14 changed files with 353 additions and 357 deletions
@ -31,21 +31,21 @@ class UserModelTest extends CIDatabaseTestCase
|
||||
{ |
||||
$this->model->updateLastLogin(1); |
||||
$user = $this->model->asArray()->find(1); |
||||
$this->assertTrue((strtotime("-5 seconds") < strtotime($user['last_login']) && strtotime("+5 seconds") > strtotime($user['last_login'])) && strtotime("-5 seconds") < strtotime($user['last_activity']) && strtotime("+5 seconds") > strtotime($user['last_activity'])); |
||||
$this->assertTrue((strtotime('-5 seconds') < strtotime($user['last_login']) && strtotime('+5 seconds') > strtotime($user['last_login'])) && strtotime('-5 seconds') < strtotime($user['last_activity']) && strtotime('+5 seconds') > strtotime($user['last_activity'])); |
||||
} |
||||
|
||||
public function testUpdateLastActivity() |
||||
{ |
||||
$this->model->updateLastActivity(1); |
||||
$user = $this->model->asArray()->find(1); |
||||
$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 testUpdateBanned() |
||||
{ |
||||
$this->assertFalse($this->model->isBanned(1)); |
||||
|
||||
$this->model->updateBanned(1, TRUE); |
||||
$this->model->updateBanned(1, true); |
||||
$this->assertTrue($this->model->isBanned(1)); |
||||
} |
||||
|
||||
@ -58,16 +58,16 @@ class UserModelTest extends CIDatabaseTestCase
|
||||
|
||||
public function testExistsByEmail() |
||||
{ |
||||
$this->assertTrue($this->model->existsByEmail("[email protected]")); |
||||
$this->assertTrue($this->model->existsByEmail('[email protected]')); |
||||
|
||||
$this->assertFalse($this->model->existsByEmail("")); |
||||
$this->assertFalse($this->model->existsByEmail('')); |
||||
} |
||||
|
||||
public function testExistsByUsername() |
||||
{ |
||||
$this->assertTrue($this->model->existsByUsername("admin")); |
||||
$this->assertTrue($this->model->existsByUsername('admin')); |
||||
|
||||
$this->assertFalse($this->model->existsByUsername("")); |
||||
$this->assertFalse($this->model->existsByUsername('')); |
||||
} |
||||
|
||||
public function testHashPasswordFilled() |
||||
@ -75,7 +75,7 @@ class UserModelTest extends CIDatabaseTestCase
|
||||
$userOld = $this->model->asArray()->find(1); |
||||
$this->model->update(1, ['id' => 1, 'password' => 'password123456']); |
||||
$userNew = $this->model->asArray()->find(1); |
||||
$this->assertTrue($userOld['password'] != $userNew['password'] && $userNew['password'] != 'password123456'); |
||||
$this->assertTrue($userOld['password'] !== $userNew['password'] && $userNew['password'] !== 'password123456'); |
||||
|
||||
$userOld = $this->model->asArray()->find(1); |
||||
$this->model->update(1, ['id' => 1, 'username' => 'admin']); |
||||
|
@ -81,35 +81,35 @@ class UserTest extends CIDatabaseTestCase
|
||||
]); |
||||
$this->assertEquals(lang('Aauth.infoUpdateSuccess'), $this->library->getInfosArray()[0]); |
||||
|
||||
// $this->library->clearInfos(); |
||||
// $this->assertFalse($this->library->updateUser(2, '[email protected]', null, null)); |
||||
// $this->assertEquals(lang('Aauth.existsAlreadyEmail'), $this->library->getErrorsArray()[0]); |
||||
$this->library = new Aauth(NULL, $session); |
||||
$this->assertFalse($this->library->updateUser(2, '[email protected]', null, null)); |
||||
$this->assertEquals(lang('Aauth.existsAlreadyEmail'), $this->library->getErrorsArray()[0]); |
||||
|
||||
$this->library->clearErrors(); |
||||
$this->library = new Aauth(NULL, $session); |
||||
$this->assertFalse($this->library->updateUser(2, 'adminexample.com', null, null)); |
||||
$this->assertEquals(lang('Aauth.invalidEmail'), $this->library->getErrorsArray()[0]); |
||||
|
||||
$this->library->clearErrors(); |
||||
$this->library = new Aauth(NULL, $session); |
||||
$this->assertFalse($this->library->updateUser(2, null, 'pass', null)); |
||||
$this->assertEquals(lang('Aauth.invalidPassword'), $this->library->getErrorsArray()[0]); |
||||
|
||||
$this->library->clearErrors(); |
||||
$this->library = new Aauth(NULL, $session); |
||||
$this->assertFalse($this->library->updateUser(2, null, 'password12345678901011121314151617', null)); |
||||
$this->assertEquals(lang('Aauth.invalidPassword'), $this->library->getErrorsArray()[0]); |
||||
|
||||
$this->library->clearErrors(); |
||||
$this->library = new Aauth(NULL, $session); |
||||
$this->assertFalse($this->library->updateUser(2, null, null, 'admin')); |
||||
$this->assertEquals(lang('Aauth.existsAlreadyUsername'), $this->library->getErrorsArray()[0]); |
||||
|
||||
$this->library->clearErrors(); |
||||
$this->library = new Aauth(NULL, $session); |
||||
$this->assertFalse($this->library->updateUser(2, null, null, 'user+')); |
||||
$this->assertEquals(lang('Aauth.invalidUsername'), $this->library->getErrorsArray()[0]); |
||||
|
||||
$this->library->clearErrors(); |
||||
$this->library = new Aauth(NULL, $session); |
||||
$this->assertFalse($this->library->updateUser(2)); |
||||
$this->assertCount(0, $this->library->getErrorsArray()); |
||||
|
||||
$this->library->clearErrors(); |
||||
$this->library = new Aauth(NULL, $session); |
||||
$this->assertFalse($this->library->updateUser(99)); |
||||
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
||||
} |
||||
|
Loading…
Reference in new issue