Commit fcbd132c authored by Igor Wiedler's avatar Igor Wiedler

remove dummy domain from Request::create() calls in tests

parent 3641d78b
...@@ -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);
......
...@@ -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);
} }
......
...@@ -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);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment