clqms-be/tests/unit/v2/master/TestDef/TestMapModelTest.php
mahdahar cd65e91db1 refactor: Rename controllers to follow CodeIgniter 4 naming convention
- Rename all controllers from X.php to XController.php format
- Add new RefTxtModel for text-based reference ranges
- Rename group_dialog.php to grp_dialog.php and remove title_dialog.php
- Add comprehensive test suite for v2/master/TestDef module
- Update Routes.php to reflect controller renames
- Remove obsolete data files (clqms_v2.sql, lab.dbml)
2026-01-05 16:55:34 +07:00

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);
}
}