diff --git a/classes/Kohana/Request.php b/classes/Kohana/Request.php index 2fe0f29e8..72e0affee 100644 --- a/classes/Kohana/Request.php +++ b/classes/Kohana/Request.php @@ -668,7 +668,7 @@ public function __construct($uri, $client_params = array(), $allow_external = TR $uri = array_shift($split_uri); // Initial request has global $_GET already applied - if (Request::$initial !== NULL) + if (Request::$initial === NULL) { if ($split_uri) { diff --git a/tests/kohana/HTTPTest.php b/tests/kohana/HTTPTest.php index 94c123deb..33ce72672 100644 --- a/tests/kohana/HTTPTest.php +++ b/tests/kohana/HTTPTest.php @@ -15,6 +15,8 @@ */ class Kohana_HTTPTest extends Unittest_TestCase { + protected $_inital_request; + /** * Sets up the environment */ @@ -24,8 +26,21 @@ public function setUp() { parent::setUp(); Kohana::$config->load('url')->set('trusted_hosts', array('www\.example\.com')); + $this->_initial_request = Request::$initial; + Request::$initial = new Request('/'); } + /** + * Tears down whatever is setUp + */ + // @codingStandardsIgnoreStart + public function tearDown() + // @codingStandardsIgnoreEnd + { + Request::$initial = $this->_initial_request; + parent::tearDown(); + } + // @codingStandardsIgnoreStart /** * Defaults for this test diff --git a/tests/kohana/RequestTest.php b/tests/kohana/RequestTest.php index bb5f74b7a..390e33885 100644 --- a/tests/kohana/RequestTest.php +++ b/tests/kohana/RequestTest.php @@ -523,18 +523,18 @@ public function provider_headers_get() { $x_powered_by = 'Kohana Unit Test'; $content_type = 'application/x-www-form-urlencoded'; + $request = new Request('foo/bar', array(), TRUE, array()); return array( array( - $request = Request::factory('foo/bar') - ->headers(array( + $request->headers(array( 'x-powered-by' => $x_powered_by, 'content-type' => $content_type ) ), - array( - 'x-powered-by' => $x_powered_by, - 'content-type' => $content_type + array( + 'x-powered-by' => $x_powered_by, + 'content-type' => $content_type ) ) ); @@ -566,7 +566,6 @@ public function provider_headers_set() { return array( array( - Request::factory(), array( 'content-type' => 'application/x-www-form-urlencoded', 'x-test-header' => 'foo' @@ -574,7 +573,6 @@ public function provider_headers_set() "Content-Type: application/x-www-form-urlencoded\r\nX-Test-Header: foo\r\n\r\n" ), array( - Request::factory(), array( 'content-type' => 'application/json', 'x-powered-by' => 'kohana' @@ -589,13 +587,13 @@ public function provider_headers_set() * * @dataProvider provider_headers_set * - * @param Request request object * @param array header(s) to set to the request object * @param string expected http header * @return void */ - public function test_headers_set(Request $request, $headers, $expected) + public function test_headers_set($headers, $expected) { + $request = new Request(TRUE, array(), TRUE, array()); $request->headers($headers); $this->assertSame($expected, (string) $request->headers()); }