Fix PHP errors in test cases related to now using Symfony's HttpFoundation component.

This commit is contained in:
Franz Liedke
2012-07-13 03:05:55 +02:00
parent 86013f1b84
commit feefa8d9c4
5 changed files with 91 additions and 42 deletions

View File

@@ -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));