clqms-be/tests/unit/v2/master/TestDef/TestDefGrpModelTest.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

133 lines
3.0 KiB
PHP

<?php
namespace Tests\Unit\v2\master\TestDef;
use CodeIgniter\Test\CIUnitTestCase;
use App\Models\Test\TestDefGrpModel;
/**
* Unit tests for TestDefGrpModel
*
* Tests the group definition model for GROUP type tests
*/
class TestDefGrpModelTest extends CIUnitTestCase
{
protected TestDefGrpModel $model;
protected function setUp(): void
{
parent::setUp();
$this->model = new TestDefGrpModel();
}
/**
* Test model has correct table name
*/
public function testModelHasCorrectTableName(): void
{
$this->assertEquals('testdefgrp', $this->model->table);
}
/**
* Test model has correct primary key
*/
public function testModelHasCorrectPrimaryKey(): void
{
$this->assertEquals('TestGrpID', $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 keys
$this->assertContains('TestSiteID', $allowedFields);
$this->assertContains('Member', $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 TestSiteID field is in allowed fields
*/
public function testTestSiteIDFieldExists(): void
{
$allowedFields = $this->model->allowedFields;
$this->assertContains('TestSiteID', $allowedFields);
}
/**
* Test Member field is in allowed fields
*/
public function testMemberFieldExists(): void
{
$allowedFields = $this->model->allowedFields;
$this->assertContains('Member', $allowedFields);
}
/**
* Test CreateDate field is in allowed fields
*/
public function testCreateDateFieldExists(): void
{
$allowedFields = $this->model->allowedFields;
$this->assertContains('CreateDate', $allowedFields);
}
/**
* Test EndDate field is in allowed fields
*/
public function testEndDateFieldExists(): void
{
$allowedFields = $this->model->allowedFields;
$this->assertContains('EndDate', $allowedFields);
}
}