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

39 lines
1010 B
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-09-25 14:01:33 +07:00
// 200 ok not found
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-09-25 14:01:33 +07:00
"message" => "Patient with ID 90909090 not found.",
2025-09-23 10:18:48 +07:00
'data' => []
]);
}
2025-09-25 14:01:33 +07:00
// 200 ok
public function testShowSingleRow() {
// Pastikan DB test punya seed patient InternalPID=10 tanpa id/addr
$result = $this->get($this->endpoint . '/1');
2025-09-23 10:18:48 +07:00
$result->assertStatus(200);
2025-09-25 14:01:33 +07:00
$data = $result->getJSON(true);
$data = json_decode($data, true);
2025-09-23 10:18:48 +07:00
$this->assertEquals('success', $data['status']);
2025-09-25 14:01:33 +07:00
// $this->assertNull($data['data']['Attachments']);
2025-09-23 10:18:48 +07:00
}
}