Update Unit Testing Patients
This commit is contained in:
parent
133ef55fac
commit
3e151583df
@ -10,103 +10,69 @@ class PatientCreateTest extends CIUnitTestCase
|
||||
use FeatureTestTrait;
|
||||
protected $endpoint = 'api/patient';
|
||||
|
||||
// public function testCreatePatientValidationFail()
|
||||
// {
|
||||
// // error 400 yg diharapkan
|
||||
// $payload = ['Name' => 'Ngawur'];
|
||||
// $result = $this->withBodyFormat('json')
|
||||
// ->call('post', 'api/patient', $payload);
|
||||
// $result->assertStatus(400);
|
||||
// $result->assertJSONFragment([
|
||||
// 'status' => 'error'
|
||||
// ]);
|
||||
public function testCreatePatientValidationFail()
|
||||
{
|
||||
// error 400 yg diharapkan
|
||||
$payload = ['Name' => 'Ngawur'];
|
||||
$result = $this->withBodyFormat('json')
|
||||
->call('post', 'api/patient', $payload);
|
||||
$result->assertStatus(400);
|
||||
$result->assertJSONFragment([
|
||||
'status' => 'error'
|
||||
]);
|
||||
|
||||
// // Kondisi Jika PatiD Sama
|
||||
// $payload = [
|
||||
// "PatientID"=> "SMAJ1",
|
||||
// "AlternatePID"=> "ALT001234",
|
||||
// "Prefix"=> "Mr.",
|
||||
// "NameFirst"=> "Budi",
|
||||
// "NameMiddle"=> "Santoso",
|
||||
// "NameMaiden"=> "Kiki",
|
||||
// "NameLast"=> "Wijaya",
|
||||
// "Suffix"=> "S.kom",
|
||||
// "NameAlias"=> "Bud",
|
||||
// "Gender"=> "1",
|
||||
// ];
|
||||
// $result = $this->withBodyFormat('json')
|
||||
// ->call('post', 'api/patient', $payload);
|
||||
// $result->assertStatus(400);
|
||||
// $result->assertJSONFragment([
|
||||
// 'status' => 'error',
|
||||
// "message" => "Validation failed (patient)",
|
||||
// ]);
|
||||
|
||||
// }
|
||||
|
||||
// // Wajib Diganti ya payloadnya kalau mau dijalankan
|
||||
// public function testCreateSuccess()
|
||||
// {
|
||||
// $payload = [
|
||||
// "PatientID"=> "SMAJ6", //Wajib Ganti
|
||||
// "AlternatePID"=> "P0234",
|
||||
// "Prefix"=> "Mr.",
|
||||
// "NameFirst"=> "Budi",
|
||||
// "NameMiddle"=> "Santoso",
|
||||
// "NameMaiden"=> "Kiki",
|
||||
// "NameLast"=> "Wijaya",
|
||||
// "Suffix"=> "S.kom",
|
||||
// "NameAlias"=> "Bud",
|
||||
// "Gender"=> "1",
|
||||
// 'EmailAddress1' => 'kaka@gmail.a1com', //Wajib Ganti
|
||||
// 'Identity' => [
|
||||
// "IdentifierType" => "KTP",
|
||||
// "Identifier" => "317409050590100" //Wajib Ganti
|
||||
// ]
|
||||
// ];
|
||||
|
||||
// // $result = $this->call('post', 'api/patient', $payload);
|
||||
// $result = $this->withBodyFormat('json')
|
||||
// ->call('post', 'api/patient', $payload);
|
||||
|
||||
// $result->assertStatus(201);
|
||||
// $result->assertJSONFragment([
|
||||
// 'status' => 'success',
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// dd($result);
|
||||
|
||||
public function testCreatePatientSuccess() {
|
||||
// Kondisi Jika PatiD Sama
|
||||
$payload = [
|
||||
"PatientID" => "PX004",
|
||||
"NameFirst" => "Johan",
|
||||
"NameLast" => "Doe",
|
||||
"Gender" => 1,
|
||||
"Birthdate" => "1990-01-01",
|
||||
"EmailAddress1" => "johnaa@examaple.com",
|
||||
"Identity" => [
|
||||
"PatientID"=> "SMAJ1",
|
||||
"AlternatePID"=> "ALT001234",
|
||||
"Prefix"=> "Mr.",
|
||||
"NameFirst"=> "Budi",
|
||||
"NameMiddle"=> "Santoso",
|
||||
"NameMaiden"=> "Kiki",
|
||||
"NameLast"=> "Wijaya",
|
||||
"Suffix"=> "S.kom",
|
||||
"NameAlias"=> "Bud",
|
||||
"Gender"=> "1",
|
||||
];
|
||||
$result = $this->withBodyFormat('json')
|
||||
->call('post', 'api/patient', $payload);
|
||||
$result->assertStatus(400);
|
||||
$result->assertJSONFragment([
|
||||
'status' => 'error',
|
||||
"message" => "Validation failed (patient)",
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
// Wajib Diganti ya payloadnya kalau mau dijalankan
|
||||
public function testCreatePatientSuccess()
|
||||
{
|
||||
$payload = [
|
||||
"PatientID"=> "SMAJ6", //Wajib Ganti
|
||||
"AlternatePID"=> "P0234",
|
||||
"Prefix"=> "Mr.",
|
||||
"NameFirst"=> "Budi",
|
||||
"NameMiddle"=> "Santoso",
|
||||
"NameMaiden"=> "Kiki",
|
||||
"NameLast"=> "Wijaya",
|
||||
"Suffix"=> "S.kom",
|
||||
"NameAlias"=> "Bud",
|
||||
"Gender"=> "1",
|
||||
'EmailAddress1' => 'kaka@gmail.a1com', //Wajib Ganti
|
||||
'Identity' => [
|
||||
"IdentifierType" => "KTP",
|
||||
"Identifier" => "1232457893",
|
||||
],
|
||||
"Attachments" => [
|
||||
["Address" => "Jl. Mawar No.1"]
|
||||
],
|
||||
"Comment" => "Pasien test"
|
||||
"Identifier" => "317409050590100" //Wajib Ganti
|
||||
]
|
||||
];
|
||||
|
||||
$result = $this->withBodyFormat('json')->post($this->endpoint, $payload);
|
||||
// $result = $this->call('post', 'api/patient', $payload);
|
||||
$result = $this->withBodyFormat('json')
|
||||
->call('post', 'api/patient', $payload);
|
||||
|
||||
$result->assertStatus(201);
|
||||
$result->assertJSONFragment([
|
||||
"status" => "success",
|
||||
"message" => "Patient created successfully"
|
||||
'status' => 'success',
|
||||
]);
|
||||
|
||||
|
||||
// $data = json_decode($result->getBody(), true);
|
||||
// $this->assertArrayHasKey("data", $data);
|
||||
// $this->assertIsInt($data["data"]); // InternalPID
|
||||
}
|
||||
|
||||
// public function testCreatePatientValidationError() {
|
||||
@ -254,5 +220,4 @@ class PatientCreateTest extends CIUnitTestCase
|
||||
|
||||
// $result->assertStatus(201);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ class PatientUpdateTest extends CIUnitTestCase
|
||||
{
|
||||
use FeatureTestTrait;
|
||||
|
||||
// Belon
|
||||
|
||||
// public function testUpdateFail()
|
||||
// {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user