Refix unit testing for Laravel

Signed-off-by: crynobone <crynobone@gmail.com>
This commit is contained in:
crynobone 2012-08-01 06:34:44 +08:00
parent 08fce4fbf8
commit d816eb9ef3
10 changed files with 209 additions and 80 deletions

View File

@ -184,13 +184,11 @@ public function testBundleMethodCorrectlySetsTheAssetBundle()
*/ */
public function testPathMethodReturnsCorrectPathForABundleAsset() public function testPathMethodReturnsCorrectPathForABundleAsset()
{ {
Config::set('application.url', 'http://localhost');
$container = $this->getContainer(); $container = $this->getContainer();
$container->bundle('eloquent'); $container->bundle('eloquent');
$this->assertEquals('http://localhost/bundles/eloquent/foo.jpg', $container->path('foo.jpg')); $this->assertEquals('/bundles/eloquent/foo.jpg', $container->path('foo.jpg'));
} }
/** /**
@ -200,11 +198,9 @@ public function testPathMethodReturnsCorrectPathForABundleAsset()
*/ */
public function testPathMethodReturnsCorrectPathForAnApplicationAsset() public function testPathMethodReturnsCorrectPathForAnApplicationAsset()
{ {
Config::set('application.url', 'http://localhost');
$container = $this->getContainer(); $container = $this->getContainer();
$this->assertEquals('http://localhost/foo.jpg', $container->path('foo.jpg')); $this->assertEquals('/foo.jpg', $container->path('foo.jpg'));
} }
/** /**

View File

@ -1,5 +1,7 @@
<?php <?php
use Symfony\Component\HttpFoundation\LaravelRequest as RequestFoundation;
use Laravel\Str; use Laravel\Str;
use Laravel\Auth; use Laravel\Auth;
use Laravel\Cookie; use Laravel\Cookie;
@ -35,6 +37,33 @@ public function tearDown()
Config::set('database.default', 'mysql'); Config::set('database.default', 'mysql');
} }
/**
* Set one of the $_SERVER variables.
*
* @param string $key
* @param string $value
*/
protected function setServerVar($key, $value)
{
$_SERVER[$key] = $value;
$this->restartRequest();
}
/**
* Reinitialize the global request.
*
* @return void
*/
protected function restartRequest()
{
// FIXME: Ugly hack, but old contents from previous requests seem to
// trip up the Foundation class.
$_FILES = array();
Request::$foundation = RequestFoundation::createFromGlobals();
}
/** /**
* Test the Auth::user method. * Test the Auth::user method.
* *
@ -54,7 +83,9 @@ public function testUserMethodReturnsCurrentUser()
*/ */
public function testCheckMethodReturnsTrueWhenUserIsSet() public function testCheckMethodReturnsTrueWhenUserIsSet()
{ {
$this->assertTrue(AuthUserReturnsDummy::check()); $auth = new AuthUserReturnsDummy;
$this->assertTrue($auth->check());
} }
/** /**
@ -64,7 +95,9 @@ public function testCheckMethodReturnsTrueWhenUserIsSet()
*/ */
public function testCheckMethodReturnsFalseWhenNoUserIsSet() public function testCheckMethodReturnsFalseWhenNoUserIsSet()
{ {
$this->assertFalse(AuthUserReturnsNull::check()); $auth = new AuthUserReturnsNull;
$this->assertFalse($auth->check());
} }
/** /**
@ -74,7 +107,9 @@ public function testCheckMethodReturnsFalseWhenNoUserIsSet()
*/ */
public function testGuestReturnsTrueWhenNoUserIsSet() public function testGuestReturnsTrueWhenNoUserIsSet()
{ {
$this->assertTrue(AuthUserReturnsNull::guest()); $auth = new AuthUserReturnsNull;
$this->assertTrue($auth->guest());
} }
/** /**
@ -84,7 +119,9 @@ public function testGuestReturnsTrueWhenNoUserIsSet()
*/ */
public function testGuestReturnsFalseWhenUserIsSet() public function testGuestReturnsFalseWhenUserIsSet()
{ {
$this->assertFalse(AuthUserReturnsDummy::guest()); $auth = new AuthUserReturnsDummy;
$this->assertFalse($auth->guest());
} }
/** /**
@ -107,10 +144,12 @@ public function testUserMethodReturnsNullWhenNoUserExistsAndNoRecallerExists()
public function testUserReturnsUserByID() public function testUserReturnsUserByID()
{ {
Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver')); Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
// FIXME: Not sure whether hard-coding the key is a good idea.
Session::$instance->session['data']['laravel_auth_drivers_fluent_login'] = 1; Auth::login(1);
$this->assertEquals('Taylor Otwell', Auth::user()->name); $this->assertEquals('Taylor Otwell', Auth::user()->name);
Auth::logout();
} }
/** /**
@ -121,8 +160,8 @@ public function testUserReturnsUserByID()
public function testNullReturnedWhenUserIDNotValidInteger() public function testNullReturnedWhenUserIDNotValidInteger()
{ {
Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver')); Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
// FIXME: Not sure whether hard-coding the key is a good idea.
Session::$instance->session['data']['laravel_auth_drivers_fluent_login'] = 'asdlkasd'; Auth::login('asdlkasd');
$this->assertNull(Auth::user()); $this->assertNull(Auth::user());
} }
@ -137,10 +176,13 @@ public function testUserCanBeRecalledViaCookie()
Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver')); Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
$cookie = Crypter::encrypt('1|'.Str::random(40)); $cookie = Crypter::encrypt('1|'.Str::random(40));
Cookie::forever(Config::get('auth.cookie'), $cookie); Cookie::forever('authloginstub_remember', $cookie);
$this->assertEquals('Taylor Otwell', AuthLoginStub::user()->name); $auth = new AuthLoginStub;
$this->assertTrue(AuthLoginStub::user() === $_SERVER['auth.login.stub']['user']);
$this->assertEquals('Taylor Otwell', $auth->user()->name);
$this->assertTrue($auth->user()->id === $_SERVER['auth.login.stub']['user']);
} }
/** /**
@ -150,11 +192,11 @@ public function testUserCanBeRecalledViaCookie()
*/ */
public function testAttemptMethodReturnsFalseWhenCredentialsAreInvalid() public function testAttemptMethodReturnsFalseWhenCredentialsAreInvalid()
{ {
$this->assertFalse(Auth::attempt('foo', 'foo')); $this->assertFalse(Auth::attempt(array('username' => 'foo', 'password' => 'foo')));
$this->assertFalse(Auth::attempt('foo', null)); $this->assertFalse(Auth::attempt(array('username' => 'foo', 'password' => null)));
$this->assertFalse(Auth::attempt(null, null)); $this->assertFalse(Auth::attempt(array('username' => null, 'password' => null)));
$this->assertFalse(Auth::attempt('taylor', 'password')); $this->assertFalse(Auth::attempt(array('username' => 'taylor', 'password' => 'password')));
$this->assertFalse(Auth::attempt('taylor', 232)); $this->assertFalse(Auth::attempt(array('username' => 'taylor', 'password' => 232)));
} }
/** /**
@ -164,13 +206,22 @@ public function testAttemptMethodReturnsFalseWhenCredentialsAreInvalid()
*/ */
public function testAttemptReturnsTrueWhenCredentialsAreCorrect() public function testAttemptReturnsTrueWhenCredentialsAreCorrect()
{ {
$this->assertTrue(AuthLoginStub::attempt('taylor', 'password1')); Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
$this->assertEquals('Taylor Otwell', $_SERVER['auth.login.stub']['user']->name);
$auth = new AuthLoginStub;
$this->assertTrue($auth->attempt(array('username' => 'taylor', 'password' => 'password1')));
$this->assertEquals('1', $_SERVER['auth.login.stub']['user']);
$this->assertFalse($_SERVER['auth.login.stub']['remember']); $this->assertFalse($_SERVER['auth.login.stub']['remember']);
$this->assertTrue(AuthLoginStub::attempt('taylor', 'password1', true)); $auth_secure = new AuthLoginStub;
$this->assertEquals('Taylor Otwell', $_SERVER['auth.login.stub']['user']->name);
$this->assertTrue($auth_secure->attempt(array('username' => 'taylor', 'password' => 'password1', 'remember' => true)));
$this->assertEquals('1', $_SERVER['auth.login.stub']['user']);
$this->assertTrue($_SERVER['auth.login.stub']['remember']); $this->assertTrue($_SERVER['auth.login.stub']['remember']);
$auth_secure->logout();
$auth->logout();
} }
/** /**
@ -189,9 +240,13 @@ public function testLoginMethodStoresUserKeyInSession()
$user = Session::$instance->session['data']['laravel_auth_drivers_fluent_login']; $user = Session::$instance->session['data']['laravel_auth_drivers_fluent_login'];
$this->assertEquals(10, $user->id); $this->assertEquals(10, $user->id);
Auth::logout();
Auth::login(5); Auth::login(5);
$user = Session::$instance->session['data']['laravel_auth_drivers_fluent_login']; $user = Session::$instance->session['data']['laravel_auth_drivers_fluent_login'];
$this->assertEquals(5, $user); $this->assertEquals(5, $user);
Auth::logout(5);
} }
/** /**
@ -203,20 +258,27 @@ public function testLoginStoresRememberCookieWhenNeeded()
{ {
Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver')); Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
$this->setServerVar('HTTPS', 'on');
// Set the session vars to make sure remember cookie uses them // Set the session vars to make sure remember cookie uses them
Config::set('session.path', 'foo'); Config::set('session.path', 'foo');
Config::set('session.domain', 'bar'); Config::set('session.domain', 'bar');
Config::set('session.secure', true); Config::set('session.secure', true);
Auth::login(10); Auth::login(1, true);
$this->assertTrue(isset(Cookie::$jar[Config::get('auth.cookie')]));
$cookie = Cookie::$jar[Config::get('auth.cookie')]['value']; $this->assertTrue(isset(Cookie::$jar['laravel_auth_drivers_fluent_remember']));
$cookie = Cookie::$jar['laravel_auth_drivers_fluent_remember']['value'];
$cookie = explode('|', Crypter::decrypt($cookie)); $cookie = explode('|', Crypter::decrypt($cookie));
$this->assertEquals(10, $cookie[0]); $this->assertEquals(1, $cookie[0]);
$this->assertEquals('foo', Cookie::$jar[Config::get('auth.cookie')]['path']); $this->assertEquals('foo', Cookie::$jar['laravel_auth_drivers_fluent_remember']['path']);
$this->assertEquals('bar', Cookie::$jar[Config::get('auth.cookie')]['domain']); $this->assertEquals('bar', Cookie::$jar['laravel_auth_drivers_fluent_remember']['domain']);
$this->assertTrue(Cookie::$jar[Config::get('auth.cookie')]['secure']); $this->assertTrue(Cookie::$jar['laravel_auth_drivers_fluent_remember']['secure']);
Auth::logout();
$this->setServerVar('HTTPS', 'off');
} }
/** /**
@ -228,40 +290,70 @@ public function testLogoutMethodLogsOutUser()
{ {
Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver')); Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
//$data = Session::$instance->session['data']['laravel_auth_drivers_fluent_login'] = 10; $data = Session::$instance->session['data']['laravel_auth_drivers_fluent_login'] = 1;
// FIXME: Restore some of these!
//Config::set('auth.logout', function($user) { $_SERVER['auth.logout.stub'] = $user; });
//Auth::$user = 'Taylor';
Auth::logout(); Auth::logout();
//$this->assertEquals('Taylor', $_SERVER['auth.logout.stub']); // A workaround since Cookie will is only stored in memory, until Response class is called.
Auth::driver()->token = null;
$this->assertNull(Auth::user()); $this->assertNull(Auth::user());
// FIXME: Not sure whether hard-coding the key is a good idea.
$this->assertFalse(isset(Session::$instance->session['data']['laravel_auth_drivers_fluent_login'])); $this->assertFalse(isset(Session::$instance->session['data']['laravel_auth_drivers_fluent_login']));
$this->assertTrue(Cookie::$jar['laravel_auth_drivers_fluent_remember']['expiration'] < time()); $this->assertTrue(Cookie::$jar['laravel_auth_drivers_fluent_remember']['expiration'] < time());
} }
} }
class AuthUserReturnsNull extends Laravel\Auth { class AuthUserReturnsNull extends Laravel\Auth\Drivers\Driver {
public static function user() {} public function user() { return null; }
public function retrieve($id) { return null; }
public function attempt($arguments = array()) { return null; }
} }
class AuthUserReturnsDummy extends Laravel\Auth { class AuthUserReturnsDummy extends Laravel\Auth\Drivers\Driver {
public static function user() { return 'Taylor'; } public function user() { return 'Taylor'; }
} public function retrieve($id) { return null; }
class AuthLoginStub extends Laravel\Auth { public function attempt($arguments = array())
public static function login($user, $remember = false)
{ {
return $this->login($arguments['username']);
}
}
class AuthLoginStub extends Laravel\Auth\Drivers\Fluent {
public function login($user, $remember = false)
{
if (is_null($remember)) $remember = false;
$_SERVER['auth.login.stub'] = compact('user', 'remember'); $_SERVER['auth.login.stub'] = compact('user', 'remember');
return parent::login($user, $remember);
}
public function logout()
{
parent::logout();
}
public function retrieve($id)
{
$user = parent::retrieve($id);
$_SERVER['auth.login.stub'] = array(
'user' => $user->id,
'remember' => false,
);
return $user;
} }
} }

View File

@ -30,10 +30,10 @@ public function testControlStructuresAreCreatedCorrectly()
$blade3 = "@if (true)\nfoo\n@elseif (false)\nbar\n@endif"; $blade3 = "@if (true)\nfoo\n@elseif (false)\nbar\n@endif";
$blade4 = "@if (true)\nfoo\n@else\nbar\n@endif"; $blade4 = "@if (true)\nfoo\n@else\nbar\n@endif";
$this->assertEquals("<?php if (true): ?>\nfoo\n<?php endif; ?>", Blade::compile_string($blade1)); $this->assertEquals("<?php if(true): ?>\nfoo\n<?php endif; ?>", Blade::compile_string($blade1));
$this->assertEquals("<?php if (count(".'$something'.") > 0): ?>\nfoo\n<?php endif; ?>", Blade::compile_string($blade2)); $this->assertEquals("<?php if(count(".'$something'.") > 0): ?>\nfoo\n<?php endif; ?>", Blade::compile_string($blade2));
$this->assertEquals("<?php if (true): ?>\nfoo\n<?php elseif (false): ?>\nbar\n<?php endif; ?>", Blade::compile_string($blade3)); $this->assertEquals("<?php if(true): ?>\nfoo\n<?php elseif(false): ?>\nbar\n<?php endif; ?>", Blade::compile_string($blade3));
$this->assertEquals("<?php if (true): ?>\nfoo\n<?php else: ?>\nbar\n<?php endif; ?>", Blade::compile_string($blade4)); $this->assertEquals("<?php if(true): ?>\nfoo\n<?php else: ?>\nbar\n<?php endif; ?>", Blade::compile_string($blade4));
} }
/** /**

View File

@ -147,10 +147,8 @@ public function testPathMethodReturnsCorrectPath()
*/ */
public function testAssetPathReturnsPathToBundlesAssets() public function testAssetPathReturnsPathToBundlesAssets()
{ {
Config::set('application.url', 'http://localhost'); $this->assertEquals('/bundles/dashboard/', Bundle::assets('dashboard'));
$this->assertEquals('/', Bundle::assets(DEFAULT_BUNDLE));
$this->assertEquals('http://localhost/bundles/dashboard/', Bundle::assets('dashboard'));
$this->assertEquals('http://localhost/', Bundle::assets(DEFAULT_BUNDLE));
Config::set('application.url', ''); Config::set('application.url', '');
} }

View File

@ -96,24 +96,24 @@ public function testFiltersCanBeConstrainedByRequestMethod()
{ {
$_SERVER['test-on-post'] = false; $_SERVER['test-on-post'] = false;
$_SERVER['REQUEST_METHOD'] = 'GET'; Request::$foundation->setMethod('GET');
Controller::call('filter@index'); Controller::call('filter@index');
$this->assertFalse($_SERVER['test-on-post']); $this->assertFalse($_SERVER['test-on-post']);
$_SERVER['REQUEST_METHOD'] = 'POST'; Request::$foundation->setMethod('POST');
Controller::call('filter@index'); Controller::call('filter@index');
$this->assertTrue($_SERVER['test-on-post']); $this->assertTrue($_SERVER['test-on-post']);
$_SERVER['test-on-get-put'] = false; $_SERVER['test-on-get-put'] = false;
$_SERVER['REQUEST_METHOD'] = 'POST'; Request::$foundation->setMethod('POST');
Controller::call('filter@index'); Controller::call('filter@index');
$this->assertFalse($_SERVER['test-on-get-put']); $this->assertFalse($_SERVER['test-on-get-put']);
$_SERVER['REQUEST_METHOD'] = 'PUT'; Request::$foundation->setMethod('PUT');
Controller::call('filter@index'); Controller::call('filter@index');
$this->assertTrue($_SERVER['test-on-get-put']); $this->assertTrue($_SERVER['test-on-get-put']);
@ -183,15 +183,18 @@ public function testMultipleFiltersCanBeAssignedToAnAction()
*/ */
public function testRestfulControllersRespondWithRestfulMethods() public function testRestfulControllersRespondWithRestfulMethods()
{ {
$_SERVER['REQUEST_METHOD'] = 'GET'; Request::$foundation->setMethod('GET');
//$_SERVER['REQUEST_METHOD'] = 'GET';
$this->assertEquals('get_index', Controller::call('restful@index')->content); $this->assertEquals('get_index', Controller::call('restful@index')->content);
$_SERVER['REQUEST_METHOD'] = 'PUT'; //$_SERVER['REQUEST_METHOD'] = 'PUT';
Request::$foundation->setMethod('PUT');
$this->assertEquals(404, Controller::call('restful@index')->status()); $this->assertEquals(404, Controller::call('restful@index')->status());
$_SERVER['REQUEST_METHOD'] = 'POST'; //$_SERVER['REQUEST_METHOD'] = 'POST';
Request::$foundation->setMethod('POST');
$this->assertEquals('post_index', Controller::call('restful@index')->content); $this->assertEquals('post_index', Controller::call('restful@index')->content);
} }

View File

@ -1,5 +1,7 @@
<?php namespace Laravel; <?php namespace Laravel;
use Symfony\Component\HttpFoundation\LaravelRequest as RequestFoundation;
/** /**
* Stub the global setcookie method into the Laravel namespace. * Stub the global setcookie method into the Laravel namespace.
*/ */
@ -31,6 +33,33 @@ public function tearDown()
Cookie::$jar = array(); Cookie::$jar = array();
} }
/**
* Set one of the $_SERVER variables.
*
* @param string $key
* @param string $value
*/
protected function setServerVar($key, $value)
{
$_SERVER[$key] = $value;
$this->restartRequest();
}
/**
* Reinitialize the global request.
*
* @return void
*/
protected function restartRequest()
{
// FIXME: Ugly hack, but old contents from previous requests seem to
// trip up the Foundation class.
$_FILES = array();
Request::$foundation = RequestFoundation::createFromGlobals();
}
/** /**
* Test Cookie::has method. * Test Cookie::has method.
* *
@ -69,12 +98,19 @@ public function testForeverShouldUseATonOfMinutes()
{ {
Cookie::forever('foo', 'bar'); Cookie::forever('foo', 'bar');
$this->assertEquals('bar', Cookie::$jar['foo']['value']); $this->assertEquals('bar', Cookie::$jar['foo']['value']);
$this->assertEquals(525600, Cookie::$jar['foo']['expiration']);
// Shouldn't be able to test this cause while we indicate -2000 seconds
// cookie expiration store timestamp.
// $this->assertEquals(525600, Cookie::$jar['foo']['expiration']);
$this->setServerVar('HTTPS', 'on');
Cookie::forever('bar', 'baz', 'path', 'domain', true); Cookie::forever('bar', 'baz', 'path', 'domain', true);
$this->assertEquals('path', Cookie::$jar['bar']['path']); $this->assertEquals('path', Cookie::$jar['bar']['path']);
$this->assertEquals('domain', Cookie::$jar['bar']['domain']); $this->assertEquals('domain', Cookie::$jar['bar']['domain']);
$this->assertTrue(Cookie::$jar['bar']['secure']); $this->assertTrue(Cookie::$jar['bar']['secure']);
$this->setServerVar('HTTPS', 'off');
} }
/** /**
@ -85,7 +121,11 @@ public function testForeverShouldUseATonOfMinutes()
public function testForgetSetsCookieWithExpiration() public function testForgetSetsCookieWithExpiration()
{ {
Cookie::forget('bar', 'path', 'domain'); Cookie::forget('bar', 'path', 'domain');
$this->assertEquals(-2000, Cookie::$jar['bar']['expiration']);
// Shouldn't be able to test this cause while we indicate -2000 seconds
// cookie expiration store timestamp.
//$this->assertEquals(-2000, Cookie::$jar['bar']['expiration']);
$this->assertEquals('path', Cookie::$jar['bar']['path']); $this->assertEquals('path', Cookie::$jar['bar']['path']);
$this->assertEquals('domain', Cookie::$jar['bar']['domain']); $this->assertEquals('domain', Cookie::$jar['bar']['domain']);
$this->assertFalse(Cookie::$jar['bar']['secure']); $this->assertFalse(Cookie::$jar['bar']['secure']);

View File

@ -149,7 +149,7 @@ public function testFlushMethodClearsFlashedInput()
{ {
$this->setSession(); $this->setSession();
$input = array('name' => 'Taylor'); $input = array('name' => 'Taylor', 'age' => 30);
Request::foundation()->request->add($input); Request::foundation()->request->add($input);
Input::flash(); Input::flash();

View File

@ -12,7 +12,7 @@ public function setUp()
Config::set('session.driver', 'foo'); Config::set('session.driver', 'foo');
Router::$routes = array(); Router::$routes = array();
Router::$names = array(); Router::$names = array();
Config::set('application.url', 'http://localhost'); URL::$base = 'http://localhost/';
Config::set('application.index', ''); Config::set('application.index', '');
} }
@ -25,7 +25,7 @@ public function tearDown()
Config::set('session.driver', ''); Config::set('session.driver', '');
Router::$routes = array(); Router::$routes = array();
Router::$names = array(); Router::$names = array();
Config::set('application.url', ''); URL::$base = '';
Config::set('application.index', 'index.php'); Config::set('application.index', 'index.php');
Session::$instance = null; Session::$instance = null;
} }

View File

@ -373,7 +373,9 @@ public function testSaveMethodSetsCookieWithCorrectValues()
$cookie = Cookie::$jar[Config::get('session.cookie')]; $cookie = Cookie::$jar[Config::get('session.cookie')];
$this->assertEquals('foo', $cookie['value']); $this->assertEquals('foo', $cookie['value']);
$this->assertEquals(Config::get('session.lifetime'), $cookie['expiration']); // Shouldn't be able to test this cause session.lifetime store number of minutes
// while cookie expiration store timestamp when it going to expired.
// $this->assertEquals(Config::get('session.lifetime'), $cookie['expiration']);
$this->assertEquals(Config::get('session.domain'), $cookie['domain']); $this->assertEquals(Config::get('session.domain'), $cookie['domain']);
$this->assertEquals(Config::get('session.path'), $cookie['path']); $this->assertEquals(Config::get('session.path'), $cookie['path']);
$this->assertEquals(Config::get('session.secure'), $cookie['secure']); $this->assertEquals(Config::get('session.secure'), $cookie['secure']);

View File

@ -49,7 +49,7 @@ public function testCorrectURIIsReturnedByCurrentMethod($uri, $expectation)
*/ */
public function testSegmentMethodReturnsAURISegment() public function testSegmentMethodReturnsAURISegment()
{ {
$this->setRequestUri('http://localhost/index.php/user/profile'); $this->setRequestUri('/user/profile');
$this->assertEquals('user', URI::segment(1)); $this->assertEquals('user', URI::segment(1));
$this->assertEquals('profile', URI::segment(2)); $this->assertEquals('profile', URI::segment(2));
@ -61,16 +61,14 @@ public function testSegmentMethodReturnsAURISegment()
public function requestUriProvider() public function requestUriProvider()
{ {
return array( return array(
array('/index.php', '/'), array('/user', 'user'),
array('/index.php/', '/'), array('/user/', 'user'),
array('http://localhost/user', 'user'), array('', '/'),
array('http://localhost/user/', 'user'), array('/', '/'),
array('http://localhost/index.php', '/'), array('//', '/'),
array('http://localhost/index.php/', '/'), array('/user', 'user'),
array('http://localhost/index.php//', '/'), array('/user/', 'user'),
array('http://localhost/index.php/user', 'user'), array('/user/profile', 'user/profile'),
array('http://localhost/index.php/user/', 'user'),
array('http://localhost/index.php/user/profile', 'user/profile'),
); );
} }