adding some basic auth tests.
This commit is contained in:
parent
19f8430ce2
commit
f4e1eaf29e
|
@ -1,4 +1,6 @@
|
|||
<phpunit colors="true" bootstrap="phpunit.php">
|
||||
<phpunit colors="true"
|
||||
bootstrap="phpunit.php"
|
||||
backupGlobals="false">
|
||||
<testsuites>
|
||||
<testsuite name="Test Suite">
|
||||
<directory suffix=".test.php">tests/cases</directory>
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
class AuthTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* Test the Auth::user method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testUserMethodReturnsCurrentUser()
|
||||
{
|
||||
Auth::$user = 'Taylor';
|
||||
|
||||
$this->assertEquals('Taylor', Auth::user());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Auth::check method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testCheckMethodReturnsTrueWhenUserIsSet()
|
||||
{
|
||||
$this->assertTrue(AuthUserReturnsDummy::check());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Auth::check method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testCheckMethodReturnsFalseWhenNoUserIsSet()
|
||||
{
|
||||
$this->assertFalse(AuthUserReturnsNull::check());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Auth::guest method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testGuestReturnsTrueWhenNoUserIsSet()
|
||||
{
|
||||
$this->assertTrue(AuthUserReturnsNull::guest());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Auth::guest method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testGuestReturnsFalseWhenUserIsSet()
|
||||
{
|
||||
$this->assertFalse(AuthUserReturnsDummy::guest());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class AuthUserReturnsNull extends Laravel\Auth {
|
||||
|
||||
public static function user() {}
|
||||
|
||||
}
|
||||
|
||||
class AuthUserReturnsDummy extends Laravel\Auth {
|
||||
|
||||
public static function user() { return 'Taylor'; }
|
||||
|
||||
}
|
Loading…
Reference in New Issue