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
fcbd132c
Commit
fcbd132c
authored
Feb 04, 2011
by
Igor Wiedler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove dummy domain from Request::create() calls in tests
parent
3641d78b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
16 deletions
+16
-16
tests/Silex/Tests/BeforeAfterFilterTest.php
tests/Silex/Tests/BeforeAfterFilterTest.php
+1
-1
tests/Silex/Tests/ErrorHandlerTest.php
tests/Silex/Tests/ErrorHandlerTest.php
+7
-7
tests/Silex/Tests/RouterTest.php
tests/Silex/Tests/RouterTest.php
+8
-8
No files found.
tests/Silex/Tests/BeforeAfterFilterTest.php
View file @
fcbd132c
...
@@ -43,7 +43,7 @@ class BeforeAfterFilterTest extends \PHPUnit_Framework_TestCase
...
@@ -43,7 +43,7 @@ class BeforeAfterFilterTest extends \PHPUnit_Framework_TestCase
$i
++
;
$i
++
;
});
});
$request
=
Request
::
create
(
'
http://test.com
/foo'
);
$request
=
Request
::
create
(
'/foo'
);
$framework
->
handle
(
$request
);
$framework
->
handle
(
$request
);
$test
->
assertEquals
(
3
,
$i
);
$test
->
assertEquals
(
3
,
$i
);
...
...
tests/Silex/Tests/ErrorHandlerTest.php
View file @
fcbd132c
...
@@ -32,7 +32,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
...
@@ -32,7 +32,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
));
));
try
{
try
{
$request
=
Request
::
create
(
'
http://test.com
/foo'
);
$request
=
Request
::
create
(
'/foo'
);
$framework
->
handle
(
$request
);
$framework
->
handle
(
$request
);
$this
->
fail
(
'->handle() should not catch exceptions where no error handler was supplied'
);
$this
->
fail
(
'->handle() should not catch exceptions where no error handler was supplied'
);
}
catch
(
\RuntimeException
$e
)
{
}
catch
(
\RuntimeException
$e
)
{
...
@@ -52,7 +52,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
...
@@ -52,7 +52,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
return
new
Response
(
'foo exception handler'
);
return
new
Response
(
'foo exception handler'
);
});
});
$request
=
Request
::
create
(
'
http://test.com
/foo'
);
$request
=
Request
::
create
(
'/foo'
);
$this
->
checkRouteResponse
(
$framework
,
'/foo'
,
'foo exception handler'
);
$this
->
checkRouteResponse
(
$framework
,
'/foo'
,
'foo exception handler'
);
}
}
...
@@ -80,7 +80,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
...
@@ -80,7 +80,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
return
new
Response
(
'foo exception handler 2'
);
return
new
Response
(
'foo exception handler 2'
);
});
});
$request
=
Request
::
create
(
'
http://test.com
/foo'
);
$request
=
Request
::
create
(
'/foo'
);
$this
->
checkRouteResponse
(
$framework
,
'/foo'
,
'foo exception handler'
,
'should return the first response returned by an exception handler'
);
$this
->
checkRouteResponse
(
$framework
,
'/foo'
,
'foo exception handler'
,
'should return the first response returned by an exception handler'
);
$this
->
assertEquals
(
3
,
$errors
,
'should execute all error handlers'
);
$this
->
assertEquals
(
3
,
$errors
,
'should execute all error handlers'
);
...
@@ -101,7 +101,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
...
@@ -101,7 +101,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
});
});
try
{
try
{
$request
=
Request
::
create
(
'
http://test.com
/foo'
);
$request
=
Request
::
create
(
'/foo'
);
$framework
->
handle
(
$request
);
$framework
->
handle
(
$request
);
$this
->
fail
(
'->handle() should not catch exceptions where an empty error handler was supplied'
);
$this
->
fail
(
'->handle() should not catch exceptions where an empty error handler was supplied'
);
}
catch
(
\RuntimeException
$e
)
{
}
catch
(
\RuntimeException
$e
)
{
...
@@ -123,7 +123,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
...
@@ -123,7 +123,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
return
'foo exception handler'
;
return
'foo exception handler'
;
});
});
$request
=
Request
::
create
(
'
http://test.com
/foo'
);
$request
=
Request
::
create
(
'/foo'
);
$this
->
checkRouteResponse
(
$framework
,
'/foo'
,
'foo exception handler'
,
'should accept a string response from the error handler'
);
$this
->
checkRouteResponse
(
$framework
,
'/foo'
,
'foo exception handler'
,
'should accept a string response from the error handler'
);
}
}
...
@@ -140,7 +140,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
...
@@ -140,7 +140,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
});
});
try
{
try
{
$request
=
Request
::
create
(
'
http://test.com
/foo'
);
$request
=
Request
::
create
(
'/foo'
);
$this
->
checkRouteResponse
(
$framework
,
'/foo'
,
'foo exception handler'
,
'should accept a string response from the error handler'
);
$this
->
checkRouteResponse
(
$framework
,
'/foo'
,
'foo exception handler'
,
'should accept a string response from the error handler'
);
$this
->
fail
(
'->handle() should not catch exceptions thrown from an error handler'
);
$this
->
fail
(
'->handle() should not catch exceptions thrown from an error handler'
);
}
catch
(
\RuntimeException
$e
)
{
}
catch
(
\RuntimeException
$e
)
{
...
@@ -150,7 +150,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
...
@@ -150,7 +150,7 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
protected
function
checkRouteResponse
(
$framework
,
$path
,
$expectedContent
,
$method
=
'get'
,
$message
=
null
)
protected
function
checkRouteResponse
(
$framework
,
$path
,
$expectedContent
,
$method
=
'get'
,
$message
=
null
)
{
{
$request
=
Request
::
create
(
'http://test.com'
.
$path
,
$method
);
$request
=
Request
::
create
(
$path
,
$method
);
$response
=
$framework
->
handle
(
$request
);
$response
=
$framework
->
handle
(
$request
);
$this
->
assertEquals
(
$expectedContent
,
$response
->
getContent
(),
$message
);
$this
->
assertEquals
(
$expectedContent
,
$response
->
getContent
(),
$message
);
}
}
...
...
tests/Silex/Tests/RouterTest.php
View file @
fcbd132c
...
@@ -71,7 +71,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
...
@@ -71,7 +71,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
$this
->
checkRouteResponse
(
$framework
,
'/'
,
'root'
,
'delete'
);
$this
->
checkRouteResponse
(
$framework
,
'/'
,
'root'
,
'delete'
);
try
{
try
{
$request
=
Request
::
create
(
'
http://test.com
/bar'
);
$request
=
Request
::
create
(
'/bar'
);
$framework
->
handle
(
$request
);
$framework
->
handle
(
$request
);
$this
->
fail
(
'Framework must reject HTTP GET method to /bar'
);
$this
->
fail
(
'Framework must reject HTTP GET method to /bar'
);
...
@@ -79,7 +79,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
...
@@ -79,7 +79,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
}
}
try
{
try
{
$request
=
Request
::
create
(
'
http://test.com
/bar'
,
'post'
);
$request
=
Request
::
create
(
'/bar'
,
'post'
);
$framework
->
handle
(
$request
);
$framework
->
handle
(
$request
);
$this
->
fail
(
'Framework must reject HTTP POST method to /bar'
);
$this
->
fail
(
'Framework must reject HTTP POST method to /bar'
);
...
@@ -130,15 +130,15 @@ class RouterTest extends \PHPUnit_Framework_TestCase
...
@@ -130,15 +130,15 @@ class RouterTest extends \PHPUnit_Framework_TestCase
},
},
));
));
$request
=
Request
::
create
(
'
http://test.com
/created'
,
'put'
);
$request
=
Request
::
create
(
'/created'
,
'put'
);
$response
=
$framework
->
handle
(
$request
);
$response
=
$framework
->
handle
(
$request
);
$this
->
assertEquals
(
201
,
$response
->
getStatusCode
());
$this
->
assertEquals
(
201
,
$response
->
getStatusCode
());
$request
=
Request
::
create
(
'
http://test.com
/forbidden'
);
$request
=
Request
::
create
(
'/forbidden'
);
$response
=
$framework
->
handle
(
$request
);
$response
=
$framework
->
handle
(
$request
);
$this
->
assertEquals
(
403
,
$response
->
getStatusCode
());
$this
->
assertEquals
(
403
,
$response
->
getStatusCode
());
$request
=
Request
::
create
(
'
http://test.com
/not_found'
);
$request
=
Request
::
create
(
'/not_found'
);
$response
=
$framework
->
handle
(
$request
);
$response
=
$framework
->
handle
(
$request
);
$this
->
assertEquals
(
404
,
$response
->
getStatusCode
());
$this
->
assertEquals
(
404
,
$response
->
getStatusCode
());
}
}
...
@@ -153,7 +153,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
...
@@ -153,7 +153,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
},
},
));
));
$request
=
Request
::
create
(
'
http://test.com
/redirect'
);
$request
=
Request
::
create
(
'/redirect'
);
$response
=
$framework
->
handle
(
$request
);
$response
=
$framework
->
handle
(
$request
);
$this
->
assertTrue
(
$response
->
isRedirected
(
'/target'
));
$this
->
assertTrue
(
$response
->
isRedirected
(
'/target'
));
}
}
...
@@ -165,7 +165,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
...
@@ -165,7 +165,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
{
{
$framework
=
new
Framework
();
$framework
=
new
Framework
();
$request
=
Request
::
create
(
'
http://test.com
/baz'
);
$request
=
Request
::
create
(
'/baz'
);
$framework
->
handle
(
$request
);
$framework
->
handle
(
$request
);
}
}
...
@@ -202,7 +202,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
...
@@ -202,7 +202,7 @@ class RouterTest extends \PHPUnit_Framework_TestCase
protected
function
checkRouteResponse
(
$framework
,
$path
,
$expectedContent
,
$method
=
'get'
,
$message
=
null
)
protected
function
checkRouteResponse
(
$framework
,
$path
,
$expectedContent
,
$method
=
'get'
,
$message
=
null
)
{
{
$request
=
Request
::
create
(
'http://test.com'
.
$path
,
$method
);
$request
=
Request
::
create
(
$path
,
$method
);
$response
=
$framework
->
handle
(
$request
);
$response
=
$framework
->
handle
(
$request
);
$this
->
assertEquals
(
$expectedContent
,
$response
->
getContent
(),
$message
);
$this
->
assertEquals
(
$expectedContent
,
$response
->
getContent
(),
$message
);
}
}
...
...
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