clqms-be/tests/feature/Patients/PatientShowTest.php

40 lines
1.0 KiB
PHP
Raw Normal View History

2025-09-23 10:18:48 +07:00
<?php
2025-09-25 14:01:33 +07:00
namespace Tests\Feature\Patients;
2025-09-23 10:18:48 +07:00
use CodeIgniter\Test\FeatureTestTrait;
use CodeIgniter\Test\CIUnitTestCase;
class PatientShowTest extends CIUnitTestCase
{
use FeatureTestTrait;
2025-09-25 14:01:33 +07:00
protected $endpoint = 'api/patient';
2025-09-23 10:18:48 +07:00
2025-10-14 15:50:22 +07:00
// 200 ok not found - Passed
2025-09-25 14:01:33 +07:00
public function testShowNotFound() {
$result = $this->get($this->endpoint . '/90909090');
$result->assertStatus(200);
2025-09-23 10:18:48 +07:00
$result->assertJSONFragment([
'status' => 'success',
2025-10-14 15:50:22 +07:00
"message" => "data not found."
2025-09-23 10:18:48 +07:00
]);
}
2025-10-14 15:50:22 +07:00
// 200 ok found - Passed
2025-09-25 14:01:33 +07:00
public function testShowSingleRow() {
// Pastikan DB test punya seed patient InternalPID=10 tanpa id/addr
$result = $this->get($this->endpoint . '/1');
$data = $result->getJSON(true);
$data = json_decode($data, true);
2025-09-23 10:18:48 +07:00
2025-10-14 15:50:22 +07:00
$result->assertStatus(200);
$result->assertArrayHasKey('data', $data);
$result->assertIsArray($data['data']);
// $this->assertEquals('success', $data['status']);
2025-09-23 10:18:48 +07:00
}
}