diff --git a/application/Libraries/Aauth.php b/application/Libraries/Aauth.php index c164daa..9a7a78c 100644 --- a/application/Libraries/Aauth.php +++ b/application/Libraries/Aauth.php @@ -94,7 +94,7 @@ class Aauth * * Prepares config & session variable. */ - public function __construct($config = NULL, $session = NULL) + public function __construct($config = null, $session = null) { if (is_null($config)) { diff --git a/tests/Aauth/Libraries/Aauth/ErrorsTest.php b/tests/Aauth/Libraries/Aauth/ErrorsTest.php new file mode 100644 index 0000000..3732691 --- /dev/null +++ b/tests/Aauth/Libraries/Aauth/ErrorsTest.php @@ -0,0 +1,73 @@ + '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 testErrors() + { + $session = $this->getInstance(); + $this->library = new Aauth(NULL, $session); + $this->assertCount(0, $this->library->getErrorsArray()); + $this->library->error('test message 1'); + $this->assertCount(1, $this->library->getErrorsArray()); + } + + public function testErrorsFlash() + { + $session = $this->getInstance(); + $this->library = new Aauth(NULL, $session); + $this->assertCount(0, $this->library->errors); + $this->library->error('test message 1', true); + $this->assertCount(1, $this->session->errors); + } +} diff --git a/tests/Aauth/Libraries/AauthTest.php b/tests/Aauth/Libraries/AauthTest.php index d08980a..6d6d33b 100644 --- a/tests/Aauth/Libraries/AauthTest.php +++ b/tests/Aauth/Libraries/AauthTest.php @@ -48,29 +48,8 @@ class AauthTest extends \CIUnitTestCase $session->setLogger(new TestLogger(new Logger())); $session->start(); - var_dump($_SESSION); - return $session; } //-------------------------------------------------------------------- - - public function testIsLoggedIn() - { - $session = $this->getInstance(); - - $this->library = new Aauth(NULL, $session); - - $this->assertFalse($this->library->isLoggedIn()); - } - - public function testTest() - { - $session = $this->getInstance(); - $session->start(); - - $session->set('foo', 'bar'); - - $this->assertEquals('bar', $_SESSION['foo']); - } }