From c398aa7e2f8254def88fd80060441797ecbcdd5e Mon Sep 17 00:00:00 2001 From: REJack Date: Sun, 9 Dec 2018 15:17:41 +0100 Subject: [PATCH] updated Aauth/UserTest.php --- tests/Aauth/Libraries/Aauth/UserTest.php | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/Aauth/Libraries/Aauth/UserTest.php b/tests/Aauth/Libraries/Aauth/UserTest.php index 4f82aa0..c9b6263 100644 --- a/tests/Aauth/Libraries/Aauth/UserTest.php +++ b/tests/Aauth/Libraries/Aauth/UserTest.php @@ -73,6 +73,7 @@ class UserTest extends CIDatabaseTestCase $this->assertEquals($user['username'], $userAfter['username']); $this->assertFalse($this->library->updateUser(2, 'asasdfasd')); $this->assertFalse($this->library->updateUser(2)); + $this->assertFalse($this->library->updateUser(99)); } public function testDeleteUser() @@ -128,6 +129,7 @@ class UserTest extends CIDatabaseTestCase ]); $userIdNone = $this->library->getUserId(); $this->assertEquals('1', $userIdNone); + $this->assertFalse($this->library->getUserId('none@example.com')); } public function testBanUser() @@ -135,6 +137,8 @@ class UserTest extends CIDatabaseTestCase $this->assertFalse($this->library->isBanned(1)); $this->library->banUser(1); $this->assertTrue($this->library->isBanned(1)); + $this->assertFalse($this->library->banUser(99)); + $this->assertCount(1, $this->library->getErrorsArray()); } public function testUnbanUser() @@ -143,5 +147,27 @@ class UserTest extends CIDatabaseTestCase $this->assertTrue($this->library->isBanned(1)); $this->library->unbanUser(1); $this->assertFalse($this->library->isBanned(1)); + $this->assertFalse($this->library->unbanUser(99)); + $this->assertCount(1, $this->library->getErrorsArray()); + } + + + public function testUnbanUserSession() + { + $session = $this->getInstance(); + $this->library = new Aauth(NULL, $session); + $session->set('user', [ + 'id' => 1, + ]); + $this->library->banUser(); + $this->assertTrue($this->library->isBanned()); + $this->library->unbanUser(); + $this->assertFalse($this->library->isBanned()); + } + + public function testIsBanned() + { + $this->assertFalse($this->library->isBanned(99)); + $this->assertCount(1, $this->library->getErrorsArray()); } }