Browse Source

updated Libraries/Aauth, UserModelTest & UserTest

v3-dev
REJack 6 years ago
parent
commit
60b098a9a3
No known key found for this signature in database
GPG Key ID: 4A44B48700429F46
  1. 2
      application/Libraries/Aauth.php
  2. 6
      tests/Aauth/Database/UserModelTest.php
  3. 37
      tests/Aauth/Libraries/Aauth/UserTest.php

2
application/Libraries/Aauth.php

@ -208,7 +208,7 @@ class Aauth
return true; return true;
} }
$this->error($userModel->errors()); $this->error(array_values($userModel->errors()));
return false; return false;
} }

6
tests/Aauth/Database/UserModelTest.php

@ -95,9 +95,9 @@ class UserModelTest extends CIDatabaseTestCase
public function testUpdate() public function testUpdate()
{ {
$this->assertFalse($this->model->update(2, ['email' => 'admin@example.com'])); // $this->assertFalse($this->model->update(2, ['email' => 'admin@example.com']));
print_r($this->model->errors()); // print_r($this->model->errors());
$this->assertEquals(lang('Aauth.existsAlreadyEmail'), $this->model->errors()[0]); // $this->assertEquals(lang('Aauth.existsAlreadyEmail'), $this->model->errors()[0]);
// $this->assertFalse($this->model->update(2, ['email' => 'adminexample.com'])); // $this->assertFalse($this->model->update(2, ['email' => 'adminexample.com']));
// $this->assertEquals(lang('Aauth.invalidEmail'), $this->model->errors()[0]); // $this->assertEquals(lang('Aauth.invalidEmail'), $this->model->errors()[0]);

37
tests/Aauth/Libraries/Aauth/UserTest.php

@ -78,27 +78,34 @@ class UserTest extends CIDatabaseTestCase
]); ]);
$this->assertEquals(lang('Aauth.infoUpdateSuccess'), $this->library->getInfosArray()[0]); $this->assertEquals(lang('Aauth.infoUpdateSuccess'), $this->library->getInfosArray()[0]);
// moved to UserModelTest, not working here :/ $this->library = new Aauth(null, true);
// $this->assertFalse($this->library->updateUser(2, 'admin@example.com', null, null)); $this->assertFalse($this->library->updateUser(2, 'admin@example.com', null, null));
// $this->assertEquals(lang('Aauth.existsAlreadyEmail'), $this->library->getErrorsArray()[0]); print_r(getErrorsArray());
$this->assertEquals(lang('Aauth.existsAlreadyEmail'), $this->library->getErrorsArray()[0]);
// $this->assertFalse($this->library->updateUser(2, 'adminexample.com', null, null)); $this->library = new Aauth(null, true);
// $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->assertFalse($this->library->updateUser(2, null, 'pass', null)); $this->library = new Aauth(null, true);
// $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->assertFalse($this->library->updateUser(2, null, 'password12345678901011121314151617', null)); $this->library = new Aauth(null, true);
// $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->library = new Aauth(null, true);
// $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->assertFalse($this->library->updateUser(2, null, null, 'user+')); $this->library = new Aauth(null, true);
// $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->assertFalse($this->library->updateUser(2)); $this->library = new Aauth(null, true);
// $this->assertCount(0, $this->library->getErrorsArray()); $this->assertFalse($this->library->updateUser(2));
$this->assertCount(0, $this->library->getErrorsArray());
$this->library = new Aauth(null, true); $this->library = new Aauth(null, true);
$this->assertFalse($this->library->updateUser(99)); $this->assertFalse($this->library->updateUser(99));

Loading…
Cancel
Save