Browse Source

added Aauth/LoginTest.php

v3-dev
REJack 6 years ago
parent
commit
4e00eb55a2
No known key found for this signature in database
GPG Key ID: 4A44B48700429F46
  1. 71
      tests/Aauth/Libraries/Aauth/LoginTest.php

71
tests/Aauth/Libraries/Aauth/LoginTest.php

@ -0,0 +1,71 @@
<?php namespace Tests\Aauth\Libraries\Aauth;
use Config\Logger;
use Config\Services;
use Tests\Support\Log\TestLogger;
use Tests\Support\Session\MockSession;
use CodeIgniter\Session\Handlers\FileHandler;
use CodeIgniter\Test\CIDatabaseTestCase;
use App\Libraries\Aauth;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
class LoginTest extends CIDatabaseTestCase
{
protected $refresh = true;
protected $basePath = TESTPATH . '../application' . 'Database/Migrations';
protected $namespace = 'App';
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,
];
$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());
}
}
Loading…
Cancel
Save