221 lines
5.6 KiB
PHP
221 lines
5.6 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Tests\Unit\v2\master\TestDef;
|
||
|
|
|
||
|
|
use CodeIgniter\Test\CIUnitTestCase;
|
||
|
|
use App\Models\Test\TestDefSiteModel;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Unit tests for TestDefSiteModel - Master Data Tests CRUD operations
|
||
|
|
*
|
||
|
|
* Tests the model configuration and behavior for test definition management
|
||
|
|
*/
|
||
|
|
class TestDefSiteModelMasterTest 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 for master data
|
||
|
|
*/
|
||
|
|
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);
|
||
|
|
|
||
|
|
// Display and ordering fields
|
||
|
|
$this->assertContains('Description', $allowedFields);
|
||
|
|
$this->assertContains('SeqScr', $allowedFields);
|
||
|
|
$this->assertContains('SeqRpt', $allowedFields);
|
||
|
|
$this->assertContains('IndentLeft', $allowedFields);
|
||
|
|
$this->assertContains('FontStyle', $allowedFields);
|
||
|
|
|
||
|
|
// Visibility fields
|
||
|
|
$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);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test SiteID field is in allowed fields
|
||
|
|
*/
|
||
|
|
public function testSiteIDFieldExists(): void
|
||
|
|
{
|
||
|
|
$allowedFields = $this->model->allowedFields;
|
||
|
|
$this->assertContains('SiteID', $allowedFields);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test Description field is in allowed fields
|
||
|
|
*/
|
||
|
|
public function testDescriptionFieldExists(): void
|
||
|
|
{
|
||
|
|
$allowedFields = $this->model->allowedFields;
|
||
|
|
$this->assertContains('Description', $allowedFields);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test SeqScr field is in allowed fields
|
||
|
|
*/
|
||
|
|
public function testSeqScrFieldExists(): void
|
||
|
|
{
|
||
|
|
$allowedFields = $this->model->allowedFields;
|
||
|
|
$this->assertContains('SeqScr', $allowedFields);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test SeqRpt field is in allowed fields
|
||
|
|
*/
|
||
|
|
public function testSeqRptFieldExists(): void
|
||
|
|
{
|
||
|
|
$allowedFields = $this->model->allowedFields;
|
||
|
|
$this->assertContains('SeqRpt', $allowedFields);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test VisibleScr field is in allowed fields
|
||
|
|
*/
|
||
|
|
public function testVisibleScrFieldExists(): void
|
||
|
|
{
|
||
|
|
$allowedFields = $this->model->allowedFields;
|
||
|
|
$this->assertContains('VisibleScr', $allowedFields);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test VisibleRpt field is in allowed fields
|
||
|
|
*/
|
||
|
|
public function testVisibleRptFieldExists(): void
|
||
|
|
{
|
||
|
|
$allowedFields = $this->model->allowedFields;
|
||
|
|
$this->assertContains('VisibleRpt', $allowedFields);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test CountStat field is in allowed fields
|
||
|
|
*/
|
||
|
|
public function testCountStatFieldExists(): void
|
||
|
|
{
|
||
|
|
$allowedFields = $this->model->allowedFields;
|
||
|
|
$this->assertContains('CountStat', $allowedFields);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test getTests method exists and is callable
|
||
|
|
*/
|
||
|
|
public function testGetTestsMethodExists(): void
|
||
|
|
{
|
||
|
|
$this->assertTrue(method_exists($this->model, 'getTests'));
|
||
|
|
$this->assertIsCallable([$this->model, 'getTests']);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test getTest method exists and is callable
|
||
|
|
*/
|
||
|
|
public function testGetTestMethodExists(): void
|
||
|
|
{
|
||
|
|
$this->assertTrue(method_exists($this->model, 'getTest'));
|
||
|
|
$this->assertIsCallable([$this->model, 'getTest']);
|
||
|
|
}
|
||
|
|
}
|