From 8c8c66572c76a22c470fdcfcf96460054a912dd7 Mon Sep 17 00:00:00 2001 From: Zain Fauzan Rofie Azizi Date: Wed, 23 May 2018 09:41:53 +0800 Subject: [PATCH] added testing for shipping order and shipping order item --- app/Http/Controllers/SoController.php | 16 +-- tests/Unit/ShippingorderTest.php | 188 +++++++++++++------------- 2 files changed, 97 insertions(+), 107 deletions(-) diff --git a/app/Http/Controllers/SoController.php b/app/Http/Controllers/SoController.php index f5e2495..1a6528f 100644 --- a/app/Http/Controllers/SoController.php +++ b/app/Http/Controllers/SoController.php @@ -50,25 +50,21 @@ class SoController extends Controller */ //post shipping order amd item public function store(Request $request) - { - + { + //shipping order $so = new So; - $so->ff_id = $request->input('ff_id'); $so->supplier_company_name = $request->input('supplier_company_name'); $so->supplier_contact_person = $request->input('supplier_contact_person'); $so->supplier_contact_person_no = $request->input('supplier_contact_person_no'); $so->delivery_id = $request->input('delivery_id'); $so->warehouse_id = $request->input('warehouse_id'); - $so->save(); - - //shipping order item - $soitems = $request->input("soitem"); - - foreach ($soitems as $soitem) + //shipping order item + $soitems = $request->input("soitem"); + foreach ($soitems as $soitem) { $new_soitem = new Soitem(array( 'so_id'=>$soitem['so_id'], @@ -87,7 +83,7 @@ class SoController extends Controller 'packaging_gross'=>$soitem['packaging_gross'], 'packaging_nett'=>$soitem['packaging_nett'], )); - $new_soitem->save(); + $new_soitem->save(); } diff --git a/tests/Unit/ShippingorderTest.php b/tests/Unit/ShippingorderTest.php index 1b623ae..60219ab 100644 --- a/tests/Unit/ShippingorderTest.php +++ b/tests/Unit/ShippingorderTest.php @@ -27,124 +27,118 @@ class ShippingorderTest extends TestCase $response->assertStatus(200); } - // public function testPOSTso() - // { - // $response = $this->json('POST', '/api/so/{so_id}', [ - - // 'id' => '1', - // 'ff_id' => '1', - // 'supplier_company_name' => 'Testing', - // 'supplier_contact_person' => 'Testing', - // 'supplier_contact_person_no' => '1234', - // 'delivery_id' => '1', - // 'warehouse_id' => '1', - - // ]); - - // $response->assertStatus(201); - // } - - public function testPOSTsoITEM() + public function testPOSTso() { - $response = $this->json('POST', '/api/so/soitem/{so_id}', - - [ - 'so_id' => '2', - 'status' => '1', - 'order_id' => '2', - 'brand_no' => '2', - 'model_no' => '2', - 'item_code' => '2', - 'quantity_of_item' => '2', - 'uom' => 'test', - 'quantity_of_carton' => '2', - 'packaging_type' => 'Testing', - 'packaging_height' => '123', - 'packaging_width' => '123', - 'packaging_depth' => '123', - 'packaging_gross' => '123', - 'packaging_nett' => '123', - ], + $response = $this->json('POST', '/api/so', [ - 'so_id' => '2', - 'status' => '1', - 'order_id' => '2', - 'brand_no' => '2', - 'model_no' => '2', - 'item_code' => '2', - 'quantity_of_item' => '2', - 'uom' => 'test', - 'quantity_of_carton' => '2', - 'packaging_type' => 'Testing', - 'packaging_height' => '123', - 'packaging_width' => '123', - 'packaging_depth' => '123', - 'packaging_gross' => '123', - 'packaging_nett' => '123', - ]); + 'id' => '3', + 'ff_id' => '3', + 'supplier_company_name' => 'Testing', + 'supplier_contact_person' => 'Testing', + 'supplier_contact_person_no' => '1234', + 'delivery_id' => '3', + 'warehouse_id' => '3', + + 'soitem' => [ + 0 => [ + 'so_id' => '3', + 'status' => '1', + 'order_id' => '3', + 'brand_no' => '3', + 'model_no' => '3', + 'item_code' => '3', + 'quantity_of_item' => '3', + 'uom' => 'test', + 'quantity_of_carton' => '3', + 'packaging_type' => 'Testing', + 'packaging_height' => '123', + 'packaging_width' => '123', + 'packaging_depth' => '123', + 'packaging_gross' => '123', + 'packaging_nett' => '123', + ], + 1 => [ + 'so_id' => '2', + 'status' => '1', + 'order_id' => '2', + 'brand_no' => '2', + 'model_no' => '2', + 'item_code' => '2', + 'quantity_of_item' => '2', + 'uom' => 'test', + 'quantity_of_carton' => '2', + 'packaging_type' => 'Testing', + 'packaging_height' => '123', + 'packaging_width' => '123', + 'packaging_depth' => '123', + 'packaging_gross' => '123', + 'packaging_nett' => '123', + ] + ] + ]); $response->assertStatus(201); } - // public function testDELETEso() - // { - // $response = $this->json('DELETE', '/api/so/8'); + public function testDELETEso() + { + $response = $this->json('DELETE', '/api/so/8'); - // $response->assertStatus(204); - // } + $response->assertStatus(204); + } - // public function testDELETEsoitem() - // { - // $response = $this->json('DELETE', '/api/so/soitem/3'); + public function testDELETEsoitem() + { + $response = $this->json('DELETE', '/api/so/soitem/3'); - // $response->assertStatus(204); - // } + $response->assertStatus(204); + } - // public function testPUTso() - // { + public function testPUTso() + { - // $response = $this->json('PUT', '/api/so/2', [ + $response = $this->json('PUT', '/api/so/2', [ - // 'id' => '1', - // 'ff_id' => '1', - // 'supplier_company_name' => 'Testinggggggggggggggggggggg', - // 'supplier_contact_person' => 'Testing', - // 'supplier_contact_person_no' => '1234', - // 'delivery_id' => '1', - // 'warehouse_id' => '1', + 'id' => '1', + 'ff_id' => '1', + 'supplier_company_name' => 'Testinggggggggggggggggggggg', + 'supplier_contact_person' => 'Testing', + 'supplier_contact_person_no' => '1234', + 'delivery_id' => '1', + 'warehouse_id' => '1', - // ]); + ]); - // $response->assertStatus(200); - // } + $response->assertStatus(200); + } - // public function testPUTsoitem() - // { + public function testPUTsoitem() + { - // $response = $this->json('PUT', '/api/so/soitem/1', [ + $response = $this->json('PUT', '/api/so/soitem/1', [ - // 'so_id' => '2', - // 'status' => '1', - // 'order_id' => '2', - // 'brand_no' => '2', - // 'model_no' => '2', - // 'item_code' => '2', - // 'quantity_of_item' => '2', - // 'uom' => 'test', - // 'quantity_of_carton' => '2', - // 'packaging_type' => 'Testinggggggggggggggggggg', - // 'packaging_height' => '123', - // 'packaging_width' => '123', - // 'packaging_depth' => '123', - // 'packaging_gross' => '123', - // 'packaging_nett' => '123', + 'so_id' => '2', + 'status' => '1', + 'order_id' => '2', + 'brand_no' => '2', + 'model_no' => '2', + 'item_code' => '2', + 'quantity_of_item' => '2', + 'uom' => 'test', + 'quantity_of_carton' => '2', + 'packaging_type' => 'Testinggggggggggggggggggg', + 'packaging_height' => '123', + 'packaging_width' => '123', + 'packaging_depth' => '123', + 'packaging_gross' => '123', + 'packaging_nett' => '123', - // ]); + ]); - // $response->assertStatus(200); - // } + $response->assertStatus(200); + } }