12 changed files with 132 additions and 320 deletions
@ -40,45 +40,32 @@ class UserModelTest extends CIDatabaseTestCase |
|||||||
$this->assertTrue(strtotime("-5 seconds") < strtotime($user['last_activity']) && strtotime("+5 seconds") > strtotime($user['last_activity'])); |
$this->assertTrue(strtotime("-5 seconds") < strtotime($user['last_activity']) && strtotime("+5 seconds") > strtotime($user['last_activity'])); |
||||||
} |
} |
||||||
|
|
||||||
public function testUpdateBannedTrue() |
public function testUpdateBanned() |
||||||
{ |
{ |
||||||
|
$this->assertFalse($this->model->isBanned(1)); |
||||||
|
|
||||||
$this->model->updateBanned(1, TRUE); |
$this->model->updateBanned(1, TRUE); |
||||||
$this->assertTrue($this->model->isBanned(1)); |
$this->assertTrue($this->model->isBanned(1)); |
||||||
} |
} |
||||||
|
|
||||||
public function testUpdateBannedFalse() |
public function testExistsById() |
||||||
{ |
|
||||||
$this->model->updateBanned(1, FALSE); |
|
||||||
$this->assertFalse($this->model->isBanned(1)); |
|
||||||
} |
|
||||||
|
|
||||||
public function testExistsByIdTrue() |
|
||||||
{ |
{ |
||||||
$this->assertTrue($this->model->existsById(1)); |
$this->assertTrue($this->model->existsById(1)); |
||||||
} |
|
||||||
|
|
||||||
public function testExistsByIdFalse() |
|
||||||
{ |
|
||||||
$this->assertFalse($this->model->existsById(0)); |
$this->assertFalse($this->model->existsById(0)); |
||||||
} |
} |
||||||
|
|
||||||
public function testExistsByEmailTrue() |
public function testExistsByEmail() |
||||||
{ |
{ |
||||||
$this->assertTrue($this->model->existsByEmail("[email protected]")); |
$this->assertTrue($this->model->existsByEmail("[email protected]")); |
||||||
} |
|
||||||
|
|
||||||
public function testExistsByEmailFalse() |
|
||||||
{ |
|
||||||
$this->assertFalse($this->model->existsByEmail("")); |
$this->assertFalse($this->model->existsByEmail("")); |
||||||
} |
} |
||||||
|
|
||||||
public function testExistsByUsernameTrue() |
public function testExistsByUsername() |
||||||
{ |
{ |
||||||
$this->assertTrue($this->model->existsByUsername("admin")); |
$this->assertTrue($this->model->existsByUsername("admin")); |
||||||
} |
|
||||||
|
|
||||||
public function testExistsByUsernameFalse() |
|
||||||
{ |
|
||||||
$this->assertFalse($this->model->existsByUsername("")); |
$this->assertFalse($this->model->existsByUsername("")); |
||||||
} |
} |
||||||
|
|
||||||
@ -88,10 +75,7 @@ class UserModelTest extends CIDatabaseTestCase |
|||||||
$this->model->update(1, ['id' => 1, 'password' => 'password123456']); |
$this->model->update(1, ['id' => 1, 'password' => 'password123456']); |
||||||
$userNew = $this->model->asArray()->find(1); |
$userNew = $this->model->asArray()->find(1); |
||||||
$this->assertTrue($userOld['password'] != $userNew['password'] && $userNew['password'] != 'password123456'); |
$this->assertTrue($userOld['password'] != $userNew['password'] && $userNew['password'] != 'password123456'); |
||||||
} |
|
||||||
|
|
||||||
public function testHashPasswordNotSet() |
|
||||||
{ |
|
||||||
$userOld = $this->model->asArray()->find(1); |
$userOld = $this->model->asArray()->find(1); |
||||||
$this->model->update(1, ['id' => 1, 'username' => 'admin']); |
$this->model->update(1, ['id' => 1, 'username' => 'admin']); |
||||||
$userNew = $this->model->asArray()->find(1); |
$userNew = $this->model->asArray()->find(1); |
||||||
|
@ -25,25 +25,25 @@ class LoginTest extends CIDatabaseTestCase |
|||||||
|
|
||||||
protected $namespace = 'App'; |
protected $namespace = 'App'; |
||||||
|
|
||||||
public function setUp() |
public function setUp() |
||||||
{ |
{ |
||||||
parent::setUp(); |
parent::setUp(); |
||||||
|
|
||||||
Services::injectMock('response', new MockResponse(new App())); |
Services::injectMock('response', new MockResponse(new App())); |
||||||
$this->response = service('response'); |
$this->response = service('response'); |
||||||
$this->library = new Aauth(null, true); |
$this->library = new Aauth(null, true); |
||||||
$_COOKIE = []; |
$_COOKIE = []; |
||||||
$_SESSION = []; |
$_SESSION = []; |
||||||
} |
} |
||||||
|
|
||||||
public function tearDown() |
public function tearDown() |
||||||
{ |
{ |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
protected function getInstance($options=[]) |
protected function getInstance($options=[]) |
||||||
{ |
{ |
||||||
$defaults = [ |
$defaults = [ |
||||||
'sessionDriver' => 'CodeIgniter\Session\Handlers\FileHandler', |
'sessionDriver' => 'CodeIgniter\Session\Handlers\FileHandler', |
||||||
'sessionCookieName' => 'ci_session', |
'sessionCookieName' => 'ci_session', |
||||||
'sessionExpiration' => 7200, |
'sessionExpiration' => 7200, |
||||||
@ -55,145 +55,93 @@ class LoginTest extends CIDatabaseTestCase |
|||||||
'cookiePrefix' => '', |
'cookiePrefix' => '', |
||||||
'cookiePath' => '/', |
'cookiePath' => '/', |
||||||
'cookieSecure' => false, |
'cookieSecure' => false, |
||||||
]; |
]; |
||||||
|
|
||||||
$config = (object)$defaults; |
$config = (object)$defaults; |
||||||
|
|
||||||
$session = new MockSession(new FileHandler($config, Services::request()->getIPAddress()), $config); |
$session = new MockSession(new FileHandler($config, Services::request()->getIPAddress()), $config); |
||||||
$session->setLogger(new TestLogger(new Logger())); |
$session->setLogger(new TestLogger(new Logger())); |
||||||
$session->start(); |
$session->start(); |
||||||
|
|
||||||
return $session; |
return $session; |
||||||
} |
} |
||||||
|
|
||||||
//-------------------------------------------------------------------- |
//-------------------------------------------------------------------- |
||||||
|
|
||||||
public function testLoginEmailTrue() |
public function testLogin() |
||||||
{ |
{ |
||||||
$session = $this->getInstance(); |
$session = $this->getInstance(); |
||||||
$this->library = new Aauth(null, $session); |
$config = new AauthConfig(); |
||||||
$this->assertTrue($this->library->login('[email protected]', 'password123456')); |
$config->loginUseUsername = true; |
||||||
} |
|
||||||
|
$this->library = new Aauth($config, $session); |
||||||
public function testLoginFalseEmailFailedEmail() |
$this->assertTrue($this->library->login('admin', 'password123456')); |
||||||
{ |
|
||||||
$session = $this->getInstance(); |
$this->assertFalse($this->library->login('admin', 'passwor')); |
||||||
$this->library = new Aauth(null, $session); |
$this->assertEquals(lang('Aauth.loginFailedUsername'), $this->library->getErrorsArray()[0]); |
||||||
$this->assertFalse($this->library->login('adminaexample.com', 'password123456')); |
|
||||||
$this->assertEquals(lang('Aauth.loginFailedEmail'), $this->library->getErrorsArray()[0]); |
$this->library->clearErrors(); |
||||||
} |
$this->assertFalse($this->library->login('user99', 'password123456')); |
||||||
|
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
||||||
public function testLoginFalseEmailFailedPassword() |
// $config->loginUseUsername = false; |
||||||
{ |
|
||||||
$session = $this->getInstance(); |
$this->library = new Aauth(null, $session); |
||||||
$this->library = new Aauth(null, $session); |
$this->assertTrue($this->library->login('[email protected]', 'password123456')); |
||||||
$this->assertFalse($this->library->login('[email protected]', 'passwor')); |
|
||||||
$this->assertEquals(lang('Aauth.loginFailedEmail'), $this->library->getErrorsArray()[0]); |
$this->assertFalse($this->library->login('adminaexample.com', 'password123456')); |
||||||
} |
$this->assertEquals(lang('Aauth.loginFailedEmail'), $this->library->getErrorsArray()[0]); |
||||||
|
|
||||||
public function testLoginFalseEmailNotFound() |
$this->library->clearErrors(); |
||||||
{ |
$this->assertFalse($this->library->login('[email protected]', 'passwor')); |
||||||
$session = $this->getInstance(); |
$this->assertEquals(lang('Aauth.loginFailedEmail'), $this->library->getErrorsArray()[0]); |
||||||
$this->library = new Aauth(null, $session); |
|
||||||
$this->assertFalse($this->library->login('[email protected]', 'password123456')); |
$this->library->clearErrors(); |
||||||
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
$this->assertFalse($this->library->login('[email protected]', 'password123456')); |
||||||
} |
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
||||||
|
|
||||||
public function testLoginUsernameTrue() |
$userVariableModel = new UserVariableModel(); |
||||||
{ |
$userVariableModel->save(1, 'verification_code', '12345678', true); |
||||||
$session = $this->getInstance(); |
$this->assertFalse($this->library->login('[email protected]', 'password123456')); |
||||||
$config = new AauthConfig(); |
$this->assertEquals(lang('Aauth.notVerified'), $this->library->getErrorsArray()[0]); |
||||||
$config->loginUseUsername = true; |
|
||||||
$this->library = new Aauth($config, $session); |
$this->library->banUser(1); |
||||||
$this->assertTrue($this->library->login('admin', 'password123456')); |
$this->library->clearErrors(); |
||||||
} |
$this->assertFalse($this->library->login('[email protected]', 'password123456')); |
||||||
|
$this->assertEquals(lang('Aauth.invalidUserBanned'), $this->library->getErrorsArray()[0]); |
||||||
public function testLoginFalseUsernameFailedPassword() |
|
||||||
{ |
|
||||||
$session = $this->getInstance(); |
$this->library->clearErrors(); |
||||||
$config = new AauthConfig(); |
$this->assertFalse($this->library->login('[email protected]', 'password1234567')); |
||||||
$config->loginUseUsername = true; |
$this->assertEquals(lang('Aauth.loginFailedAll'), $this->library->getErrorsArray()[0]); |
||||||
$this->library = new Aauth($config, $session); |
|
||||||
$this->assertFalse($this->library->login('admin', 'passwor')); |
$this->library->login('[email protected]', 'password123456'); |
||||||
$this->assertEquals(lang('Aauth.loginFailedUsername'), $this->library->getErrorsArray()[0]); |
$this->library->login('[email protected]', 'password123456'); |
||||||
} |
$this->library->login('[email protected]', 'password123456'); |
||||||
|
$this->library->clearErrors(); |
||||||
public function testLoginFalseUsernameNotFound() |
$this->assertFalse($this->library->login('[email protected]', 'password123456')); |
||||||
{ |
$this->assertEquals(lang('Aauth.loginAttemptsExceeded'), $this->library->getErrorsArray()[0]); |
||||||
$session = $this->getInstance(); |
} |
||||||
$config = new AauthConfig(); |
|
||||||
$config->loginUseUsername = true; |
|
||||||
$this->library = new Aauth($config, $session); |
|
||||||
$this->assertFalse($this->library->login('user99', 'password123456')); |
|
||||||
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
|
||||||
$config->loginUseUsername = false; |
|
||||||
} |
|
||||||
|
|
||||||
public function testLoginFalseNotVerified() |
|
||||||
{ |
|
||||||
$session = $this->getInstance(); |
|
||||||
$this->library = new Aauth(null, $session); |
|
||||||
$userVariableModel = new UserVariableModel(); |
|
||||||
$userVariableModel->save(1, 'verification_code', '12345678', true); |
|
||||||
$this->assertFalse($this->library->login('[email protected]', 'password123456')); |
|
||||||
$this->assertEquals(lang('Aauth.notVerified'), $this->library->getErrorsArray()[0]); |
|
||||||
} |
|
||||||
|
|
||||||
public function testLoginFalseBanned() |
|
||||||
{ |
|
||||||
$session = $this->getInstance(); |
|
||||||
$this->library = new Aauth(null, $session); |
|
||||||
$this->library->banUser(1); |
|
||||||
$this->assertFalse($this->library->login('[email protected]', 'password123456')); |
|
||||||
$this->assertEquals(lang('Aauth.invalidUserBanned'), $this->library->getErrorsArray()[0]); |
|
||||||
} |
|
||||||
|
|
||||||
public function testLoginFalse() |
|
||||||
{ |
|
||||||
$session = $this->getInstance(); |
|
||||||
$this->library = new Aauth(null, $session); |
|
||||||
$this->assertFalse($this->library->login('[email protected]', 'password1234567')); |
|
||||||
$this->assertEquals(lang('Aauth.loginFailedAll'), $this->library->getErrorsArray()[0]); |
|
||||||
} |
|
||||||
|
|
||||||
public function testLoginFalseLoginAttemptsExceeded() |
|
||||||
{ |
|
||||||
$session = $this->getInstance(); |
|
||||||
$this->library = new Aauth(null, $session); |
|
||||||
$this->library->login('[email protected]', 'password123456'); |
|
||||||
$this->library->login('[email protected]', 'password123456'); |
|
||||||
$this->library->login('[email protected]', 'password123456'); |
|
||||||
$this->library->login('[email protected]', 'password123456'); |
|
||||||
$this->library->login('[email protected]', 'password123456'); |
|
||||||
$this->library->login('[email protected]', 'password123456'); |
|
||||||
$this->library->login('[email protected]', 'password123456'); |
|
||||||
$this->library->login('[email protected]', 'password123456'); |
|
||||||
$this->library->login('[email protected]', 'password123456'); |
|
||||||
$this->library->clearErrors(); |
|
||||||
$this->assertFalse($this->library->login('[email protected]', 'password123456')); |
|
||||||
$this->assertEquals(lang('Aauth.loginAttemptsExceeded'), $this->library->getErrorsArray()[0]); |
|
||||||
} |
|
||||||
|
|
||||||
public function testIsLoggedIn() |
public function testIsLoggedIn() |
||||||
{ |
{ |
||||||
$session = $this->getInstance(); |
$session = $this->getInstance(); |
||||||
$this->library = new Aauth(null, $session); |
$this->library = new Aauth(null, $session); |
||||||
$session->set('user', [ |
$session->set('user', [ |
||||||
'loggedIn' => true, |
'loggedIn' => true, |
||||||
]); |
]); |
||||||
$this->assertTrue($this->library->isLoggedIn()); |
$this->assertTrue($this->library->isLoggedIn()); |
||||||
} |
} |
||||||
|
|
||||||
public function testLogout() |
public function testLogout() |
||||||
{ |
{ |
||||||
$session = $this->getInstance(); |
$session = $this->getInstance(); |
||||||
$this->library = new Aauth(null, $session); |
$this->library = new Aauth(null, $session); |
||||||
$session->set('user', [ |
$session->set('user', [ |
||||||
'loggedIn' => true, |
'loggedIn' => true, |
||||||
]); |
]); |
||||||
$this->assertTrue($this->library->isLoggedIn()); |
$this->assertTrue($this->library->isLoggedIn()); |
||||||
$this->library->logout(); |
$this->library->logout(); |
||||||
$this->library = new Aauth(null, $session); |
$this->library = new Aauth(null, $session); |
||||||
$this->assertFalse($this->library->isLoggedIn()); |
$this->assertFalse($this->library->isLoggedIn()); |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -63,66 +63,50 @@ class UserTest extends CIDatabaseTestCase |
|||||||
|
|
||||||
//-------------------------------------------------------------------- |
//-------------------------------------------------------------------- |
||||||
|
|
||||||
public function testUpdateUserTrue() |
public function testUpdateUser() |
||||||
{ |
{ |
||||||
$this->seeInDatabase($this->config->dbTableUserVariables, [ |
$this->seeInDatabase($this->config->dbTableUserVariables, [ |
||||||
'user_id' => 2, |
'id' => 2, |
||||||
'email' => '[email protected]', |
'email' => '[email protected]', |
||||||
'username' => 'user', |
'username' => 'user', |
||||||
]); |
]); |
||||||
$this->library->updateUser(2, '[email protected]', 'password987654', 'user1'); |
$this->library->updateUser(2, '[email protected]', 'password987654', 'user1'); |
||||||
$this->seeInDatabase($this->config->dbTableUserVariables, [ |
$this->seeInDatabase($this->config->dbTableUserVariables, [ |
||||||
'user_id' => 2, |
'id' => 2, |
||||||
'email' => '[email protected]', |
'email' => '[email protected]', |
||||||
'username' => 'user1', |
'username' => 'user1', |
||||||
]); |
]); |
||||||
$this->assertEquals(lang('Aauth.infoUpdateSuccess'), $this->library->getInfosArray()[0]); |
$this->assertEquals(lang('Aauth.infoUpdateSuccess'), $this->library->getInfosArray()[0]); |
||||||
} |
|
||||||
|
|
||||||
public function testUpdateUserFalseEmailExists() |
$this->library->clearInfos(); |
||||||
{ |
|
||||||
$this->assertFalse($this->library->updateUser(2, '[email protected]', null, null)); |
$this->assertFalse($this->library->updateUser(2, '[email protected]', null, null)); |
||||||
$this->assertEquals(lang('Aauth.existsAlreadyEmail'), $this->library->getErrorsArray()[0]); |
$this->assertEquals(lang('Aauth.existsAlreadyEmail'), $this->library->getErrorsArray()[0]); |
||||||
} |
|
||||||
|
|
||||||
public function testUpdateUserFalseEmailInvalid() |
$this->library->clearErrors(); |
||||||
{ |
|
||||||
$this->assertFalse($this->library->updateUser(2, 'adminexample.com', null, null)); |
$this->assertFalse($this->library->updateUser(2, 'adminexample.com', null, null)); |
||||||
$this->assertEquals(lang('Aauth.invalidEmail'), $this->library->getErrorsArray()[0]); |
$this->assertEquals(lang('Aauth.invalidEmail'), $this->library->getErrorsArray()[0]); |
||||||
} |
|
||||||
|
|
||||||
public function testUpdateUserFalsePasswordMin() |
$this->library->clearErrors(); |
||||||
{ |
|
||||||
$this->assertFalse($this->library->updateUser(2, null, 'pass', null)); |
$this->assertFalse($this->library->updateUser(2, null, 'pass', null)); |
||||||
$this->assertEquals(lang('Aauth.invalidPassword'), $this->library->getErrorsArray()[0]); |
$this->assertEquals(lang('Aauth.invalidPassword'), $this->library->getErrorsArray()[0]); |
||||||
} |
|
||||||
|
|
||||||
public function testUpdateUserFalsePasswordMax() |
$this->library->clearErrors(); |
||||||
{ |
|
||||||
$this->assertFalse($this->library->updateUser(2, null, 'password12345678901011121314151617', null)); |
$this->assertFalse($this->library->updateUser(2, null, 'password12345678901011121314151617', null)); |
||||||
$this->assertEquals(lang('Aauth.invalidPassword'), $this->library->getErrorsArray()[0]); |
$this->assertEquals(lang('Aauth.invalidPassword'), $this->library->getErrorsArray()[0]); |
||||||
} |
|
||||||
|
|
||||||
public function testUpdateUserFalseUsernameExists() |
$this->library->clearErrors(); |
||||||
{ |
|
||||||
$this->assertFalse($this->library->updateUser(2, null, null, 'admin')); |
$this->assertFalse($this->library->updateUser(2, null, null, 'admin')); |
||||||
$this->assertEquals(lang('Aauth.existsAlreadyUsername'), $this->library->getErrorsArray()[0]); |
$this->assertEquals(lang('Aauth.existsAlreadyUsername'), $this->library->getErrorsArray()[0]); |
||||||
} |
|
||||||
|
|
||||||
public function testUpdateUserFalseUsernameInvalid() |
$this->library->clearErrors(); |
||||||
{ |
|
||||||
$this->assertFalse($this->library->updateUser(2, null, null, 'user+')); |
$this->assertFalse($this->library->updateUser(2, null, null, 'user+')); |
||||||
$this->assertEquals(lang('Aauth.invalidUsername'), $this->library->getErrorsArray()[0]); |
$this->assertEquals(lang('Aauth.invalidUsername'), $this->library->getErrorsArray()[0]); |
||||||
} |
|
||||||
|
|
||||||
public function testUpdateUserFalseEmpty() |
$this->library->clearErrors(); |
||||||
{ |
|
||||||
$this->assertFalse($this->library->updateUser(2)); |
$this->assertFalse($this->library->updateUser(2)); |
||||||
$this->assertCount(0, $this->library->getErrorsArray()); |
$this->assertCount(0, $this->library->getErrorsArray()); |
||||||
} |
|
||||||
|
|
||||||
public function testUpdateUserFalseUserNotFound() |
$this->library->clearErrors(); |
||||||
{ |
|
||||||
$this->assertFalse($this->library->updateUser(99)); |
$this->assertFalse($this->library->updateUser(99)); |
||||||
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
||||||
} |
} |
||||||
@ -132,10 +116,7 @@ class UserTest extends CIDatabaseTestCase |
|||||||
$this->seeNumRecords(2, $this->config->dbTableUsers); |
$this->seeNumRecords(2, $this->config->dbTableUsers); |
||||||
$this->library->deleteUser(2); |
$this->library->deleteUser(2); |
||||||
$this->seeNumRecords(1, $this->config->dbTableUsers); |
$this->seeNumRecords(1, $this->config->dbTableUsers); |
||||||
} |
|
||||||
|
|
||||||
public function testDeleteUserFalseUserNotFound() |
|
||||||
{ |
|
||||||
$this->assertFalse($this->library->deleteUser(99)); |
$this->assertFalse($this->library->deleteUser(99)); |
||||||
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
||||||
} |
} |
||||||
@ -146,25 +127,19 @@ class UserTest extends CIDatabaseTestCase |
|||||||
$this->assertCount(2, $users); |
$this->assertCount(2, $users); |
||||||
$this->assertEquals('admin', $users[0]['username']); |
$this->assertEquals('admin', $users[0]['username']); |
||||||
$this->assertEquals('user', $users[1]['username']); |
$this->assertEquals('user', $users[1]['username']); |
||||||
} |
|
||||||
|
|
||||||
public function testListUsersOrderBy() |
|
||||||
{ |
|
||||||
$usersOrderBy = $this->library->listUsers(0, 0, null, 'id DESC'); |
$usersOrderBy = $this->library->listUsers(0, 0, null, 'id DESC'); |
||||||
$this->assertEquals('user', $usersOrderBy[0]['username']); |
$this->assertEquals('user', $usersOrderBy[0]['username']); |
||||||
$this->assertEquals('admin', $usersOrderBy[1]['username']); |
$this->assertEquals('admin', $usersOrderBy[1]['username']); |
||||||
} |
} |
||||||
|
|
||||||
public function testGetUserByUserId() |
public function testGetUser() |
||||||
{ |
{ |
||||||
$user = $this->library->getUser(1); |
$user = $this->library->getUser(1); |
||||||
$this->assertEquals('1', $user['id']); |
$this->assertEquals('1', $user['id']); |
||||||
$this->assertEquals('admin', $user['username']); |
$this->assertEquals('admin', $user['username']); |
||||||
$this->assertEquals('[email protected]', $user['email']); |
$this->assertEquals('[email protected]', $user['email']); |
||||||
} |
|
||||||
|
|
||||||
public function testGetUserBySession() |
|
||||||
{ |
|
||||||
$session = $this->getInstance(); |
$session = $this->getInstance(); |
||||||
$this->library = new Aauth(NULL, $session); |
$this->library = new Aauth(NULL, $session); |
||||||
$session->set('user', [ |
$session->set('user', [ |
||||||
@ -172,28 +147,19 @@ class UserTest extends CIDatabaseTestCase |
|||||||
]); |
]); |
||||||
$userIdNone = $this->library->getUser(); |
$userIdNone = $this->library->getUser(); |
||||||
$this->assertEquals('admin', $userIdNone['username']); |
$this->assertEquals('admin', $userIdNone['username']); |
||||||
} |
|
||||||
|
|
||||||
public function testGetUserWithVariables() |
|
||||||
{ |
|
||||||
$userVar = $this->library->getUser(1, true); |
$userVar = $this->library->getUser(1, true); |
||||||
$this->assertInternalType('array', $userVar['variables']); |
$this->assertInternalType('array', $userVar['variables']); |
||||||
} |
|
||||||
|
|
||||||
public function testGetUserFalseUserNotFound() |
|
||||||
{ |
|
||||||
$this->assertFalse($this->library->getUser(99)); |
$this->assertFalse($this->library->getUser(99)); |
||||||
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
||||||
} |
} |
||||||
|
|
||||||
public function testGetUserIdByEmail() |
public function testGetUserId() |
||||||
{ |
{ |
||||||
$userIdEmail = $this->library->getUserId('[email protected]'); |
$userIdEmail = $this->library->getUserId('[email protected]'); |
||||||
$this->assertEquals('1', $userIdEmail); |
$this->assertEquals('1', $userIdEmail); |
||||||
} |
|
||||||
|
|
||||||
public function testGetUserIdBySession() |
|
||||||
{ |
|
||||||
$session = $this->getInstance(); |
$session = $this->getInstance(); |
||||||
$this->library = new Aauth(NULL, $session); |
$this->library = new Aauth(NULL, $session); |
||||||
$session->set('user', [ |
$session->set('user', [ |
||||||
@ -201,10 +167,7 @@ class UserTest extends CIDatabaseTestCase |
|||||||
]); |
]); |
||||||
$userIdNone = $this->library->getUserId(); |
$userIdNone = $this->library->getUserId(); |
||||||
$this->assertEquals('1', $userIdNone); |
$this->assertEquals('1', $userIdNone); |
||||||
} |
|
||||||
|
|
||||||
public function testGetUserIdFalseUserNotFound() |
|
||||||
{ |
|
||||||
$this->assertFalse($this->library->getUserId('[email protected]')); |
$this->assertFalse($this->library->getUserId('[email protected]')); |
||||||
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
||||||
} |
} |
||||||
@ -220,9 +183,7 @@ class UserTest extends CIDatabaseTestCase |
|||||||
'id' => 1, |
'id' => 1, |
||||||
'banned' => 1, |
'banned' => 1, |
||||||
]); |
]); |
||||||
} |
|
||||||
public function testBanUserFalseUserNotFound() |
|
||||||
{ |
|
||||||
$this->assertFalse($this->library->banUser(99)); |
$this->assertFalse($this->library->banUser(99)); |
||||||
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
||||||
} |
} |
||||||
@ -239,9 +200,7 @@ class UserTest extends CIDatabaseTestCase |
|||||||
'id' => 1, |
'id' => 1, |
||||||
'banned' => 0, |
'banned' => 0, |
||||||
]); |
]); |
||||||
} |
|
||||||
public function testUnbanUserFalseUserNotFound() |
|
||||||
{ |
|
||||||
$this->assertFalse($this->library->unbanUser(99)); |
$this->assertFalse($this->library->unbanUser(99)); |
||||||
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
||||||
} |
} |
||||||
@ -265,20 +224,13 @@ class UserTest extends CIDatabaseTestCase |
|||||||
]); |
]); |
||||||
} |
} |
||||||
|
|
||||||
public function testIsBannedTrue() |
public function testIsBanned() |
||||||
{ |
{ |
||||||
$this->library->banUser(1); |
$this->library->banUser(1); |
||||||
$this->assertTrue($this->library->isBanned(1)); |
$this->assertTrue($this->library->isBanned(1)); |
||||||
} |
|
||||||
|
|
||||||
public function testIsBannedFalse() |
|
||||||
{ |
|
||||||
$this->assertFalse($this->library->isBanned(1)); |
$this->assertFalse($this->library->isBanned(1)); |
||||||
} |
|
||||||
|
|
||||||
public function testIsBannedFalseUserNotFound() |
$this->assertTrue($this->library->isBanned(99)); |
||||||
{ |
|
||||||
$this->assertFalse($this->library->isBanned(99)); |
|
||||||
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
|
||||||
} |
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue