clqms-be/tests/feature/Test/TestShowResponseTest.php
root 30c4e47304 chore(repo): normalize EOL and harden contact patch flow
- handle contact PATCH failures by checking model save result and returning HTTP 400 with the model error message
- update ContactDetailModel nested updates to enforce active-detail checks and use model update() with explicit failure propagation
- extend contact patch assertions and align test-create variants expectations to status=success for POST responses
- refresh composer lock metadata/dependency constraints and include generated docs/data/test files updated during normalization
- impact: API contract unchanged except clearer 400 error responses on invalid contact detail updates
2026-04-17 05:38:11 +07:00

39 lines
1.2 KiB
PHP
Executable File

<?php
declare(strict_types=1);
namespace Tests\Feature\Test;
use App\Models\Test\TestDefSiteModel;
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\FeatureTestTrait;
class TestShowResponseTest extends CIUnitTestCase
{
use FeatureTestTrait;
public function testShowTechnicalDoesNotReturnNestedTestDefTech(): void
{
$model = new TestDefSiteModel();
$test = $model->where('TestSiteCode', 'GLU')->where('EndDate IS NULL')->first();
if (!$test) {
$test = $model->where('TestType', 'TEST')->where('EndDate IS NULL')->first();
}
$this->assertNotEmpty($test, 'No active technical test record found for show endpoint test.');
$response = $this->call('get', 'api/test/' . $test['TestSiteID']);
$response->assertStatus(200);
$json = json_decode($response->getJSON(), true);
$this->assertSame('success', $json['status'] ?? null);
$this->assertArrayHasKey('data', $json);
$this->assertArrayNotHasKey('testdeftech', $json['data']);
$this->assertArrayHasKey('TestSiteID', $json['data']);
$this->assertArrayHasKey('ResultType', $json['data']);
}
}