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