Browse Source

updated tests

v3-dev
REJack 6 years ago
parent
commit
06f2d67633
No known key found for this signature in database
GPG Key ID: 4A44B48700429F46
  1. 2
      tests/Aauth/Database/GroupModelTest.php
  2. 48
      tests/Aauth/Database/GroupToGroupModelTest.php
  3. 48
      tests/Aauth/Database/GroupToUserModelTest.php
  4. 2
      tests/Aauth/Database/LoginAttemptModelTest.php
  5. 6
      tests/Aauth/Database/LoginTokenModelTest.php
  6. 2
      tests/Aauth/Database/PermModelTest.php
  7. 48
      tests/Aauth/Database/PermToGroupModelTest.php
  8. 48
      tests/Aauth/Database/PermToUserModelTest.php
  9. 22
      tests/Aauth/Database/UserModelTest.php
  10. 60
      tests/Aauth/Database/UserVariableModelTest.php
  11. 106
      tests/Aauth/Libraries/Aauth/ErrorsTest.php
  12. 105
      tests/Aauth/Libraries/Aauth/InfosTest.php
  13. 41
      tests/Aauth/Libraries/Aauth/LoginTest.php
  14. 172
      tests/Aauth/Libraries/Aauth/UserTest.php

2
tests/Aauth/Database/GroupModelTest.php

@ -13,7 +13,7 @@ class GroupModelTest extends CIDatabaseTestCase
public function setUp()
{
parent::setUp();
parent::setUp();
$this->model = new GroupModel($this->db);
}

48
tests/Aauth/Database/GroupToGroupModelTest.php

@ -14,9 +14,9 @@ class GroupToGroupModelTest extends CIDatabaseTestCase
public function setUp()
{
parent::setUp();
parent::setUp();
$this->model = new GroupToGroupModel($this->db);
$this->model = new GroupToGroupModel($this->db);
$this->config = new AauthConfig();
}
@ -26,8 +26,8 @@ class GroupToGroupModelTest extends CIDatabaseTestCase
{
$groupToGroup = $this->model->insert(99, 99);
$this->seeInDatabase($this->config->dbTableGroupToGroup, [
'group_id' => 99,
'subgroup_id' => 99,
'group_id' => 99,
'subgroup_id' => 99,
]);
}
@ -37,8 +37,8 @@ class GroupToGroupModelTest extends CIDatabaseTestCase
$this->assertFalse($groupToGroup);
$this->hasInDatabase($this->config->dbTableGroupToGroup, [
'group_id' => 99,
'subgroup_id' => 99,
'group_id' => 99,
'subgroup_id' => 99,
]);
$groupToGroup = $this->model->exists(99, 99);
$this->assertTrue($groupToGroup);
@ -49,8 +49,8 @@ class GroupToGroupModelTest extends CIDatabaseTestCase
$groupsToGroup = $this->model->findAllBySubgroupId(99);
$this->assertCount(0, $groupsToGroup);
$this->hasInDatabase($this->config->dbTableGroupToGroup, [
'group_id' => 99,
'subgroup_id' => 99,
'group_id' => 99,
'subgroup_id' => 99,
]);
$groupsToGroup = $this->model->findAllBySubgroupId(99);
$this->assertCount(1, $groupsToGroup);
@ -61,8 +61,8 @@ class GroupToGroupModelTest extends CIDatabaseTestCase
$groupToGroups = $this->model->findAllByGroupId(99);
$this->assertCount(0, $groupToGroups);
$this->hasInDatabase($this->config->dbTableGroupToGroup, [
'group_id' => 99,
'subgroup_id' => 99,
'group_id' => 99,
'subgroup_id' => 99,
]);
$groupToGroups = $this->model->findAllByGroupId(99);
$this->assertCount(1, $groupToGroups);
@ -71,12 +71,12 @@ class GroupToGroupModelTest extends CIDatabaseTestCase
public function testDelete()
{
$this->hasInDatabase($this->config->dbTableGroupToGroup, [
'group_id' => 99,
'subgroup_id' => 99,
'group_id' => 99,
'subgroup_id' => 99,
]);
$criteria = [
'group_id' => 99,
'subgroup_id' => 99,
'group_id' => 99,
'subgroup_id' => 99,
];
$this->seeNumRecords(1, $this->config->dbTableGroupToGroup, $criteria);
$this->model->delete(99, 99);
@ -86,11 +86,11 @@ class GroupToGroupModelTest extends CIDatabaseTestCase
public function testDeleteAllByGroupId()
{
$this->hasInDatabase($this->config->dbTableGroupToGroup, [
'group_id' => 99,
'subgroup_id' => 99,
'group_id' => 99,
'subgroup_id' => 99,
]);
$criteria = [
'group_id' => 99
'group_id' => 99,
];
$this->seeNumRecords(1, $this->config->dbTableGroupToGroup, $criteria);
$this->model->deleteAllByGroupId(99);
@ -100,11 +100,11 @@ class GroupToGroupModelTest extends CIDatabaseTestCase
public function testDeleteAllBySubgroupId()
{
$this->hasInDatabase($this->config->dbTableGroupToGroup, [
'group_id' => 99,
'subgroup_id' => 99,
'group_id' => 99,
'subgroup_id' => 99,
]);
$criteria = [
'subgroup_id' => 99
'subgroup_id' => 99,
];
$this->seeNumRecords(1, $this->config->dbTableGroupToGroup, $criteria);
$this->model->deleteAllBySubgroupId(99);
@ -115,12 +115,12 @@ class GroupToGroupModelTest extends CIDatabaseTestCase
{
$this->model = new GroupToGroupModel();
$this->hasInDatabase($this->config->dbTableGroupToGroup, [
'group_id' => 99,
'subgroup_id' => 99,
'group_id' => 99,
'subgroup_id' => 99,
]);
$this->hasInDatabase($this->config->dbTableGroupToGroup, [
'group_id' => 98,
'subgroup_id' => 99,
'group_id' => 98,
'subgroup_id' => 99,
]);
$groupsToGroup = $this->model->findAllBySubgroupId(99);
$this->assertCount(2, $groupsToGroup);

48
tests/Aauth/Database/GroupToUserModelTest.php

@ -14,9 +14,9 @@ class GroupToUserModelTest extends CIDatabaseTestCase
public function setUp()
{
parent::setUp();
parent::setUp();
$this->model = new GroupToUserModel($this->db);
$this->model = new GroupToUserModel($this->db);
$this->config = new AauthConfig();
}
@ -26,8 +26,8 @@ class GroupToUserModelTest extends CIDatabaseTestCase
{
$groupToGroup = $this->model->insert(99, 99);
$this->seeInDatabase($this->config->dbTableGroupToUser, [
'group_id' => 99,
'user_id' => 99,
'group_id' => 99,
'user_id' => 99,
]);
}
@ -37,8 +37,8 @@ class GroupToUserModelTest extends CIDatabaseTestCase
$this->assertFalse($groupToUser);
$this->hasInDatabase($this->config->dbTableGroupToUser, [
'group_id' => 99,
'user_id' => 99,
'group_id' => 99,
'user_id' => 99,
]);
$groupToUser = $this->model->exists(99, 99);
$this->assertTrue($groupToUser);
@ -49,8 +49,8 @@ class GroupToUserModelTest extends CIDatabaseTestCase
$groupToUsers = $this->model->findAllByUserId(99);
$this->assertCount(0, $groupToUsers);
$this->hasInDatabase($this->config->dbTableGroupToUser, [
'group_id' => 99,
'user_id' => 99,
'group_id' => 99,
'user_id' => 99,
]);
$groupToUsers = $this->model->findAllByUserId(99);
$this->assertCount(1, $groupToUsers);
@ -61,8 +61,8 @@ class GroupToUserModelTest extends CIDatabaseTestCase
$groupToUsers = $this->model->findAllByGroupId(99);
$this->assertCount(0, $groupToUsers);
$this->hasInDatabase($this->config->dbTableGroupToUser, [
'group_id' => 99,
'user_id' => 99,
'group_id' => 99,
'user_id' => 99,
]);
$groupToUsers = $this->model->findAllByGroupId(99);
$this->assertCount(1, $groupToUsers);
@ -71,12 +71,12 @@ class GroupToUserModelTest extends CIDatabaseTestCase
public function testDelete()
{
$this->hasInDatabase($this->config->dbTableGroupToUser, [
'group_id' => 99,
'user_id' => 99,
'group_id' => 99,
'user_id' => 99,
]);
$criteria = [
'group_id' => 99,
'user_id' => 99,
'group_id' => 99,
'user_id' => 99,
];
$this->seeNumRecords(1, $this->config->dbTableGroupToUser, $criteria);
$this->model->delete(99, 99);
@ -86,11 +86,11 @@ class GroupToUserModelTest extends CIDatabaseTestCase
public function testDeleteAllByGroupId()
{
$this->hasInDatabase($this->config->dbTableGroupToUser, [
'group_id' => 99,
'user_id' => 99,
'group_id' => 99,
'user_id' => 99,
]);
$criteria = [
'group_id' => 99
'group_id' => 99,
];
$this->seeNumRecords(1, $this->config->dbTableGroupToUser, $criteria);
$this->model->deleteAllByGroupId(99);
@ -100,11 +100,11 @@ class GroupToUserModelTest extends CIDatabaseTestCase
public function testDeleteAllByUserId()
{
$this->hasInDatabase($this->config->dbTableGroupToUser, [
'group_id' => 99,
'user_id' => 99,
'group_id' => 99,
'user_id' => 99,
]);
$criteria = [
'user_id' => 99
'user_id' => 99,
];
$this->seeNumRecords(1, $this->config->dbTableGroupToUser, $criteria);
$this->model->deleteAllByUserId(99);
@ -115,12 +115,12 @@ class GroupToUserModelTest extends CIDatabaseTestCase
{
$this->model = new GroupToUserModel();
$this->hasInDatabase($this->config->dbTableGroupToUser, [
'group_id' => 99,
'user_id' => 99,
'group_id' => 99,
'user_id' => 99,
]);
$this->hasInDatabase($this->config->dbTableGroupToUser, [
'group_id' => 98,
'user_id' => 99,
'group_id' => 98,
'user_id' => 99,
]);
$groupToUsers = $this->model->findAllByUserId(99);
$this->assertCount(2, $groupToUsers);

2
tests/Aauth/Database/LoginAttemptModelTest.php

@ -13,7 +13,7 @@ class LoginAttemptModelTest extends CIDatabaseTestCase
public function setUp()
{
parent::setUp();
parent::setUp();
$this->model = new LoginAttemptModel($this->db);
}

6
tests/Aauth/Database/LoginTokenModelTest.php

@ -13,7 +13,7 @@ class LoginTokenModelTest extends CIDatabaseTestCase
public function setUp()
{
parent::setUp();
parent::setUp();
$this->model = new LoginTokenModel($this->db);
}
@ -31,11 +31,11 @@ class LoginTokenModelTest extends CIDatabaseTestCase
{
$this->model->insert(['user_id' => 99, 'random_hash' => 'random_hash9999']);
$oldLoginTokens = $this->model->findAllByUserId(99);
$oldLoginToken = $oldLoginTokens[0];
$oldLoginToken = $oldLoginTokens[0];
sleep(5);
$this->model->update($oldLoginToken['id']);
$loginTokens = $this->model->findAllByUserId(99);
$loginToken = $loginTokens[0];
$loginToken = $loginTokens[0];
$this->assertNotEquals($oldLoginToken['expires_at'], $loginToken['expires_at']);
}

2
tests/Aauth/Database/PermModelTest.php

@ -13,7 +13,7 @@ class PermModelTest extends CIDatabaseTestCase
public function setUp()
{
parent::setUp();
parent::setUp();
$this->model = new PermModel($this->db);
}

48
tests/Aauth/Database/PermToGroupModelTest.php

@ -14,9 +14,9 @@ class PermToGroupModelTest extends CIDatabaseTestCase
public function setUp()
{
parent::setUp();
parent::setUp();
$this->model = new PermToGroupModel($this->db);
$this->model = new PermToGroupModel($this->db);
$this->config = new AauthConfig();
}
@ -25,8 +25,8 @@ class PermToGroupModelTest extends CIDatabaseTestCase
{
$permToGroup = $this->model->insert(99, 99);
$this->seeInDatabase($this->config->dbTablePermToGroup, [
'perm_id' => 99,
'group_id' => 99,
'perm_id' => 99,
'group_id' => 99,
]);
}
@ -36,8 +36,8 @@ class PermToGroupModelTest extends CIDatabaseTestCase
$this->assertFalse($permToGroup);
$this->hasInDatabase($this->config->dbTablePermToGroup, [
'perm_id' => 99,
'group_id' => 99,
'perm_id' => 99,
'group_id' => 99,
]);
$permToGroup = $this->model->exists(99, 99);
$this->assertTrue($permToGroup);
@ -48,8 +48,8 @@ class PermToGroupModelTest extends CIDatabaseTestCase
$permsToGroup = $this->model->findAllByGroupId(99);
$this->assertCount(0, $permsToGroup);
$this->hasInDatabase($this->config->dbTablePermToGroup, [
'perm_id' => 99,
'group_id' => 99,
'perm_id' => 99,
'group_id' => 99,
]);
$permsToGroup = $this->model->findAllByGroupId(99);
$this->assertCount(1, $permsToGroup);
@ -60,8 +60,8 @@ class PermToGroupModelTest extends CIDatabaseTestCase
$permToGroups = $this->model->findAllByPermId(99);
$this->assertCount(0, $permToGroups);
$this->hasInDatabase($this->config->dbTablePermToGroup, [
'perm_id' => 99,
'group_id' => 99,
'perm_id' => 99,
'group_id' => 99,
]);
$permToGroups = $this->model->findAllByPermId(99);
$this->assertCount(1, $permToGroups);
@ -70,12 +70,12 @@ class PermToGroupModelTest extends CIDatabaseTestCase
public function testDelete()
{
$this->hasInDatabase($this->config->dbTablePermToGroup, [
'perm_id' => 99,
'group_id' => 99,
'perm_id' => 99,
'group_id' => 99,
]);
$criteria = [
'perm_id' => 99,
'group_id' => 99,
'perm_id' => 99,
'group_id' => 99,
];
$this->seeNumRecords(1, $this->config->dbTablePermToGroup, $criteria);
$this->model->delete(99, 99);
@ -85,11 +85,11 @@ class PermToGroupModelTest extends CIDatabaseTestCase
public function testDeleteAllByPermId()
{
$this->hasInDatabase($this->config->dbTablePermToGroup, [
'perm_id' => 99,
'group_id' => 99,
'perm_id' => 99,
'group_id' => 99,
]);
$criteria = [
'perm_id' => 99,
'perm_id' => 99,
];
$this->seeNumRecords(1, $this->config->dbTablePermToGroup, $criteria);
$this->model->deleteAllByPermId(99);
@ -99,11 +99,11 @@ class PermToGroupModelTest extends CIDatabaseTestCase
public function testDeleteAllByGroupId()
{
$this->hasInDatabase($this->config->dbTablePermToGroup, [
'perm_id' => 99,
'group_id' => 99,
'perm_id' => 99,
'group_id' => 99,
]);
$criteria = [
'group_id' => 99,
'group_id' => 99,
];
$this->seeNumRecords(1, $this->config->dbTablePermToGroup, $criteria);
$this->model->deleteAllByGroupId(99);
@ -114,12 +114,12 @@ class PermToGroupModelTest extends CIDatabaseTestCase
{
$this->model = new PermToGroupModel();
$this->hasInDatabase($this->config->dbTablePermToGroup, [
'perm_id' => 99,
'group_id' => 99,
'perm_id' => 99,
'group_id' => 99,
]);
$this->hasInDatabase($this->config->dbTablePermToGroup, [
'perm_id' => 98,
'group_id' => 99,
'perm_id' => 98,
'group_id' => 99,
]);
$permsToGroup = $this->model->findAllByGroupId(99);
$this->assertCount(2, $permsToGroup);

48
tests/Aauth/Database/PermToUserModelTest.php

@ -14,9 +14,9 @@ class PermToUserModelTest extends CIDatabaseTestCase
public function setUp()
{
parent::setUp();
parent::setUp();
$this->model = new PermToUserModel($this->db);
$this->model = new PermToUserModel($this->db);
$this->config = new AauthConfig();
}
@ -25,8 +25,8 @@ class PermToUserModelTest extends CIDatabaseTestCase
{
$permToUser = $this->model->insert(99, 99);
$this->seeInDatabase($this->config->dbTablePermToUser, [
'perm_id' => 99,
'user_id' => 99,
'perm_id' => 99,
'user_id' => 99,
]);
}
@ -36,8 +36,8 @@ class PermToUserModelTest extends CIDatabaseTestCase
$this->assertFalse($permToUser);
$this->hasInDatabase($this->config->dbTablePermToUser, [
'perm_id' => 99,
'user_id' => 99,
'perm_id' => 99,
'user_id' => 99,
]);
$permToUser = $this->model->exists(99, 99);
$this->assertTrue($permToUser);
@ -48,8 +48,8 @@ class PermToUserModelTest extends CIDatabaseTestCase
$permsToUser = $this->model->findAllByUserId(99);
$this->assertCount(0, $permsToUser);
$this->hasInDatabase($this->config->dbTablePermToUser, [
'perm_id' => 99,
'user_id' => 99,
'perm_id' => 99,
'user_id' => 99,
]);
$permsToUser = $this->model->findAllByUserId(99);
$this->assertCount(1, $permsToUser);
@ -60,8 +60,8 @@ class PermToUserModelTest extends CIDatabaseTestCase
$permToUsers = $this->model->findAllByPermId(99);
$this->assertCount(0, $permToUsers);
$this->hasInDatabase($this->config->dbTablePermToUser, [
'perm_id' => 99,
'user_id' => 99,
'perm_id' => 99,
'user_id' => 99,
]);
$permToUsers = $this->model->findAllByPermId(99);
$this->assertCount(1, $permToUsers);
@ -70,12 +70,12 @@ class PermToUserModelTest extends CIDatabaseTestCase
public function testDelete()
{
$this->hasInDatabase($this->config->dbTablePermToUser, [
'perm_id' => 99,
'user_id' => 99,
'perm_id' => 99,
'user_id' => 99,
]);
$criteria = [
'perm_id' => 99,
'user_id' => 99,
'perm_id' => 99,
'user_id' => 99,
];
$this->seeNumRecords(1, $this->config->dbTablePermToUser, $criteria);
$this->model->delete(99, 99);
@ -85,11 +85,11 @@ class PermToUserModelTest extends CIDatabaseTestCase
public function testDeleteAllByPermId()
{
$this->hasInDatabase($this->config->dbTablePermToUser, [
'perm_id' => 99,
'user_id' => 99,
'perm_id' => 99,
'user_id' => 99,
]);
$criteria = [
'perm_id' => 99,
'perm_id' => 99,
];
$this->seeNumRecords(1, $this->config->dbTablePermToUser, $criteria);
$this->model->deleteAllByPermId(99);
@ -99,11 +99,11 @@ class PermToUserModelTest extends CIDatabaseTestCase
public function testDeleteAllByUserId()
{
$this->hasInDatabase($this->config->dbTablePermToUser, [
'perm_id' => 99,
'user_id' => 99,
'perm_id' => 99,
'user_id' => 99,
]);
$criteria = [
'user_id' => 99,
'user_id' => 99,
];
$this->seeNumRecords(1, $this->config->dbTablePermToUser, $criteria);
$this->model->deleteAllByUserId(99);
@ -114,12 +114,12 @@ class PermToUserModelTest extends CIDatabaseTestCase
{
$this->model = new PermToUserModel();
$this->hasInDatabase($this->config->dbTablePermToUser, [
'perm_id' => 99,
'user_id' => 99,
'perm_id' => 99,
'user_id' => 99,
]);
$this->hasInDatabase($this->config->dbTablePermToUser, [
'perm_id' => 98,
'user_id' => 99,
'perm_id' => 98,
'user_id' => 99,
]);
$permsToUser = $this->model->findAllByUserId(99);
$this->assertCount(2, $permsToUser);

22
tests/Aauth/Database/UserModelTest.php

@ -14,7 +14,7 @@ class UserModelTest extends CIDatabaseTestCase
public function setUp()
{
parent::setUp();
parent::setUp();
$this->model = new UserModel($this->db);
}
@ -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("admin@example.com"));
$this->assertTrue($this->model->existsByEmail('admin@example.com'));
$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']);
@ -85,11 +85,11 @@ class UserModelTest extends CIDatabaseTestCase
public function testLoginUseUsernameDummy()
{
$config = new AauthConfig();
$config = new AauthConfig();
$config->loginUseUsername = true;
$this->model = new UserModel($this->db, null, $config);
$newUser = $this->model->insert(['email' => 'test@test.local', 'password' => 'password123456']);
$newUser = $this->model->insert(['email' => 'test@test.local', 'password' => 'password123456']);
$this->assertFalse($newUser);
}
}

60
tests/Aauth/Database/UserVariableModelTest.php

@ -14,9 +14,9 @@ class UserVariableModelTest extends CIDatabaseTestCase
public function setUp()
{
parent::setUp();
parent::setUp();
$this->model = new UserVariableModel($this->db);
$this->model = new UserVariableModel($this->db);
$this->config = new AauthConfig();
}
@ -28,9 +28,9 @@ class UserVariableModelTest extends CIDatabaseTestCase
$this->assertFalse($userVariable);
$this->hasInDatabase($this->config->dbTableUserVariables, [
'user_id' => 99,
'data_key' => 'test',
'data_value' => 'TRUE',
'user_id' => 99,
'data_key' => 'test',
'data_value' => 'TRUE',
]);
$userVariable = $this->model->find(99, 'test');
$this->assertEquals('TRUE', $userVariable);
@ -39,9 +39,9 @@ class UserVariableModelTest extends CIDatabaseTestCase
public function testFindAll()
{
$this->hasInDatabase($this->config->dbTableUserVariables, [
'user_id' => 99,
'data_key' => 'test',
'data_value' => 'TRUE',
'user_id' => 99,
'data_key' => 'test',
'data_value' => 'TRUE',
]);
$userVariables = $this->model->findAll(99);
$this->assertCount(1, $userVariables);
@ -51,28 +51,28 @@ class UserVariableModelTest extends CIDatabaseTestCase
{
$this->model->save(99, 'test', 'TRUE');
$this->seeInDatabase($this->config->dbTableUserVariables, [
'user_id' => 99,
'data_key' => 'test',
'data_value' => 'TRUE',
'user_id' => 99,
'data_key' => 'test',
'data_value' => 'TRUE',
]);
$this->model->save(99, 'test', 'TRUE2');
$this->seeInDatabase($this->config->dbTableUserVariables, [
'user_id' => 99,
'data_key' => 'test',
'data_value' => 'TRUE2',
'user_id' => 99,
'data_key' => 'test',
'data_value' => 'TRUE2',
]);
}
public function testDelete()
{
$this->hasInDatabase($this->config->dbTableUserVariables, [
'user_id' => 99,
'data_key' => 'test',
'data_value' => 'TRUE',
'user_id' => 99,
'data_key' => 'test',
'data_value' => 'TRUE',
]);
$criteria = [
'user_id' => 99,
'user_id' => 99,
];
$this->seeNumRecords(1, $this->config->dbTableUserVariables, $criteria);
$this->model->delete(99, 'test');
@ -82,22 +82,22 @@ class UserVariableModelTest extends CIDatabaseTestCase
public function testAsArrayFirst()
{
$this->hasInDatabase($this->config->dbTableUserVariables, [
'user_id' => 99,
'data_key' => 'test',
'data_value' => 'TRUE',
'user_id' => 99,
'data_key' => 'test',
'data_value' => 'TRUE',
]);
$userVariable = $this->model->asArray()->where(['data_key'=>'test', 'data_value'=>'TRUE'])->first();
$userVariable = $this->model->asArray()->where(['data_key' => 'test', 'data_value' => 'TRUE'])->first();
$this->assertInternalType('array', $userVariable);
}
public function testAsObjectFirst()
{
$this->hasInDatabase($this->config->dbTableUserVariables, [
'user_id' => 99,
'data_key' => 'test',
'data_value' => 'TRUE',
'user_id' => 99,
'data_key' => 'test',
'data_value' => 'TRUE',
]);
$userVariable = $this->model->asObject()->where(['data_key'=>'test', 'data_value'=>'TRUE'])->first();
$userVariable = $this->model->asObject()->where(['data_key' => 'test', 'data_value' => 'TRUE'])->first();
$this->assertInternalType('object', $userVariable);
}
@ -105,11 +105,11 @@ class UserVariableModelTest extends CIDatabaseTestCase
{
$this->model = new UserVariableModel();
$this->hasInDatabase($this->config->dbTableUserVariables, [
'user_id' => 99,
'data_key' => 'test',
'data_value' => 'TRUE',
'user_id' => 99,
'data_key' => 'test',
'data_value' => 'TRUE',
]);
$userVariable = $this->model->asObject()->where(['data_key'=>'test', 'data_value'=>'TRUE'])->first();
$userVariable = $this->model->asObject()->where(['data_key' => 'test', 'data_value' => 'TRUE'])->first();
$this->assertInternalType('object', $userVariable);
}

106
tests/Aauth/Libraries/Aauth/ErrorsTest.php

@ -9,48 +9,47 @@ use App\Libraries\Aauth;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @preserveGlobalState disabled
*/
class ErrorsTest extends \CIUnitTestCase
{
public function setUp()
{
parent::setUp();
$this->library = new Aauth(null, true);
$_COOKIE = [];
$_SESSION = [];
}
public function tearDown()
{
}
protected function getInstance($options=[])
{
$defaults = [
'sessionDriver' => 'CodeIgniter\Session\Handlers\FileHandler',
'sessionCookieName' => 'ci_session',
'sessionExpiration' => 7200,
'sessionSavePath' => 'null',
'sessionMatchIP' => false,
'sessionTimeToUpdate' => 300,
public function setUp()
{
parent::setUp();
$this->library = new Aauth(null, true);
$_COOKIE = [];
$_SESSION = [];
}
public function tearDown()
{
}
protected function getInstance($options = [])
{
$defaults = [
'sessionDriver' => 'CodeIgniter\Session\Handlers\FileHandler',
'sessionCookieName' => 'ci_session',
'sessionExpiration' => 7200,
'sessionSavePath' => 'null',
'sessionMatchIP' => false,
'sessionTimeToUpdate' => 300,
'sessionRegenerateDestroy' => false,
'cookieDomain' => '',
'cookiePrefix' => '',
'cookiePath' => '/',
'cookieSecure' => false,
];
'cookieDomain' => '',
'cookiePrefix' => '',
'cookiePath' => '/',
'cookieSecure' => false,
];
$config = (object)$defaults;
$config = (object)$defaults;
$session = new MockSession(new FileHandler($config, Services::request()->getIPAddress()), $config);
$session->setLogger(new TestLogger(new Logger()));
$session->start();
$session = new MockSession(new FileHandler($config, Services::request()->getIPAddress()), $config);
$session->setLogger(new TestLogger(new Logger()));
$session->start();
return $session;
}
return $session;
}
//--------------------------------------------------------------------
@ -64,26 +63,25 @@ class ErrorsTest extends \CIUnitTestCase
public function testErrorsArray()
{
$this->assertCount(0, $this->library->getErrorsArray());
$this->library->error(['test message 1','test message 2']);
$this->assertEquals(['test message 1','test message 2'], $this->library->getErrorsArray());
$this->library->error(['test message 1', 'test message 2']);
$this->assertEquals(['test message 1', 'test message 2'], $this->library->getErrorsArray());
}
public function testPrintErrors()
{
$this->library->error('test message 1');
$this->assertEquals('test message 1', $this->library->printErrors('<br />', true));
$this->library->error('test message 2');
$this->assertEquals('test message 1<br />test message 2', $this->library->printErrors('<br />', true));
$this->library->printErrors('<br />');
$this->expectOutputString('test message 1<br />test message 2');
$this->library->printErrors('<br />');
$this->expectOutputString('test message 1<br />test message 2');
}
public function testClearErrors()
{
$session = $this->getInstance();
$this->library = new Aauth(NULL, $session);
$session = $this->getInstance();
$this->library = new Aauth(null, $session);
$this->library->error('test message 1', true);
$this->assertEquals(['test message 1'], $session->getFlashdata('errors'));
$this->library->clearErrors();
@ -93,30 +91,30 @@ class ErrorsTest extends \CIUnitTestCase
public function testErrorsFlash()
{
$session = $this->getInstance();
$this->library = new Aauth(NULL, $session);
$session = $this->getInstance();
$this->library = new Aauth(null, $session);
$this->assertNull($session->getFlashdata('errors'));
$this->library->error('test message 1', true);
$session->start();
$session->start();
$this->assertEquals(['test message 1'], $session->getFlashdata('errors'));
$this->library = new Aauth(NULL, $session);
$this->library->error(['test message 1','test message 2'], true);
$session->start();
$this->assertEquals(['test message 1','test message 2'], $session->getFlashdata('errors'));
$this->library = new Aauth(null, $session);
$this->library->error(['test message 1', 'test message 2'], true);
$session->start();
$this->assertEquals(['test message 1', 'test message 2'], $session->getFlashdata('errors'));
}
public function testErrorsFlashKeep()
{
$session = $this->getInstance();
$this->library = new Aauth(NULL, $session);
$session = $this->getInstance();
$this->library = new Aauth(null, $session);
$this->assertNull($session->getFlashdata('errors'));
$this->library->error('test message 1 Flash', true);
$session->start();
$this->library = new Aauth(NULL, $session);
$session->start();
$this->library = new Aauth(null, $session);
$this->library->error('test message 1 NonFlash');
$this->library->keepErrors(true);
$session->start();
$session->start();
$this->assertEquals(['test message 1 Flash', 'test message 1 NonFlash'], $session->getFlashdata('errors'));
}
}

105
tests/Aauth/Libraries/Aauth/InfosTest.php

@ -9,48 +9,47 @@ use App\Libraries\Aauth;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @preserveGlobalState disabled
*/
class InfosTest extends \CIUnitTestCase
{
public function setUp()
{
parent::setUp();
$this->library = new Aauth(null, true);
$_COOKIE = [];
$_SESSION = [];
}
public function tearDown()
{
}
protected function getInstance($options=[])
{
$defaults = [
'sessionDriver' => 'CodeIgniter\Session\Handlers\FileHandler',
'sessionCookieName' => 'ci_session',
'sessionExpiration' => 7200,
'sessionSavePath' => 'null',
'sessionMatchIP' => false,
'sessionTimeToUpdate' => 300,
public function setUp()
{
parent::setUp();
$this->library = new Aauth(null, true);
$_COOKIE = [];
$_SESSION = [];
}
public function tearDown()
{
}
protected function getInstance($options = [])
{
$defaults = [
'sessionDriver' => 'CodeIgniter\Session\Handlers\FileHandler',
'sessionCookieName' => 'ci_session',
'sessionExpiration' => 7200,
'sessionSavePath' => 'null',
'sessionMatchIP' => false,
'sessionTimeToUpdate' => 300,
'sessionRegenerateDestroy' => false,
'cookieDomain' => '',
'cookiePrefix' => '',
'cookiePath' => '/',
'cookieSecure' => false,
];
'cookieDomain' => '',
'cookiePrefix' => '',
'cookiePath' => '/',
'cookieSecure' => false,
];
$config = (object)$defaults;
$config = (object)$defaults;
$session = new MockSession(new FileHandler($config, Services::request()->getIPAddress()), $config);
$session->setLogger(new TestLogger(new Logger()));
$session->start();
$session = new MockSession(new FileHandler($config, Services::request()->getIPAddress()), $config);
$session->setLogger(new TestLogger(new Logger()));
$session->start();
return $session;
}
return $session;
}
//--------------------------------------------------------------------
@ -64,8 +63,8 @@ class InfosTest extends \CIUnitTestCase
public function testInfosArray()
{
$this->assertCount(0, $this->library->getInfosArray());
$this->library->info(['test message 1','test message 2']);
$this->assertEquals(['test message 1','test message 2'], $this->library->getInfosArray());
$this->library->info(['test message 1', 'test message 2']);
$this->assertEquals(['test message 1', 'test message 2'], $this->library->getInfosArray());
}
public function testPrintInfos()
@ -75,14 +74,14 @@ class InfosTest extends \CIUnitTestCase
$this->library->info('test message 2');
$this->assertEquals('test message 1<br />test message 2', $this->library->printInfos('<br />', true));
$this->library->printInfos('<br />');
$this->expectOutputString('test message 1<br />test message 2');
$this->library->printInfos('<br />');
$this->expectOutputString('test message 1<br />test message 2');
}
public function testClearInfos()
{
$session = $this->getInstance();
$this->library = new Aauth(NULL, $session);
$session = $this->getInstance();
$this->library = new Aauth(null, $session);
$this->library->info('test message 1', true);
$this->assertEquals(['test message 1'], $session->getFlashdata('infos'));
$this->library->clearInfos();
@ -92,30 +91,30 @@ class InfosTest extends \CIUnitTestCase
public function testInfosFlash()
{
$session = $this->getInstance();
$this->library = new Aauth(NULL, $session);
$session = $this->getInstance();
$this->library = new Aauth(null, $session);
$this->assertNull($session->getFlashdata('infos'));
$this->library->info('test message 1', true);
$session->start();
$session->start();
$this->assertEquals(['test message 1'], $session->getFlashdata('infos'));
$this->library = new Aauth(NULL, $session);
$this->library->info(['test message 1','test message 2'], true);
$session->start();
$this->assertEquals(['test message 1','test message 2'], $session->getFlashdata('infos'));
$this->library = new Aauth(null, $session);
$this->library->info(['test message 1', 'test message 2'], true);
$session->start();
$this->assertEquals(['test message 1', 'test message 2'], $session->getFlashdata('infos'));
}
public function testInfosFlashKeep()
{
$session = $this->getInstance();
$this->library = new Aauth(NULL, $session);
$session = $this->getInstance();
$this->library = new Aauth(null, $session);
$this->assertNull($session->getFlashdata('infos'));
$this->library->info('test message 1 Flash', true);
$session->start();
$this->library = new Aauth(NULL, $session);
$session->start();
$this->library = new Aauth(null, $session);
$this->library->info('test message 1 NonFlash');
$this->library->keepInfos(true);
$session->start();
$session->start();
$this->assertEquals(['test message 1 Flash', 'test message 1 NonFlash'], $session->getFlashdata('infos'));
}
}

41
tests/Aauth/Libraries/Aauth/LoginTest.php

@ -15,7 +15,7 @@ use App\Models\Aauth\LoginTokenModel;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @preserveGlobalState disabled
*/
class LoginTest extends CIDatabaseTestCase
{
@ -31,30 +31,29 @@ class LoginTest extends CIDatabaseTestCase
Services::injectMock('response', new MockResponse(new App()));
$this->response = service('response');
$this->library = new Aauth(null, true);
$_COOKIE = [];
$_SESSION = [];
$this->library = new Aauth(null, true);
$_COOKIE = [];
$_SESSION = [];
}
public function tearDown()
{
}
protected function getInstance($options=[])
protected function getInstance($options = [])
{
$defaults = [
'sessionDriver' => 'CodeIgniter\Session\Handlers\FileHandler',
'sessionCookieName' => 'ci_session',
'sessionExpiration' => 7200,
'sessionSavePath' => 'null',
'sessionMatchIP' => false,
'sessionTimeToUpdate' => 300,
'sessionDriver' => 'CodeIgniter\Session\Handlers\FileHandler',
'sessionCookieName' => 'ci_session',
'sessionExpiration' => 7200,
'sessionSavePath' => 'null',
'sessionMatchIP' => false,
'sessionTimeToUpdate' => 300,
'sessionRegenerateDestroy' => false,
'cookieDomain' => '',
'cookiePrefix' => '',
'cookiePath' => '/',
'cookieSecure' => false,
'cookieDomain' => '',
'cookiePrefix' => '',
'cookiePath' => '/',
'cookieSecure' => false,
];
$config = (object)$defaults;
@ -70,8 +69,8 @@ class LoginTest extends CIDatabaseTestCase
public function testLogin()
{
$session = $this->getInstance();
$config = new AauthConfig();
$session = $this->getInstance();
$config = new AauthConfig();
$config->loginUseUsername = true;
$this->library = new Aauth($config, $session);
@ -104,7 +103,7 @@ class LoginTest extends CIDatabaseTestCase
$this->assertEquals(lang('Aauth.loginFailedAll'), $this->library->getErrorsArray()[0]);
$this->library->banUser(1);
$this->library->clearErrors();
$this->library->clearErrors();
$this->assertFalse($this->library->login('admin@example.com', 'password123456'));
$this->assertEquals(lang('Aauth.invalidUserBanned'), $this->library->getErrorsArray()[0]);
@ -124,7 +123,7 @@ class LoginTest extends CIDatabaseTestCase
public function testIsLoggedIn()
{
$session = $this->getInstance();
$session = $this->getInstance();
$this->library = new Aauth(null, $session);
$session->set('user', [
'loggedIn' => true,
@ -134,7 +133,7 @@ class LoginTest extends CIDatabaseTestCase
public function testLogout()
{
$session = $this->getInstance();
$session = $this->getInstance();
$this->library = new Aauth(null, $session);
$session->set('user', [
'loggedIn' => true,

172
tests/Aauth/Libraries/Aauth/UserTest.php

@ -21,24 +21,24 @@ class UserTest extends CIDatabaseTestCase
protected $namespace = 'App';
public function setUp()
public function setUp()
{
parent::setUp();
parent::setUp();
$this->library = new Aauth(null, true);
$this->library = new Aauth(null, true);
$this->config = new AauthConfig();
$_COOKIE = [];
$_SESSION = [];
}
$_COOKIE = [];
$_SESSION = [];
}
public function tearDown()
public function tearDown()
{
}
}
protected function getInstance($options=[])
protected function getInstance($options=[])
{
$defaults = [
$defaults = [
'sessionDriver' => 'CodeIgniter\Session\Handlers\FileHandler',
'sessionCookieName' => 'ci_session',
'sessionExpiration' => 7200,
@ -50,68 +50,68 @@ class UserTest extends CIDatabaseTestCase
'cookiePrefix' => '',
'cookiePath' => '/',
'cookieSecure' => false,
];
];
$config = (object)$defaults;
$config = (object)$defaults;
$session = new MockSession(new FileHandler($config, Services::request()->getIPAddress()), $config);
$session->setLogger(new TestLogger(new Logger()));
$session->start();
$session = new MockSession(new FileHandler($config, Services::request()->getIPAddress()), $config);
$session->setLogger(new TestLogger(new Logger()));
$session->start();
return $session;
}
return $session;
}
//--------------------------------------------------------------------
public function testUpdateUser()
{
$session = $this->getInstance();
$this->library = new Aauth(NULL, $session);
$session = $this->getInstance();
$this->library = new Aauth(NULL, $session);
$this->seeInDatabase($this->config->dbTableUsers, [
'id' => 2,
'email' => 'user@example.com',
'username' => 'user',
'id' => 2,
'email' => 'user@example.com',
'username' => 'user',
]);
$this->library->updateUser(2, 'user1@example.com', 'password987654', 'user1');
$this->library->updateUser(2, 'user1@example.com', 'password987654', 'user1');
$this->seeInDatabase($this->config->dbTableUsers, [
'id' => 2,
'email' => 'user1@example.com',
'username' => 'user1',
'id' => 2,
'email' => 'user1@example.com',
'username' => 'user1',
]);
$this->assertEquals(lang('Aauth.infoUpdateSuccess'), $this->library->getInfosArray()[0]);
$this->assertEquals(lang('Aauth.infoUpdateSuccess'), $this->library->getInfosArray()[0]);
// $this->library->clearInfos();
// $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, 'admin@example.com', null, null));
$this->assertEquals(lang('Aauth.existsAlreadyEmail'), $this->library->getErrorsArray()[0]);
$this->library->clearErrors();
$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, 'adminexample.com', null, null));
$this->assertEquals(lang('Aauth.invalidEmail'), $this->library->getErrorsArray()[0]);
$this->library->clearErrors();
$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, 'pass', null));
$this->assertEquals(lang('Aauth.invalidPassword'), $this->library->getErrorsArray()[0]);
$this->library->clearErrors();
$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, 'password12345678901011121314151617', null));
$this->assertEquals(lang('Aauth.invalidPassword'), $this->library->getErrorsArray()[0]);
$this->library->clearErrors();
$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, 'admin'));
$this->assertEquals(lang('Aauth.existsAlreadyUsername'), $this->library->getErrorsArray()[0]);
$this->library->clearErrors();
$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, null, null, 'user+'));
$this->assertEquals(lang('Aauth.invalidUsername'), $this->library->getErrorsArray()[0]);
$this->library->clearErrors();
$this->assertFalse($this->library->updateUser(2));
$this->assertCount(0, $this->library->getErrorsArray());
$this->library = new Aauth(NULL, $session);
$this->assertFalse($this->library->updateUser(2));
$this->assertCount(0, $this->library->getErrorsArray());
$this->library->clearErrors();
$this->assertFalse($this->library->updateUser(99));
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]);
$this->library = new Aauth(NULL, $session);
$this->assertFalse($this->library->updateUser(99));
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]);
}
public function testDeleteUser()
@ -121,54 +121,54 @@ class UserTest extends CIDatabaseTestCase
$this->seeNumRecords(1, $this->config->dbTableUsers, ['deleted' => 0]);
$this->assertFalse($this->library->deleteUser(99));
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]);
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]);
}
public function testListUsers()
{
$users = $this->library->listUsers();
$users = $this->library->listUsers();
$this->assertCount(2, $users);
$this->assertEquals('admin', $users[0]['username']);
$this->assertEquals('user', $users[1]['username']);
$usersOrderBy = $this->library->listUsers(0, 0, null, 'id DESC');
$usersOrderBy = $this->library->listUsers(0, 0, null, 'id DESC');
$this->assertEquals('user', $usersOrderBy[0]['username']);
$this->assertEquals('admin', $usersOrderBy[1]['username']);
}
public function testGetUser()
{
$user = $this->library->getUser(1);
$user = $this->library->getUser(1);
$this->assertEquals('1', $user['id']);
$this->assertEquals('admin', $user['username']);
$this->assertEquals('admin@example.com', $user['email']);
$session = $this->getInstance();
$this->library = new Aauth(NULL, $session);
$session = $this->getInstance();
$this->library = new Aauth(NULL, $session);
$session->set('user', [
'id' => 1,
]);
$userIdNone = $this->library->getUser();
$userIdNone = $this->library->getUser();
$this->assertEquals('admin', $userIdNone['username']);
$userVar = $this->library->getUser(1, true);
$userVar = $this->library->getUser(1, true);
$this->assertInternalType('array', $userVar['variables']);
$this->assertFalse($this->library->getUser(99));
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]);
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]);
}
public function testGetUserId()
{
$userIdEmail = $this->library->getUserId('admin@example.com');
$userIdEmail = $this->library->getUserId('admin@example.com');
$this->assertEquals('1', $userIdEmail);
$session = $this->getInstance();
$this->library = new Aauth(NULL, $session);
$session = $this->getInstance();
$this->library = new Aauth(NULL, $session);
$session->set('user', [
'id' => 1,
]);
$userIdNone = $this->library->getUserId();
$userIdNone = $this->library->getUserId();
$this->assertEquals('1', $userIdNone);
$this->assertFalse($this->library->getUserId('none@example.com'));
@ -177,52 +177,52 @@ class UserTest extends CIDatabaseTestCase
public function testBanUser()
{
$this->seeInDatabase($this->config->dbTableUsers, [
'id' => 1,
'banned' => 0,
'id' => 1,
'banned' => 0,
]);
$this->library->banUser(1);
$this->library->banUser(1);
$this->seeInDatabase($this->config->dbTableUsers, [
'id' => 1,
'banned' => 1,
'id' => 1,
'banned' => 1,
]);
$this->assertFalse($this->library->banUser(99));
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]);
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]);
}
public function testUnbanUser()
{
$this->library->banUser(1);
$this->library->banUser(1);
$this->seeInDatabase($this->config->dbTableUsers, [
'id' => 1,
'banned' => 1,
'id' => 1,
'banned' => 1,
]);
$this->library->unbanUser(1);
$this->library->unbanUser(1);
$this->seeInDatabase($this->config->dbTableUsers, [
'id' => 1,
'banned' => 0,
'id' => 1,
'banned' => 0,
]);
$this->assertFalse($this->library->unbanUser(99));
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]);
$this->assertEquals(lang('Aauth.notFoundUser'), $this->library->getErrorsArray()[0]);
}
public function testBanUnbanUserSession()
{
$session = $this->getInstance();
$this->library = new Aauth(NULL, $session);
$session = $this->getInstance();
$this->library = new Aauth(NULL, $session);
$session->set('user', [
'id' => 1,
]);
$this->library->banUser();
$this->library->banUser();
$this->seeInDatabase($this->config->dbTableUsers, [
'id' => 1,
'banned' => 1,
'id' => 1,
'banned' => 1,
]);
$this->library->unbanUser();
$this->library->unbanUser();
$this->seeInDatabase($this->config->dbTableUsers, [
'id' => 1,
'banned' => 0,
'id' => 1,
'banned' => 0,
]);
}
@ -230,7 +230,7 @@ class UserTest extends CIDatabaseTestCase
{
$this->assertFalse($this->library->isBanned(1));
$this->library->banUser(1);
$this->library->banUser(1);
$this->assertTrue($this->library->isBanned(1));
$this->assertTrue($this->library->isBanned(99));

Loading…
Cancel
Save