From 4e00eb55a2b26fd0ef35d5fc10049dd15909fc50 Mon Sep 17 00:00:00 2001 From: REJack Date: Sun, 9 Dec 2018 15:51:15 +0100 Subject: [PATCH] added Aauth/LoginTest.php --- tests/Aauth/Libraries/Aauth/LoginTest.php | 71 +++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/Aauth/Libraries/Aauth/LoginTest.php diff --git a/tests/Aauth/Libraries/Aauth/LoginTest.php b/tests/Aauth/Libraries/Aauth/LoginTest.php new file mode 100644 index 0000000..b10f309 --- /dev/null +++ b/tests/Aauth/Libraries/Aauth/LoginTest.php @@ -0,0 +1,71 @@ +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, + ]; + + $config = (object)$defaults; + + $session = new MockSession(new FileHandler($config, Services::request()->getIPAddress()), $config); + $session->setLogger(new TestLogger(new Logger())); + $session->start(); + + return $session; + } + + //-------------------------------------------------------------------- + + public function testIsLoggedIn() + { + $session = $this->getInstance(); + $this->library = new Aauth(NULL, $session); + $this->assertTrue($this->library->login('admin@example.com', 'password123456')); + $this->assertTrue($this->library->isLoggedIn()); + } +}