Fix PHP errors in test cases related to now using Symfony's HttpFoundation component.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\HttpFoundation\LaravelRequest as RequestFoundation;
|
||||
|
||||
class URITest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
@@ -12,6 +14,21 @@ class URITest extends PHPUnit_Framework_TestCase {
|
||||
URI::$segments = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set this request's URI to the given string
|
||||
*
|
||||
* @param string $uri
|
||||
*/
|
||||
protected function setRequestUri($uri)
|
||||
{
|
||||
// FIXME: Ugly hack, but old contents from previous requests seem to
|
||||
// trip up the Foundation class.
|
||||
$_FILES = array();
|
||||
|
||||
$_SERVER['REQUEST_URI'] = $uri;
|
||||
Request::$foundation = RequestFoundation::createFromGlobals();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the URI::current method.
|
||||
*
|
||||
@@ -20,7 +37,8 @@ class URITest extends PHPUnit_Framework_TestCase {
|
||||
*/
|
||||
public function testCorrectURIIsReturnedByCurrentMethod($uri, $expectation)
|
||||
{
|
||||
$_SERVER['REQUEST_URI'] = $uri;
|
||||
$this->setRequestUri($uri);
|
||||
|
||||
$this->assertEquals($expectation, URI::current());
|
||||
}
|
||||
|
||||
@@ -31,7 +49,7 @@ class URITest extends PHPUnit_Framework_TestCase {
|
||||
*/
|
||||
public function testSegmentMethodReturnsAURISegment()
|
||||
{
|
||||
$_SERVER['REQUEST_URI'] = 'http://localhost/index.php/user/profile';
|
||||
$this->setRequestUri('http://localhost/index.php/user/profile');
|
||||
|
||||
$this->assertEquals('user', URI::segment(1));
|
||||
$this->assertEquals('profile', URI::segment(2));
|
||||
|
||||
Reference in New Issue
Block a user