clqms-be/tests/unit/TestDef/TestDefModelsTest.php

199 lines
6.4 KiB
PHP
Raw Normal View History

<?php
namespace Tests\Unit\TestDef;
use CodeIgniter\Test\CIUnitTestCase;
use App\Models\Test\TestDefSiteModel;
use App\Models\Test\TestDefCalModel;
use App\Models\Test\TestDefGrpModel;
use App\Models\Test\TestMapModel;
class TestDefModelsTest extends CIUnitTestCase
{
protected $testDefSiteModel;
protected $testDefCalModel;
protected $testDefGrpModel;
protected $testMapModel;
protected function setUp(): void
{
parent::setUp();
$this->testDefSiteModel = new TestDefSiteModel();
$this->testDefCalModel = new TestDefCalModel();
$this->testDefGrpModel = new TestDefGrpModel();
$this->testMapModel = new TestMapModel();
}
/**
* Test TestDefSiteModel has correct table name
*/
public function testTestDefSiteModelTable()
{
$this->assertEquals('testdefsite', $this->testDefSiteModel->table);
}
/**
* Test TestDefSiteModel has correct primary key
*/
public function testTestDefSiteModelPrimaryKey()
{
$this->assertEquals('TestSiteID', $this->testDefSiteModel->primaryKey);
}
/**
* Test TestDefSiteModel has correct allowed fields
*/
public function testTestDefSiteModelAllowedFields()
{
$allowedFields = $this->testDefSiteModel->allowedFields;
$this->assertContains('SiteID', $allowedFields);
$this->assertContains('TestSiteCode', $allowedFields);
$this->assertContains('TestSiteName', $allowedFields);
$this->assertContains('TestType', $allowedFields);
$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);
$this->assertContains('CreateDate', $allowedFields);
$this->assertContains('StartDate', $allowedFields);
$this->assertContains('EndDate', $allowedFields);
}
/**
* Test TestDefSiteModel uses soft deletes
*/
public function testTestDefSiteModelSoftDeletes()
{
$this->assertTrue($this->testDefSiteModel->useSoftDeletes);
$this->assertEquals('EndDate', $this->testDefSiteModel->deletedField);
}
/**
* Test TestDefCalModel has correct table name
*/
public function testTestDefCalModelTable()
{
$this->assertEquals('testdefcal', $this->testDefCalModel->table);
}
/**
* Test TestDefCalModel has correct primary key
*/
public function testTestDefCalModelPrimaryKey()
{
$this->assertEquals('TestCalID', $this->testDefCalModel->primaryKey);
}
/**
* Test TestDefCalModel has correct allowed fields
*/
public function testTestDefCalModelAllowedFields()
{
$allowedFields = $this->testDefCalModel->allowedFields;
$this->assertContains('TestSiteID', $allowedFields);
$this->assertContains('DisciplineID', $allowedFields);
$this->assertContains('DepartmentID', $allowedFields);
$this->assertContains('FormulaInput', $allowedFields);
$this->assertContains('FormulaCode', $allowedFields);
$this->assertContains('RefType', $allowedFields);
$this->assertContains('Unit1', $allowedFields);
$this->assertContains('Factor', $allowedFields);
$this->assertContains('Unit2', $allowedFields);
$this->assertContains('Decimal', $allowedFields);
$this->assertContains('Method', $allowedFields);
}
/**
* Test TestDefGrpModel has correct table name
*/
public function testTestDefGrpModelTable()
{
$this->assertEquals('testdefgrp', $this->testDefGrpModel->table);
}
/**
* Test TestDefGrpModel has correct primary key
*/
public function testTestDefGrpModelPrimaryKey()
{
$this->assertEquals('TestGrpID', $this->testDefGrpModel->primaryKey);
}
/**
* Test TestDefGrpModel has correct allowed fields
*/
public function testTestDefGrpModelAllowedFields()
{
$allowedFields = $this->testDefGrpModel->allowedFields;
$this->assertContains('TestSiteID', $allowedFields);
$this->assertContains('Member', $allowedFields);
}
/**
* Test TestMapModel has correct table name
*/
public function testTestMapModelTable()
{
$this->assertEquals('testmap', $this->testMapModel->table);
}
/**
* Test TestMapModel has correct primary key
*/
public function testTestMapModelPrimaryKey()
{
$this->assertEquals('TestMapID', $this->testMapModel->primaryKey);
}
/**
* Test TestMapModel has correct allowed fields
*/
public function testTestMapModelAllowedFields()
{
$allowedFields = $this->testMapModel->allowedFields;
$this->assertContains('TestSiteID', $allowedFields);
$this->assertContains('HostType', $allowedFields);
$this->assertContains('HostID', $allowedFields);
$this->assertContains('HostDataSource', $allowedFields);
$this->assertContains('HostTestCode', $allowedFields);
$this->assertContains('HostTestName', $allowedFields);
$this->assertContains('ClientType', $allowedFields);
$this->assertContains('ClientID', $allowedFields);
$this->assertContains('ClientDataSource', $allowedFields);
$this->assertContains('ConDefID', $allowedFields);
$this->assertContains('ClientTestCode', $allowedFields);
$this->assertContains('ClientTestName', $allowedFields);
}
/**
* Test all models use soft deletes
*/
public function testAllModelsUseSoftDeletes()
{
$this->assertTrue($this->testDefCalModel->useSoftDeletes);
$this->assertTrue($this->testDefGrpModel->useSoftDeletes);
$this->assertTrue($this->testMapModel->useSoftDeletes);
}
/**
* Test all models have EndDate as deleted field
*/
public function testAllModelsUseEndDateAsDeletedField()
{
$this->assertEquals('EndDate', $this->testDefCalModel->deletedField);
$this->assertEquals('EndDate', $this->testDefGrpModel->deletedField);
$this->assertEquals('EndDate', $this->testMapModel->deletedField);
}
}