Refix unit testing for Laravel
Signed-off-by: crynobone <crynobone@gmail.com>
This commit is contained in:
parent
08fce4fbf8
commit
d816eb9ef3
|
@ -184,13 +184,11 @@ public function testBundleMethodCorrectlySetsTheAssetBundle()
|
|||
*/
|
||||
public function testPathMethodReturnsCorrectPathForABundleAsset()
|
||||
{
|
||||
Config::set('application.url', 'http://localhost');
|
||||
|
||||
$container = $this->getContainer();
|
||||
|
||||
$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()
|
||||
{
|
||||
Config::set('application.url', 'http://localhost');
|
||||
|
||||
$container = $this->getContainer();
|
||||
|
||||
$this->assertEquals('http://localhost/foo.jpg', $container->path('foo.jpg'));
|
||||
$this->assertEquals('/foo.jpg', $container->path('foo.jpg'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Symfony\Component\HttpFoundation\LaravelRequest as RequestFoundation;
|
||||
|
||||
use Laravel\Str;
|
||||
use Laravel\Auth;
|
||||
use Laravel\Cookie;
|
||||
|
@ -35,6 +37,33 @@ public function tearDown()
|
|||
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.
|
||||
*
|
||||
|
@ -54,7 +83,9 @@ public function testUserMethodReturnsCurrentUser()
|
|||
*/
|
||||
public function testCheckMethodReturnsTrueWhenUserIsSet()
|
||||
{
|
||||
$this->assertTrue(AuthUserReturnsDummy::check());
|
||||
$auth = new AuthUserReturnsDummy;
|
||||
|
||||
$this->assertTrue($auth->check());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,7 +95,9 @@ public function testCheckMethodReturnsTrueWhenUserIsSet()
|
|||
*/
|
||||
public function testCheckMethodReturnsFalseWhenNoUserIsSet()
|
||||
{
|
||||
$this->assertFalse(AuthUserReturnsNull::check());
|
||||
$auth = new AuthUserReturnsNull;
|
||||
|
||||
$this->assertFalse($auth->check());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,7 +107,9 @@ public function testCheckMethodReturnsFalseWhenNoUserIsSet()
|
|||
*/
|
||||
public function testGuestReturnsTrueWhenNoUserIsSet()
|
||||
{
|
||||
$this->assertTrue(AuthUserReturnsNull::guest());
|
||||
$auth = new AuthUserReturnsNull;
|
||||
|
||||
$this->assertTrue($auth->guest());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,7 +119,9 @@ public function testGuestReturnsTrueWhenNoUserIsSet()
|
|||
*/
|
||||
public function testGuestReturnsFalseWhenUserIsSet()
|
||||
{
|
||||
$this->assertFalse(AuthUserReturnsDummy::guest());
|
||||
$auth = new AuthUserReturnsDummy;
|
||||
|
||||
$this->assertFalse($auth->guest());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,10 +144,12 @@ public function testUserMethodReturnsNullWhenNoUserExistsAndNoRecallerExists()
|
|||
public function testUserReturnsUserByID()
|
||||
{
|
||||
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);
|
||||
|
||||
Auth::logout();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,8 +160,8 @@ public function testUserReturnsUserByID()
|
|||
public function testNullReturnedWhenUserIDNotValidInteger()
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
@ -137,10 +176,13 @@ public function testUserCanBeRecalledViaCookie()
|
|||
Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
|
||||
|
||||
$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);
|
||||
$this->assertTrue(AuthLoginStub::user() === $_SERVER['auth.login.stub']['user']);
|
||||
$auth = new AuthLoginStub;
|
||||
|
||||
$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()
|
||||
{
|
||||
$this->assertFalse(Auth::attempt('foo', 'foo'));
|
||||
$this->assertFalse(Auth::attempt('foo', null));
|
||||
$this->assertFalse(Auth::attempt(null, null));
|
||||
$this->assertFalse(Auth::attempt('taylor', 'password'));
|
||||
$this->assertFalse(Auth::attempt('taylor', 232));
|
||||
$this->assertFalse(Auth::attempt(array('username' => 'foo', 'password' => 'foo')));
|
||||
$this->assertFalse(Auth::attempt(array('username' => 'foo', 'password' => null)));
|
||||
$this->assertFalse(Auth::attempt(array('username' => null, 'password' => null)));
|
||||
$this->assertFalse(Auth::attempt(array('username' => 'taylor', 'password' => 'password')));
|
||||
$this->assertFalse(Auth::attempt(array('username' => 'taylor', 'password' => 232)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -164,13 +206,22 @@ public function testAttemptMethodReturnsFalseWhenCredentialsAreInvalid()
|
|||
*/
|
||||
public function testAttemptReturnsTrueWhenCredentialsAreCorrect()
|
||||
{
|
||||
$this->assertTrue(AuthLoginStub::attempt('taylor', 'password1'));
|
||||
$this->assertEquals('Taylor Otwell', $_SERVER['auth.login.stub']['user']->name);
|
||||
Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
|
||||
|
||||
$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->assertTrue(AuthLoginStub::attempt('taylor', 'password1', true));
|
||||
$this->assertEquals('Taylor Otwell', $_SERVER['auth.login.stub']['user']->name);
|
||||
$auth_secure = new AuthLoginStub;
|
||||
|
||||
$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']);
|
||||
|
||||
$auth_secure->logout();
|
||||
$auth->logout();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -189,9 +240,13 @@ public function testLoginMethodStoresUserKeyInSession()
|
|||
$user = Session::$instance->session['data']['laravel_auth_drivers_fluent_login'];
|
||||
$this->assertEquals(10, $user->id);
|
||||
|
||||
|
||||
Auth::logout();
|
||||
|
||||
Auth::login(5);
|
||||
$user = Session::$instance->session['data']['laravel_auth_drivers_fluent_login'];
|
||||
$this->assertEquals(5, $user);
|
||||
Auth::logout(5);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -203,20 +258,27 @@ public function testLoginStoresRememberCookieWhenNeeded()
|
|||
{
|
||||
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
|
||||
Config::set('session.path', 'foo');
|
||||
Config::set('session.domain', 'bar');
|
||||
Config::set('session.secure', true);
|
||||
|
||||
Auth::login(10);
|
||||
$this->assertTrue(isset(Cookie::$jar[Config::get('auth.cookie')]));
|
||||
Auth::login(1, true);
|
||||
|
||||
$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));
|
||||
$this->assertEquals(10, $cookie[0]);
|
||||
$this->assertEquals('foo', Cookie::$jar[Config::get('auth.cookie')]['path']);
|
||||
$this->assertEquals('bar', Cookie::$jar[Config::get('auth.cookie')]['domain']);
|
||||
$this->assertTrue(Cookie::$jar[Config::get('auth.cookie')]['secure']);
|
||||
$this->assertEquals(1, $cookie[0]);
|
||||
$this->assertEquals('foo', Cookie::$jar['laravel_auth_drivers_fluent_remember']['path']);
|
||||
$this->assertEquals('bar', Cookie::$jar['laravel_auth_drivers_fluent_remember']['domain']);
|
||||
$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'));
|
||||
|
||||
//$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();
|
||||
|
||||
//$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());
|
||||
// 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->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 static function login($user, $remember = false)
|
||||
public function attempt($arguments = array())
|
||||
{
|
||||
$_SERVER['auth.login.stub'] = compact('user', 'remember');
|
||||
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');
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -30,10 +30,10 @@ public function testControlStructuresAreCreatedCorrectly()
|
|||
$blade3 = "@if (true)\nfoo\n@elseif (false)\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 (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 else: ?>\nbar\n<?php endif; ?>", Blade::compile_string($blade4));
|
||||
$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(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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -147,10 +147,8 @@ public function testPathMethodReturnsCorrectPath()
|
|||
*/
|
||||
public function testAssetPathReturnsPathToBundlesAssets()
|
||||
{
|
||||
Config::set('application.url', 'http://localhost');
|
||||
|
||||
$this->assertEquals('http://localhost/bundles/dashboard/', Bundle::assets('dashboard'));
|
||||
$this->assertEquals('http://localhost/', Bundle::assets(DEFAULT_BUNDLE));
|
||||
$this->assertEquals('/bundles/dashboard/', Bundle::assets('dashboard'));
|
||||
$this->assertEquals('/', Bundle::assets(DEFAULT_BUNDLE));
|
||||
|
||||
Config::set('application.url', '');
|
||||
}
|
||||
|
|
|
@ -96,24 +96,24 @@ public function testFiltersCanBeConstrainedByRequestMethod()
|
|||
{
|
||||
$_SERVER['test-on-post'] = false;
|
||||
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
Request::$foundation->setMethod('GET');
|
||||
Controller::call('filter@index');
|
||||
|
||||
$this->assertFalse($_SERVER['test-on-post']);
|
||||
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
Request::$foundation->setMethod('POST');
|
||||
Controller::call('filter@index');
|
||||
|
||||
$this->assertTrue($_SERVER['test-on-post']);
|
||||
|
||||
$_SERVER['test-on-get-put'] = false;
|
||||
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
Request::$foundation->setMethod('POST');
|
||||
Controller::call('filter@index');
|
||||
|
||||
$this->assertFalse($_SERVER['test-on-get-put']);
|
||||
|
||||
$_SERVER['REQUEST_METHOD'] = 'PUT';
|
||||
Request::$foundation->setMethod('PUT');
|
||||
Controller::call('filter@index');
|
||||
|
||||
$this->assertTrue($_SERVER['test-on-get-put']);
|
||||
|
@ -183,15 +183,18 @@ public function testMultipleFiltersCanBeAssignedToAnAction()
|
|||
*/
|
||||
public function testRestfulControllersRespondWithRestfulMethods()
|
||||
{
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
Request::$foundation->setMethod('GET');
|
||||
//$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
|
||||
$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());
|
||||
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
//$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
Request::$foundation->setMethod('POST');
|
||||
|
||||
$this->assertEquals('post_index', Controller::call('restful@index')->content);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php namespace Laravel;
|
||||
|
||||
use Symfony\Component\HttpFoundation\LaravelRequest as RequestFoundation;
|
||||
|
||||
/**
|
||||
* Stub the global setcookie method into the Laravel namespace.
|
||||
*/
|
||||
|
@ -31,6 +33,33 @@ public function tearDown()
|
|||
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.
|
||||
*
|
||||
|
@ -69,12 +98,19 @@ public function testForeverShouldUseATonOfMinutes()
|
|||
{
|
||||
Cookie::forever('foo', 'bar');
|
||||
$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);
|
||||
$this->assertEquals('path', Cookie::$jar['bar']['path']);
|
||||
$this->assertEquals('domain', Cookie::$jar['bar']['domain']);
|
||||
$this->assertTrue(Cookie::$jar['bar']['secure']);
|
||||
|
||||
$this->setServerVar('HTTPS', 'off');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,7 +121,11 @@ public function testForeverShouldUseATonOfMinutes()
|
|||
public function testForgetSetsCookieWithExpiration()
|
||||
{
|
||||
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('domain', Cookie::$jar['bar']['domain']);
|
||||
$this->assertFalse(Cookie::$jar['bar']['secure']);
|
||||
|
|
|
@ -149,7 +149,7 @@ public function testFlushMethodClearsFlashedInput()
|
|||
{
|
||||
$this->setSession();
|
||||
|
||||
$input = array('name' => 'Taylor');
|
||||
$input = array('name' => 'Taylor', 'age' => 30);
|
||||
Request::foundation()->request->add($input);
|
||||
|
||||
Input::flash();
|
||||
|
|
|
@ -12,7 +12,7 @@ public function setUp()
|
|||
Config::set('session.driver', 'foo');
|
||||
Router::$routes = array();
|
||||
Router::$names = array();
|
||||
Config::set('application.url', 'http://localhost');
|
||||
URL::$base = 'http://localhost/';
|
||||
Config::set('application.index', '');
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public function tearDown()
|
|||
Config::set('session.driver', '');
|
||||
Router::$routes = array();
|
||||
Router::$names = array();
|
||||
Config::set('application.url', '');
|
||||
URL::$base = '';
|
||||
Config::set('application.index', 'index.php');
|
||||
Session::$instance = null;
|
||||
}
|
||||
|
|
|
@ -373,7 +373,9 @@ public function testSaveMethodSetsCookieWithCorrectValues()
|
|||
$cookie = Cookie::$jar[Config::get('session.cookie')];
|
||||
|
||||
$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.path'), $cookie['path']);
|
||||
$this->assertEquals(Config::get('session.secure'), $cookie['secure']);
|
||||
|
|
|
@ -49,7 +49,7 @@ public function testCorrectURIIsReturnedByCurrentMethod($uri, $expectation)
|
|||
*/
|
||||
public function testSegmentMethodReturnsAURISegment()
|
||||
{
|
||||
$this->setRequestUri('http://localhost/index.php/user/profile');
|
||||
$this->setRequestUri('/user/profile');
|
||||
|
||||
$this->assertEquals('user', URI::segment(1));
|
||||
$this->assertEquals('profile', URI::segment(2));
|
||||
|
@ -61,16 +61,14 @@ public function testSegmentMethodReturnsAURISegment()
|
|||
public function requestUriProvider()
|
||||
{
|
||||
return array(
|
||||
array('/index.php', '/'),
|
||||
array('/index.php/', '/'),
|
||||
array('http://localhost/user', 'user'),
|
||||
array('http://localhost/user/', 'user'),
|
||||
array('http://localhost/index.php', '/'),
|
||||
array('http://localhost/index.php/', '/'),
|
||||
array('http://localhost/index.php//', '/'),
|
||||
array('http://localhost/index.php/user', 'user'),
|
||||
array('http://localhost/index.php/user/', 'user'),
|
||||
array('http://localhost/index.php/user/profile', 'user/profile'),
|
||||
array('/user', 'user'),
|
||||
array('/user/', 'user'),
|
||||
array('', '/'),
|
||||
array('/', '/'),
|
||||
array('//', '/'),
|
||||
array('/user', 'user'),
|
||||
array('/user/', 'user'),
|
||||
array('/user/profile', 'user/profile'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue