Browse Source

updated tests

v3-dev
REJack 6 years ago
parent
commit
5ea5fa5b69
No known key found for this signature in database
GPG Key ID: 4A44B48700429F46
  1. 5
      application/Libraries/Aauth.php
  2. 2
      tests/Aauth/Libraries/Aauth/InfosTest.php
  3. 12
      tests/Aauth/Libraries/Aauth/LoginTest.php
  4. 3
      tests/Aauth/Libraries/Aauth/UserTest.php

5
application/Libraries/Aauth.php

@ -732,7 +732,7 @@ class Aauth
// }
// }
if (! $user['banned'] && password_verify($password, $user['password']))
if (password_verify($password, $user['password']))
{
$data['id'] = $user['id'];
$data['username'] = $user['username'];
@ -943,7 +943,6 @@ class Aauth
{
$this->session->keepFlashdata('errors');
}
}
/**
@ -990,6 +989,7 @@ class Aauth
public function clearErrors()
{
$this->errors = [];
$this->flashErrors = [];
$this->session->remove('errors');
}
@ -1102,6 +1102,7 @@ class Aauth
public function clearInfos()
{
$this->infos = [];
$this->flashInfos = [];
$this->session->remove('infos');
}
}

2
tests/Aauth/Libraries/Aauth/InfosTest.php

@ -99,7 +99,7 @@ class InfosTest extends \CIUnitTestCase
$session->start();
$this->assertEquals(['test message 1'], $session->getFlashdata('infos'));
$this->library->clearInfos();
$session->start();
$this->library->info(['test message 1','test message 2'], true);
$session->start();
$this->assertEquals(['test message 1','test message 2'], $session->getFlashdata('infos'));

12
tests/Aauth/Libraries/Aauth/LoginTest.php

@ -99,20 +99,20 @@ class LoginTest extends CIDatabaseTestCase
$this->assertFalse($this->library->login('admina@example.com', 'password123456'));
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]);
$userVariableModel = new UserVariableModel();
$userVariableModel->save(1, 'verification_code', '12345678', true);
$this->library->clearErrors();
$this->assertFalse($this->library->login('admin@example.com', 'password123456'));
$this->assertEquals(lang('Aauth.notVerified'), $this->library->getErrorsArray()[0]);
$this->assertFalse($this->library->login('admin@example.com', 'password1234567'));
$this->assertEquals(lang('Aauth.loginFailedAll'), $this->library->getErrorsArray()[0]);
$this->library->banUser(1);
$this->library->clearErrors();
$this->assertFalse($this->library->login('admin@example.com', 'password123456'));
$this->assertEquals(lang('Aauth.invalidUserBanned'), $this->library->getErrorsArray()[0]);
$userVariableModel = new UserVariableModel();
$userVariableModel->save(1, 'verification_code', '12345678', true);
$this->library->clearErrors();
$this->assertFalse($this->library->login('admin@example.com', 'password1234567'));
$this->assertEquals(lang('Aauth.loginFailedAll'), $this->library->getErrorsArray()[0]);
$this->assertFalse($this->library->login('admin@example.com', 'password123456'));
$this->assertEquals(lang('Aauth.notVerified'), $this->library->getErrorsArray()[0]);
$this->library->login('admina@example.com', 'password123456');
$this->library->login('admina@example.com', 'password123456');

3
tests/Aauth/Libraries/Aauth/UserTest.php

@ -65,6 +65,9 @@ class UserTest extends CIDatabaseTestCase
public function testUpdateUser()
{
$session = $this->getInstance();
$this->library = new Aauth(NULL, $session);
$this->seeInDatabase($this->config->dbTableUsers, [
'id' => 2,
'email' => 'user@example.com',

Loading…
Cancel
Save