138 lines
3.5 KiB
PHP
138 lines
3.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Tests\Unit\v2\master\TestDef;
|
||
|
|
|
||
|
|
use CodeIgniter\Test\CIUnitTestCase;
|
||
|
|
use App\Models\Test\TestDefSiteModel;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Unit tests for TestDefSiteModel
|
||
|
|
*
|
||
|
|
* Tests the main test definition model configuration and behavior
|
||
|
|
*/
|
||
|
|
class TestDefSiteModelTest extends CIUnitTestCase
|
||
|
|
{
|
||
|
|
protected TestDefSiteModel $model;
|
||
|
|
|
||
|
|
protected function setUp(): void
|
||
|
|
{
|
||
|
|
parent::setUp();
|
||
|
|
$this->model = new TestDefSiteModel();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test model has correct table name
|
||
|
|
*/
|
||
|
|
public function testModelHasCorrectTableName(): void
|
||
|
|
{
|
||
|
|
$this->assertEquals('testdefsite', $this->model->table);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test model has correct primary key
|
||
|
|
*/
|
||
|
|
public function testModelHasCorrectPrimaryKey(): void
|
||
|
|
{
|
||
|
|
$this->assertEquals('TestSiteID', $this->model->primaryKey);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test model uses soft deletes
|
||
|
|
*/
|
||
|
|
public function testModelUsesSoftDeletes(): void
|
||
|
|
{
|
||
|
|
$this->assertTrue($this->model->useSoftDeletes);
|
||
|
|
$this->assertEquals('EndDate', $this->model->deletedField);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test model has correct allowed fields
|
||
|
|
*/
|
||
|
|
public function testModelHasCorrectAllowedFields(): void
|
||
|
|
{
|
||
|
|
$allowedFields = $this->model->allowedFields;
|
||
|
|
|
||
|
|
// Core required fields
|
||
|
|
$this->assertContains('SiteID', $allowedFields);
|
||
|
|
$this->assertContains('TestSiteCode', $allowedFields);
|
||
|
|
$this->assertContains('TestSiteName', $allowedFields);
|
||
|
|
$this->assertContains('TestType', $allowedFields);
|
||
|
|
|
||
|
|
// Optional fields
|
||
|
|
$this->assertContains('Description', $allowedFields);
|
||
|
|
$this->assertContains('SeqScr', $allowedFields);
|
||
|
|
$this->assertContains('SeqRpt', $allowedFields);
|
||
|
|
$this->assertContains('IndentLeft', $allowedFields);
|
||
|
|
$this->assertContains('FontStyle', $allowedFields);
|
||
|
|
$this->assertContains('VisibleScr', $allowedFields);
|
||
|
|
$this->assertContains('VisibleRpt', $allowedFields);
|
||
|
|
$this->assertContains('CountStat', $allowedFields);
|
||
|
|
|
||
|
|
// Timestamp fields
|
||
|
|
$this->assertContains('CreateDate', $allowedFields);
|
||
|
|
$this->assertContains('StartDate', $allowedFields);
|
||
|
|
$this->assertContains('EndDate', $allowedFields);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test model uses timestamps
|
||
|
|
*/
|
||
|
|
public function testModelUsesTimestamps(): void
|
||
|
|
{
|
||
|
|
$this->assertTrue($this->model->useTimestamps);
|
||
|
|
$this->assertEquals('CreateDate', $this->model->createdField);
|
||
|
|
$this->assertEquals('StartDate', $this->model->updatedField);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test model return type is array
|
||
|
|
*/
|
||
|
|
public function testModelReturnTypeIsArray(): void
|
||
|
|
{
|
||
|
|
$this->assertEquals('array', $this->model->returnType);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test model has correct skip validation
|
||
|
|
*/
|
||
|
|
public function testModelSkipValidation(): void
|
||
|
|
{
|
||
|
|
$this->assertFalse($this->model->skipValidation);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test model has correct useAutoIncrement
|
||
|
|
*/
|
||
|
|
public function testModelUseAutoIncrement(): void
|
||
|
|
{
|
||
|
|
$this->assertTrue($this->model->useAutoIncrement);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test TestSiteCode field is in allowed fields
|
||
|
|
*/
|
||
|
|
public function testTestSiteCodeFieldExists(): void
|
||
|
|
{
|
||
|
|
$allowedFields = $this->model->allowedFields;
|
||
|
|
$this->assertContains('TestSiteCode', $allowedFields);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test TestSiteName field is in allowed fields
|
||
|
|
*/
|
||
|
|
public function testTestSiteNameFieldExists(): void
|
||
|
|
{
|
||
|
|
$allowedFields = $this->model->allowedFields;
|
||
|
|
$this->assertContains('TestSiteName', $allowedFields);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test TestType field is in allowed fields
|
||
|
|
*/
|
||
|
|
public function testTestTypeFieldExists(): void
|
||
|
|
{
|
||
|
|
$allowedFields = $this->model->allowedFields;
|
||
|
|
$this->assertContains('TestType', $allowedFields);
|
||
|
|
}
|
||
|
|
}
|