Re-synced controllers, configs, libraries, seeds, and docs with the latest API expectations and response helpers.
90 lines
2.7 KiB
PHP
Executable File
90 lines
2.7 KiB
PHP
Executable File
<?php
|
|
|
|
namespace Tests\Feature\Patients;
|
|
|
|
use CodeIgniter\Test\FeatureTestTrait;
|
|
use CodeIgniter\Test\CIUnitTestCase;
|
|
|
|
class PatientShowTest extends CIUnitTestCase
|
|
{
|
|
use FeatureTestTrait;
|
|
|
|
protected $endpoint = 'api/patient';
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
}
|
|
|
|
// 200 ok found - Passed
|
|
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);
|
|
|
|
$result->assertStatus(200);
|
|
$result->assertArrayHasKey('data', $data);
|
|
$result->assertIsArray($data['data']);
|
|
}
|
|
|
|
// 200 ok - Test validasi respons selalu sukses - Passed
|
|
public function testShowAlwaysReturnSuccessStatus() {
|
|
$result = $this->get($this->endpoint . '/99999');
|
|
$result->assertJSONFragment(['status' => 'success']);
|
|
}
|
|
|
|
// 200 ok not found - Passed
|
|
public function testShowNotFound() {
|
|
$result = $this->get($this->endpoint . '/90909090');
|
|
$result->assertStatus(200);
|
|
$result->assertJSONFragment([
|
|
'status' => 'success',
|
|
"message" => "data not found."
|
|
]);
|
|
}
|
|
|
|
// 200 ok found - PatIdt null - Passed
|
|
public function testShowWithNullPatIdt() {
|
|
$result = $this->get($this->endpoint . '/2');
|
|
$data = $result->getJSON();
|
|
$data = json_decode($data, true);
|
|
|
|
$result->assertStatus(200);
|
|
$this->assertNull($data['data']['PatIdt']);
|
|
}
|
|
|
|
// 200 ok found - PatAtt null - Passed
|
|
public function testShowWithNullPatAtt() {
|
|
$result = $this->get($this->endpoint . '/2');
|
|
$data = $result->getJSON();
|
|
$data = json_decode($data, true);
|
|
|
|
$result->assertStatus(200);
|
|
$this->assertNull($data['data']['PatAtt']);
|
|
}
|
|
|
|
// 200 ok found - PatCom null - Passed
|
|
public function testShowWithNullPatCom() {
|
|
$result = $this->get($this->endpoint . '/2');
|
|
$data = $result->getJSON();
|
|
$data = json_decode($data, true);
|
|
|
|
$result->assertStatus(200);
|
|
$this->assertNull($data['data']['PatCom']);
|
|
}
|
|
|
|
// 200 ok found - PatAtt greater dan 1 - Passed
|
|
public function testShowWithMultipleAddresses() {
|
|
$result = $this->get($this->endpoint . '/1');
|
|
$data = $result->getJSON();
|
|
$data = json_decode($data, true);
|
|
|
|
$result->assertStatus(200);
|
|
$this->assertIsArray($data['data']['PatAtt']);
|
|
$this->assertGreaterThanOrEqual(1, count($data['data']['PatAtt']));
|
|
}
|
|
|
|
}
|