156 lines
3.8 KiB
PHP
156 lines
3.8 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Tests\Unit\v2\master\TestDef;
|
||
|
|
|
||
|
|
use CodeIgniter\Test\CIUnitTestCase;
|
||
|
|
use App\Models\Test\TestMapModel;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Unit tests for TestMapModel
|
||
|
|
*
|
||
|
|
* Tests the test mapping model for all test types
|
||
|
|
*/
|
||
|
|
class TestMapModelTest extends CIUnitTestCase
|
||
|
|
{
|
||
|
|
protected TestMapModel $model;
|
||
|
|
|
||
|
|
protected function setUp(): void
|
||
|
|
{
|
||
|
|
parent::setUp();
|
||
|
|
$this->model = new TestMapModel();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test model has correct table name
|
||
|
|
*/
|
||
|
|
public function testModelHasCorrectTableName(): void
|
||
|
|
{
|
||
|
|
$this->assertEquals('testmap', $this->model->table);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test model has correct primary key
|
||
|
|
*/
|
||
|
|
public function testModelHasCorrectPrimaryKey(): void
|
||
|
|
{
|
||
|
|
$this->assertEquals('TestMapID', $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;
|
||
|
|
|
||
|
|
// Foreign key
|
||
|
|
$this->assertContains('TestSiteID', $allowedFields);
|
||
|
|
|
||
|
|
// Host system mapping
|
||
|
|
$this->assertContains('HostType', $allowedFields);
|
||
|
|
$this->assertContains('HostID', $allowedFields);
|
||
|
|
$this->assertContains('HostDataSource', $allowedFields);
|
||
|
|
$this->assertContains('HostTestCode', $allowedFields);
|
||
|
|
$this->assertContains('HostTestName', $allowedFields);
|
||
|
|
|
||
|
|
// Client system mapping
|
||
|
|
$this->assertContains('ClientType', $allowedFields);
|
||
|
|
$this->assertContains('ClientID', $allowedFields);
|
||
|
|
$this->assertContains('ClientDataSource', $allowedFields);
|
||
|
|
$this->assertContains('ConDefID', $allowedFields);
|
||
|
|
$this->assertContains('ClientTestCode', $allowedFields);
|
||
|
|
$this->assertContains('ClientTestName', $allowedFields);
|
||
|
|
|
||
|
|
// Timestamp fields
|
||
|
|
$this->assertContains('CreateDate', $allowedFields);
|
||
|
|
$this->assertContains('EndDate', $allowedFields);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test model uses timestamps
|
||
|
|
*/
|
||
|
|
public function testModelUsesTimestamps(): void
|
||
|
|
{
|
||
|
|
$this->assertTrue($this->model->useTimestamps);
|
||
|
|
$this->assertEquals('CreateDate', $this->model->createdField);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 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 HostType field is in allowed fields
|
||
|
|
*/
|
||
|
|
public function testHostTypeFieldExists(): void
|
||
|
|
{
|
||
|
|
$allowedFields = $this->model->allowedFields;
|
||
|
|
$this->assertContains('HostType', $allowedFields);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test HostID field is in allowed fields
|
||
|
|
*/
|
||
|
|
public function testHostIDFieldExists(): void
|
||
|
|
{
|
||
|
|
$allowedFields = $this->model->allowedFields;
|
||
|
|
$this->assertContains('HostID', $allowedFields);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test HostTestCode field is in allowed fields
|
||
|
|
*/
|
||
|
|
public function testHostTestCodeFieldExists(): void
|
||
|
|
{
|
||
|
|
$allowedFields = $this->model->allowedFields;
|
||
|
|
$this->assertContains('HostTestCode', $allowedFields);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test ClientType field is in allowed fields
|
||
|
|
*/
|
||
|
|
public function testClientTypeFieldExists(): void
|
||
|
|
{
|
||
|
|
$allowedFields = $this->model->allowedFields;
|
||
|
|
$this->assertContains('ClientType', $allowedFields);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Test TestSiteID field is in allowed fields
|
||
|
|
*/
|
||
|
|
public function testTestSiteIDFieldExists(): void
|
||
|
|
{
|
||
|
|
$allowedFields = $this->model->allowedFields;
|
||
|
|
$this->assertContains('TestSiteID', $allowedFields);
|
||
|
|
}
|
||
|
|
}
|