Update auth test case
Signed-off-by: crynobone <crynobone@gmail.com>
This commit is contained in:
parent
ba661e5768
commit
590872d3c6
|
@ -17,6 +17,9 @@ class AuthTest extends PHPUnit_Framework_TestCase {
|
|||
public function setUp()
|
||||
{
|
||||
$_SERVER['auth.login.stub'] = null;
|
||||
$_SERVER['test.user.login'] = null;
|
||||
$_SERVER['test.user.logout'] = null;
|
||||
|
||||
Cookie::$jar = array();
|
||||
Config::$items = array();
|
||||
Auth::driver()->user = null;
|
||||
|
@ -30,6 +33,9 @@ public function setUp()
|
|||
public function tearDown()
|
||||
{
|
||||
$_SERVER['auth.login.stub'] = null;
|
||||
$_SERVER['test.user.login'] = null;
|
||||
$_SERVER['test.user.logout'] = null;
|
||||
|
||||
Cookie::$jar = array();
|
||||
Config::$items = array();
|
||||
Auth::driver()->user = null;
|
||||
|
@ -300,6 +306,37 @@ public function testLogoutMethodLogsOutUser()
|
|||
$this->assertTrue(Cookie::$jar['laravel_auth_drivers_fluent_remember']['expiration'] < time());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test `laravel.auth: login` and `laravel.auth: logout` is called properly
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testAuthEventIsCalledProperly()
|
||||
{
|
||||
Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
|
||||
|
||||
Event::listen('laravel.auth: login', function ()
|
||||
{
|
||||
$_SERVER['test.user.login'] = 'foo';
|
||||
});
|
||||
|
||||
Event::listen('laravel.auth: logout', function ()
|
||||
{
|
||||
$_SERVER['test.user.logout'] = 'foo';
|
||||
});
|
||||
|
||||
$this->assertNull($_SERVER['test.user.login']);
|
||||
$this->assertNull($_SERVER['test.user.logout']);
|
||||
|
||||
Auth::login(1, true);
|
||||
|
||||
$this->assertEquals('foo', $_SERVER['test.user.login']);
|
||||
|
||||
Auth::logout();
|
||||
|
||||
$this->assertEquals('foo', $_SERVER['test.user.logout']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class AuthUserReturnsNull extends Laravel\Auth\Drivers\Driver {
|
||||
|
|
Loading…
Reference in New Issue