|
|
|
@ -33,10 +33,9 @@ class UserTest extends CIDatabaseTestCase
|
|
|
|
|
|
|
|
|
|
public function tearDown() |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected function getInstance($options=[]) |
|
|
|
|
protected function getInstance($options = []) |
|
|
|
|
{ |
|
|
|
|
$defaults = [ |
|
|
|
|
'sessionDriver' => 'CodeIgniter\Session\Handlers\FileHandler', |
|
|
|
@ -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' => 'user@example.com', |
|
|
|
@ -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, 'admin@example.com', null, null)); |
|
|
|
|
$this->assertEquals(lang('Aauth.existsAlreadyEmail'), $this->library->getErrorsArray()[0]); |
|
|
|
|
// moved to UserModelTest |
|
|
|
|
// $this->assertFalse($this->library->updateUser(2, 'admin@example.com', 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('admin@example.com', $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, |
|
|
|
|
]); |
|
|
|
|