2 changed files with 119 additions and 101 deletions
@ -92,4 +92,31 @@ class UserModelTest extends CIDatabaseTestCase
|
||||
$newUser = $this->model->insert(['email' => '[email protected]', 'password' => 'password123456']); |
||||
$this->assertFalse($newUser); |
||||
} |
||||
|
||||
public function testUpdate() |
||||
{ |
||||
$this->assertFalse($this->model->update(2, ['id' => 2, 'email' => '[email protected]'])); |
||||
$this->assertEquals(lang('Aauth.existsAlreadyEmail'), $this->model->errors()); |
||||
|
||||
// $this->assertFalse($this->library->updateUser(2, '[email protected]', null, null)); |
||||
// $this->assertEquals(lang('Aauth.existsAlreadyEmail'), $this->library->getErrorsArray()[0]); |
||||
|
||||
// $this->assertFalse($this->library->updateUser(2, 'adminexample.com', null, null)); |
||||
// $this->assertEquals(lang('Aauth.invalidEmail'), $this->library->getErrorsArray()[0]); |
||||
|
||||
// $this->assertFalse($this->library->updateUser(2, null, 'pass', null)); |
||||
// $this->assertEquals(lang('Aauth.invalidPassword'), $this->library->getErrorsArray()[0]); |
||||
|
||||
// $this->assertFalse($this->library->updateUser(2, null, 'password12345678901011121314151617', null)); |
||||
// $this->assertEquals(lang('Aauth.invalidPassword'), $this->library->getErrorsArray()[0]); |
||||
|
||||
// $this->assertFalse($this->library->updateUser(2, null, null, 'admin')); |
||||
// $this->assertEquals(lang('Aauth.existsAlreadyUsername'), $this->library->getErrorsArray()[0]); |
||||
|
||||
// $this->assertFalse($this->library->updateUser(2, null, null, 'user+')); |
||||
// $this->assertEquals(lang('Aauth.invalidUsername'), $this->library->getErrorsArray()[0]); |
||||
|
||||
// $this->assertFalse($this->library->updateUser(2)); |
||||
// $this->assertCount(0, $this->library->getErrorsArray()); |
||||
} |
||||
} |
||||
|
@ -33,7 +33,6 @@ class UserTest extends CIDatabaseTestCase
|
||||
|
||||
public function tearDown() |
||||
{ |
||||
|
||||
} |
||||
|
||||
protected function getInstance($options = []) |
||||
@ -65,9 +64,7 @@ class UserTest extends CIDatabaseTestCase
|
||||
|
||||
public function testUpdateUser() |
||||
{ |
||||
$session = $this->getInstance(); |
||||
$this->library = new Aauth(NULL, $session); |
||||
|
||||
$this->library = new Aauth(null, true); |
||||
$this->seeInDatabase($this->config->dbTableUsers, [ |
||||
'id' => 2, |
||||
'email' => '[email protected]', |
||||
@ -81,35 +78,29 @@ class UserTest extends CIDatabaseTestCase
|
||||
]); |
||||
$this->assertEquals(lang('Aauth.infoUpdateSuccess'), $this->library->getInfosArray()[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]); |
||||
// moved to UserModelTest |
||||
// $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, 'adminexample.com', null, null)); |
||||
$this->assertEquals(lang('Aauth.invalidEmail'), $this->library->getErrorsArray()[0]); |
||||
// $this->assertFalse($this->library->updateUser(2, 'adminexample.com', null, null)); |
||||
// $this->assertEquals(lang('Aauth.invalidEmail'), $this->library->getErrorsArray()[0]); |
||||
|
||||
$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->assertFalse($this->library->updateUser(2, null, 'pass', null)); |
||||
// $this->assertEquals(lang('Aauth.invalidPassword'), $this->library->getErrorsArray()[0]); |
||||
|
||||
$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->assertFalse($this->library->updateUser(2, null, 'password12345678901011121314151617', null)); |
||||
// $this->assertEquals(lang('Aauth.invalidPassword'), $this->library->getErrorsArray()[0]); |
||||
|
||||
$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->assertFalse($this->library->updateUser(2, null, null, 'admin')); |
||||
// $this->assertEquals(lang('Aauth.existsAlreadyUsername'), $this->library->getErrorsArray()[0]); |
||||
|
||||
$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->assertFalse($this->library->updateUser(2, null, null, 'user+')); |
||||
// $this->assertEquals(lang('Aauth.invalidUsername'), $this->library->getErrorsArray()[0]); |
||||
|
||||
$this->library = new Aauth(NULL, $session); |
||||
$this->assertFalse($this->library->updateUser(2)); |
||||
$this->assertCount(0, $this->library->getErrorsArray()); |
||||
// $this->assertFalse($this->library->updateUser(2)); |
||||
// $this->assertCount(0, $this->library->getErrorsArray()); |
||||
|
||||
$this->library = new Aauth(NULL, $session); |
||||
$this->library = new Aauth(null, true); |
||||
$this->assertFalse($this->library->updateUser(99)); |
||||
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]); |
||||
} |
||||
@ -144,7 +135,7 @@ class UserTest extends CIDatabaseTestCase
|
||||
$this->assertEquals('[email protected]', $user['email']); |
||||
|
||||
$session = $this->getInstance(); |
||||
$this->library = new Aauth(NULL, $session); |
||||
$this->library = new Aauth(null, $session); |
||||
$session->set('user', [ |
||||
'id' => 1, |
||||
]); |
||||
@ -164,7 +155,7 @@ class UserTest extends CIDatabaseTestCase
|
||||
$this->assertEquals('1', $userIdEmail); |
||||
|
||||
$session = $this->getInstance(); |
||||
$this->library = new Aauth(NULL, $session); |
||||
$this->library = new Aauth(null, $session); |
||||
$session->set('user', [ |
||||
'id' => 1, |
||||
]); |
||||
@ -210,7 +201,7 @@ class UserTest extends CIDatabaseTestCase
|
||||
public function testBanUnbanUserSession() |
||||
{ |
||||
$session = $this->getInstance(); |
||||
$this->library = new Aauth(NULL, $session); |
||||
$this->library = new Aauth(null, $session); |
||||
$session->set('user', [ |
||||
'id' => 1, |
||||
]); |
||||
|
Loading…
Reference in new issue