Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
6358f7ef
Commit
6358f7ef
authored
Jul 13, 2012
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added some tests to avoid regressions in the future
parent
b5790ea0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
5 deletions
+38
-5
composer.lock
composer.lock
+2
-2
tests/Silex/Tests/ErrorHandlerTest.php
tests/Silex/Tests/ErrorHandlerTest.php
+36
-3
No files found.
composer.lock
View file @
6358f7ef
...
...
@@ -46,8 +46,8 @@
{
"package": "symfony/http-kernel",
"version": "dev-master",
"source-reference": "
538a38c4919a982c1f68ad129178a0e3bb78a4c5
",
"commit-date": "134217
3351
"
"source-reference": "
dc93ba8c91cb4d6de78bb32e9836cf32088f0626
",
"commit-date": "134217
4453
"
},
{
"package": "symfony/routing",
...
...
tests/Silex/Tests/ErrorHandlerTest.php
View file @
6358f7ef
...
...
@@ -77,6 +77,34 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
404
,
$response
->
getStatusCode
());
}
public
function
testErrorHandlerMethodNotAllowedNoDebug
()
{
$app
=
new
Application
();
$app
[
'debug'
]
=
false
;
$app
->
get
(
'/foo'
,
function
()
{
return
'foo'
;
});
$request
=
Request
::
create
(
'/foo'
,
'POST'
);
$response
=
$app
->
handle
(
$request
);
$this
->
assertContains
(
'<title>Whoops, looks like something went wrong.</title>'
,
$response
->
getContent
());
$this
->
assertEquals
(
405
,
$response
->
getStatusCode
());
$this
->
assertEquals
(
'GET'
,
$response
->
headers
->
get
(
'Allow'
));
}
public
function
testErrorHandlerMethodNotAllowedDebug
()
{
$app
=
new
Application
();
$app
[
'debug'
]
=
true
;
$app
->
get
(
'/foo'
,
function
()
{
return
'foo'
;
});
$request
=
Request
::
create
(
'/foo'
,
'POST'
);
$response
=
$app
->
handle
(
$request
);
$this
->
assertContains
(
'No route found for "POST /foo": Method Not Allowed (Allow: GET)'
,
$response
->
getContent
());
$this
->
assertEquals
(
405
,
$response
->
getStatusCode
());
$this
->
assertEquals
(
'GET'
,
$response
->
headers
->
get
(
'Allow'
));
}
public
function
testNoErrorHandler
()
{
$app
=
new
Application
();
...
...
@@ -107,16 +135,21 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
throw
new
NotFoundHttpException
(
'foo exception'
);
});
$app
->
get
(
'/405'
,
function
()
{
return
'foo'
;
});
$app
->
error
(
function
(
$e
,
$code
)
{
return
new
Response
(
'foo exception handler'
,
$code
);
return
new
Response
(
'foo exception handler'
);
});
$response
=
$this
->
checkRouteResponse
(
$app
,
'/500'
,
'foo exception handler'
);
$this
->
assertEquals
(
500
,
$response
->
getStatusCode
());
$request
=
Request
::
create
(
'/404'
);
$response
=
$app
->
handle
(
$request
);
$response
=
$app
->
handle
(
Request
::
create
(
'/404'
));
$this
->
assertEquals
(
404
,
$response
->
getStatusCode
());
$response
=
$app
->
handle
(
Request
::
create
(
'/405'
,
'POST'
));
$this
->
assertEquals
(
405
,
$response
->
getStatusCode
());
$this
->
assertEquals
(
'GET'
,
$response
->
headers
->
get
(
'Allow'
));
}
public
function
testMultipleErrorHandlers
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment