You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.7 KiB
77 lines
1.7 KiB
6 years ago
|
<?php namespace Tests\Aauth\Database;
|
||
|
|
||
|
use CodeIgniter\Test\CIDatabaseTestCase;
|
||
|
use App\Models\Aauth\LoginAttemptModel;
|
||
|
|
||
|
class LoginAttemptModelTest extends CIDatabaseTestCase
|
||
|
{
|
||
|
protected $refresh = true;
|
||
|
|
||
|
protected $basePath = TESTPATH . '../application' . 'Database/Migrations';
|
||
|
|
||
|
protected $namespace = 'App';
|
||
|
|
||
|
public function setUp()
|
||
|
{
|
||
|
parent::setUp();
|
||
|
|
||
|
$this->model = new LoginAttemptModel($this->db);
|
||
|
}
|
||
|
|
||
|
//--------------------------------------------------------------------
|
||
|
|
||
|
public function testFind()
|
||
|
{
|
||
|
$loginAttempt = $this->model->find();
|
||
|
$this->assertEquals(0, $loginAttempt);
|
||
|
}
|
||
|
|
||
|
public function testSaveInsert()
|
||
|
{
|
||
|
$this->model->save();
|
||
|
$loginAttempt = $this->model->find();
|
||
|
$this->assertEquals(1, $loginAttempt);
|
||
|
}
|
||
|
|
||
|
public function testSaveUpdate()
|
||
|
{
|
||
|
$this->model->save();
|
||
|
$this->assertTrue($this->model->save());
|
||
|
$loginAttempt = $this->model->find();
|
||
|
$this->assertEquals(2, $loginAttempt);
|
||
|
}
|
||
|
|
||
|
public function testSaveUpdateFalse()
|
||
|
{
|
||
|
$this->model->save();
|
||
|
$this->model->save();
|
||
|
$this->model->save();
|
||
|
$this->model->save();
|
||
|
$this->model->save();
|
||
|
$this->model->save();
|
||
|
$this->model->save();
|
||
|
$this->model->save();
|
||
|
$this->model->save();
|
||
|
$this->model->save();
|
||
|
$this->assertFalse($this->model->save());
|
||
|
}
|
||
|
|
||
|
public function testDelete()
|
||
|
{
|
||
|
$this->model->save();
|
||
|
$loginAttempt = $this->model->find();
|
||
|
$this->assertEquals(1, $loginAttempt);
|
||
|
$this->model->delete();
|
||
|
$loginAttempt = $this->model->find();
|
||
|
$this->assertEquals(0, $loginAttempt);
|
||
|
}
|
||
|
|
||
|
public function testConfigDBGroup()
|
||
|
{
|
||
|
$this->model = new LoginAttemptModel();
|
||
|
$this->model->save();
|
||
|
$groupsToGroup = $this->model->find();
|
||
|
$this->assertEquals(1, $groupsToGroup);
|
||
|
}
|
||
|
}
|