diff --git a/app/So.php b/app/So.php index eeaec8a..9313dea 100644 --- a/app/So.php +++ b/app/So.php @@ -23,6 +23,6 @@ class So extends Model { return $this->hasMany('App\Warehousearr'); } - + } diff --git a/database/factories/SoFactory.php b/database/factories/SoFactory.php index ef461df..f48e068 100644 --- a/database/factories/SoFactory.php +++ b/database/factories/SoFactory.php @@ -12,14 +12,50 @@ use Faker\Generator as Faker; | model instances for testing / seeding your application's database. | */ -// Manually creating the relationship tree. + $factory->define(App\So::class, function (Faker $faker) { return [ - 'ff_id'=>'testing', + 'ff_id'=>'1', 'supplier_company_name'=>'testing', 'supplier_contact_person'=>'testing', - 'supplier_contact_person_no'=>'12345', - 'delivery_id'=>'12345', - 'warehouse_id'=>'testing', - ]; + 'supplier_contact_person_no'=>'1', + 'delivery_id'=>'1', + 'warehouse_id'=>'1', + 'soitem' => [ + 0 => [ + 'so_id'=> '1', + 'status'=> '1', + 'order_id'=> '1', + 'brand_no'=> '1', + 'model_no'=> '1', + 'item_code'=> '1', + 'quantity_of_item'=> '1', + 'uom'=> 'testing', + 'quantity_of_carton'=> '1', + 'packaging_type'=> 'testing', + 'packaging_height'=> '1', + 'packaging_width'=> '1', + 'packaging_depth'=> '1', + 'packaging_gross'=> '1', + 'packaging_nett'=> '1', + ], + 1 => [ + 'so_id'=> '1', + 'status'=> '1', + 'order_id'=> '1', + 'brand_no'=> '1', + 'model_no'=> '1', + 'item_code'=> '1', + 'quantity_of_item'=> '1', + 'uom'=> 'testing', + 'quantity_of_carton'=> '1', + 'packaging_type'=> 'testing', + 'packaging_height'=> '1', + 'packaging_width'=> '1', + 'packaging_depth'=> '1', + 'packaging_gross'=> '1', + 'packaging_nett'=> '1', + ] + ] + ]; }); diff --git a/database/factories/WarehousearrFactory.php b/database/factories/WarehousearrFactory.php new file mode 100644 index 0000000..8d7c8a5 --- /dev/null +++ b/database/factories/WarehousearrFactory.php @@ -0,0 +1,62 @@ +define(App\Warehousearr::class, function (Faker $faker) { + return [ + + 'so_id'=> function () { + + return factory(App\So::class)->create()->id; + + }, + 'receive_on'=> '2018-03-01', + 'transport_company_name'=> 'testing', + 'consignment_note_no'=> '1', + 'warehouse_receive_note_no'=> '1', + 'receiving_person'=> 'testing', + 'marking_number'=> '1', + 'image'=> 'testing.jpg', + 'warehouseitem' => [ + 0 => [ + 'description'=> 'testing', + 'nominal_ctn'=> '1', + 'actual_ctn'=> '1', + 'nominal_measurement'=> '1', + 'actual_measurement'=> '1', + 'nominal_weight'=> '1', + 'actual_weight'=> '1', + 'balance'=> '1', + 'isDamaged'=> '1', + 'status'=> 'testing', + 'image'=> 'testing.jpg', + 'wa_id'=> '1', + ], + 1 => [ + 'description'=> 'testing', + 'nominal_ctn'=> '1', + 'actual_ctn'=> '1', + 'nominal_measurement'=> '1', + 'actual_measurement'=> '1', + 'nominal_weight'=> '1', + 'actual_weight'=> '1', + 'balance'=> '2', + 'isDamaged'=> '1', + 'status'=> 'testing', + 'image'=> 'testing.jpg', + 'wa_id'=> '1', + ] + ] + ]; +}); diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 1785f6c..b2b7592 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -13,7 +13,9 @@ class DatabaseSeeder extends Seeder { $this->call(LaratrustSeeder::class); $this->call(UsersTableSeeder::class); - //$this->call(UsersTableSeeder::class); - $this->call(SoSeeder::class); + $this->call(SoSeeder::class); + $this->call(SoitemSeeder::class); + $this->call(WarehousearrSeeder::class); + $this->call(WarehouseitemSeeder::class); } } diff --git a/database/seeds/SoSeeder.php b/database/seeds/SoSeeder.php index 5118d7f..3418370 100644 --- a/database/seeds/SoSeeder.php +++ b/database/seeds/SoSeeder.php @@ -14,7 +14,8 @@ class SoSeeder extends Seeder public function run() { DB::table('sos')->insert([ - + + 'id' => '99', 'ff_id' => '1', 'supplier_company_name' => 'SEED', 'supplier_contact_person' => 'SEED', diff --git a/database/seeds/SoitemSeeder.php b/database/seeds/SoitemSeeder.php index c865d1e..7321f91 100644 --- a/database/seeds/SoitemSeeder.php +++ b/database/seeds/SoitemSeeder.php @@ -18,9 +18,8 @@ class SoitemSeeder extends Seeder ([ - - 'so_id' => '3', - 'status' => '0', + 'so_id' => '99', + 'status' => '1', 'order_id' => '1', 'brand_no' => '1', 'model_no' => '1', @@ -39,8 +38,8 @@ class SoitemSeeder extends Seeder ]), ([ - // 'id' => '8', - 'so_id' => '3', + + 'so_id' => '99', 'status' => '0', 'order_id' => '1', 'brand_no' => '1', diff --git a/database/seeds/WarehousearrSeeder.php b/database/seeds/WarehousearrSeeder.php new file mode 100644 index 0000000..1ff9023 --- /dev/null +++ b/database/seeds/WarehousearrSeeder.php @@ -0,0 +1,31 @@ +insert([ + + 'so_id' => '99', + 'receive_on'=> Carbon::now()->format('Y-m-d H:i:s'), + 'transport_company_name'=> 'TEScief', + 'consignment_note_no'=> '1', + 'warehouse_receive_note_no'=> '1', + 'receiving_person'=> 'TEST', + 'marking_number'=> '1', + 'image'=> 'test.jpg', + 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), + 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'), + + ]); + } +} diff --git a/database/seeds/WarehouseitemSeeder.php b/database/seeds/WarehouseitemSeeder.php new file mode 100644 index 0000000..ac34d3a --- /dev/null +++ b/database/seeds/WarehouseitemSeeder.php @@ -0,0 +1,57 @@ +insert([ + + ([ + + 'description'=> 'CIEFhuhuuh', + 'nominal_ctn'=> '1', + 'actual_ctn'=> '1', + 'nominal_measurement'=> '1', + 'actual_measurement'=> '1', + 'nominal_weight'=> '1', + 'actual_weight'=> '1', + 'balance'=> '2', + 'isDamaged'=> '1', + 'status'=> 'ok', + 'image'=> 'test.jpg', + 'wa_id'=> '1', + 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), + 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'), + + ]), + ([ + + 'description'=> 'CIEFhuhuuh', + 'nominal_ctn'=> '1', + 'actual_ctn'=> '1', + 'nominal_measurement'=> '1', + 'actual_measurement'=> '1', + 'nominal_weight'=> '1', + 'actual_weight'=> '1', + 'balance'=> '2', + 'isDamaged'=> '1', + 'status'=> 'ok', + 'image'=> 'test.jpg', + 'wa_id'=> '1', + 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), + 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'), + ]), + + ]); + } +} diff --git a/tests/Unit/ShippingorderTest.php b/tests/Unit/ShippingorderTest.php index dadcac0..cef6731 100644 --- a/tests/Unit/ShippingorderTest.php +++ b/tests/Unit/ShippingorderTest.php @@ -8,6 +8,14 @@ use Illuminate\Foundation\Testing\RefreshDatabase; class ShippingorderTest extends TestCase { + + public function setUp() + { + parent::setUp(); + Artisan::call('db:seed'); + + } + /** * A basic test example. * @@ -27,68 +35,14 @@ class ShippingorderTest extends TestCase $response->assertStatus(200); } - public function testPOSTso() - { - $response = $this->json('POST', '/api/so', - - [ - 'id' => '1', - 'ff_id' => '1', - 'supplier_company_name' => 'Testing', - 'supplier_contact_person' => 'Testing', - 'supplier_contact_person_no' => '1234', - 'delivery_id' => '1', - 'warehouse_id' => '1', - - 'soitem' => [ - 0 => [ - 'so_id' => '1', - 'status' => '1', - 'order_id' => '1', - 'brand_no' => '1', - 'model_no' => '1', - 'item_code' => '1', - 'quantity_of_item' => '1', - 'uom' => 'test', - 'quantity_of_carton' => '1', - 'packaging_type' => 'Testing', - 'packaging_height' => '123', - 'packaging_width' => '123', - 'packaging_depth' => '123', - 'packaging_gross' => '123', - 'packaging_nett' => '123', - ], - 1 => [ - 'so_id' => '1', - 'status' => '1', - 'order_id' => '1', - 'brand_no' => '1', - 'model_no' => '1', - 'item_code' => '1', - 'quantity_of_item' => '1', - 'uom' => 'test', - 'quantity_of_carton' => '1', - 'packaging_type' => 'Testing', - 'packaging_height' => '123', - 'packaging_width' => '123', - 'packaging_depth' => '123', - 'packaging_gross' => '123', - 'packaging_nett' => '123', - ] - ] - ]); - - $response->assertStatus(201); - } - - public function testDELETEso() + public function testDELETEso() { $response = $this->json('DELETE', '/api/so/8'); $response->assertStatus(204); } - public function testDELETEsoitem() + public function testDELETEsoitem() { $response = $this->json('DELETE', '/api/so/soitem/3'); @@ -98,43 +52,34 @@ class ShippingorderTest extends TestCase public function testPUTso() { - $response = $this->json('PUT', '/api/so/2', [ 'id' => '1', 'ff_id' => '1', - 'supplier_company_name' => 'Testinggggggggggggggggggggg', + 'supplier_company_name' => 'Testing', 'supplier_contact_person' => 'Testing', 'supplier_contact_person_no' => '1234', 'delivery_id' => '1', 'warehouse_id' => '1', - - ]); - - $response->assertStatus(200); - } - - public function testPUTsoitem() - { - - - $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', + 'soitem' => [ + 0 => [ + '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', + ], + ] ]); diff --git a/tests/Unit/WarehouseReceiveNoteTest.php b/tests/Unit/WarehouseReceiveNoteTest.php index ee2dd13..be57f41 100644 --- a/tests/Unit/WarehouseReceiveNoteTest.php +++ b/tests/Unit/WarehouseReceiveNoteTest.php @@ -14,28 +14,24 @@ use Artisan; class WarehouseReceiveNoteTest extends TestCase { - /** - * A basic test example. - * - * @return void - */ - // public function testGET() - // { - // $response = $this->json('GET', '/api/warehousearr'); + - // $response->assertStatus(200); - - // } - - public function testPOST() + public function setUp() { - $response = $this->json('POST', '/api/warehousearr', + parent::setUp(); + Artisan::call('db:seed'); + + } + + public function testPUT() + { + $response = $this->json('PUT', '/api/warehousearr/1', [ - 'so_id'=> '3', - 'receive_on'=> '2018-03-01', - 'transport_company_name'=> 'TEScief', + 'so_id'=> '99', + 'receive_on'=> '2018-06-04', + 'transport_company_name'=> 'TESTTESTabc', 'consignment_note_no'=> '3', 'warehouse_receive_note_no'=> '3', 'receiving_person'=> 'TEST', @@ -43,7 +39,7 @@ class WarehouseReceiveNoteTest extends TestCase 'image'=> 'test.jpg', 'warehouseitem' => [ 0 => [ - 'description'=> 'CIEFhuhuuh', + 'description'=> 'TESTTESTabctest', 'nominal_ctn'=> '1', 'actual_ctn'=> '1', 'nominal_measurement'=> '1', @@ -54,90 +50,34 @@ class WarehouseReceiveNoteTest extends TestCase 'isDamaged'=> '1', 'status'=> 'ok', 'image'=> 'test.jpg', - 'wa_id'=> '11', ], - 1 => [ - 'description'=> 'CIE', - 'nominal_ctn'=> '1', - 'actual_ctn'=> '1', - 'nominal_measurement'=> '1', - 'actual_measurement'=> '1', - 'nominal_weight'=> '1', - 'actual_weight'=> '1', - 'balance'=> '2', - 'isDamaged'=> '1', - 'status'=> 'ok', - 'image'=> 'test.jpg', - 'wa_id'=> '11', - ] ] ]); - // dd($response->getContent()); - $response->assertStatus(201); - + $response->assertStatus(201); + } - // public function testPUT() - // { - // $response = $this->json('PUT', '/api/warehousearr/30', + public function testUploadWarehouseImage() + { + Storage::fake('warehouse_picture'); - // [ + $response = $this->json('POST', '/api/warehousearr/warehouse_picture/1', [ + 'warehouse_picture' => UploadedFile::fake()->image('test.jpg') + ]); + + $response->assertStatus(201); + } - // 'so_id'=> '3', - // 'receive_on'=> '2018-03-01', - // 'transport_company_name'=> 'TEScief', - // 'consignment_note_no'=> '3', - // 'warehouse_receive_note_no'=> '3', - // 'receiving_person'=> 'TEST', - // 'marking_number'=> '3', - // 'image'=> 'test.jpg', - // 'warehouseitem' => [ - // 0 => [ - // 'description'=> 'CIEFhuhuuh', - // 'nominal_ctn'=> '1', - // 'actual_ctn'=> '1', - // 'nominal_measurement'=> '1', - // 'actual_measurement'=> '1', - // 'nominal_weight'=> '1', - // 'actual_weight'=> '1', - // 'balance'=> '2', - // 'isDamaged'=> '1', - // 'status'=> 'ok', - // 'image'=> 'test.jpg', - // 'wa_id'=> '4', - // 'soitem_id'=> '4' - // ], - // ] - // ]); - - // // dd($response->getContent()); - // $response->assertStatus(201); - - // } - - // public function testUploadWarehouseImage() - // { - // Storage::fake('warehouse_picture'); + public function testUploadWarehouseItemImage() + { + Storage::fake('warehouse_item_picture'); - // $response = $this->actingAs($this->user) - // ->json('POST', '/warehousearr/warehouse_picture/1', [ - // 'warehouse_picture' => UploadedFile::fake()->image('test.jpg') - // ]); - // // dd($response->getContent()); - // $response->assertStatus(201); - // } - - // public function testUploadWarehouseItemImage() - // { - // Storage::fake('warehouse_picture'); - - // $response = $this->actingAs($this->user) - // ->json('POST', '/warehousearr/warehouse_item_picture/1', [ - // 'warehouse_item_picture' => UploadedFile::fake()->image('test.jpg') - // ]); - // // dd($response->getContent()); - // $response->assertStatus(201); - // } + $response = $this->json('POST', '/api/warehousearr/warehouse_item_picture/1', [ + 'warehouse_item_picture' => UploadedFile::fake()->image('test.jpg') + ]); + + $response->assertStatus(201); + } } \ No newline at end of file