|
|
@@ -1,91 +0,0 @@
|
|
|
-<?php
|
|
|
-
|
|
|
-
|
|
|
-namespace Tests\Inventory\Http\InventoryController;
|
|
|
-
|
|
|
-
|
|
|
-use App\Authority;
|
|
|
-use App\InventoryAccount;
|
|
|
-use App\InventoryAccountMission;
|
|
|
-use App\Owner;
|
|
|
-use App\Role;
|
|
|
-use App\User;
|
|
|
-use Illuminate\Support\Facades\DB;
|
|
|
-use Tests\TestCase;
|
|
|
-
|
|
|
-class InventoryControllerStockInventoryMissionTestTest extends TestCase
|
|
|
-{
|
|
|
- public $response=null;
|
|
|
- public $role;
|
|
|
- public $user;
|
|
|
- public $inventory;
|
|
|
- public $inventoryMissions;
|
|
|
- function setUp(): void
|
|
|
- {
|
|
|
- parent::setUp(); // TODO: Change the autogenerated stub
|
|
|
- if(!$this->user){
|
|
|
- $this->user = factory(User::class)->create();
|
|
|
- $this->role= Role::firstOrCreate([
|
|
|
- 'name'=>'testRole',
|
|
|
- ]);
|
|
|
- $this->assertNotEmpty($this->role->id);
|
|
|
- $authority= Authority::where('name','库存管理-盘点')->first();
|
|
|
- DB::table('authority_role')->insert(['id_authority'=>$authority->id,'id_role'=>$this->role->id]);
|
|
|
- DB::table('user_role')->insert(['id_user'=>$this->user->id,'id_role'=>$this->role->id]);
|
|
|
- $this->inventory=factory(InventoryAccount::class)->create();
|
|
|
- $this->inventoryMissions=InventoryAccountMission::create([
|
|
|
- 'inventory_account_id'=>$this->inventory['id'],
|
|
|
- 'location'=>'A12-10-01',
|
|
|
- 'commodity_id'=>256226,
|
|
|
- 'produced_at'=>null,
|
|
|
- 'valid_at'=>null,
|
|
|
- 'stored_at'=>null,
|
|
|
- 'batch_number'=>'',
|
|
|
- 'erp_type_position'=>'',
|
|
|
- 'quality'=>'',
|
|
|
- 'stored_amount'=>50,
|
|
|
- 'valid_amount'=>'',
|
|
|
- 'verified_amount'=>'',
|
|
|
- 're_checked_amount'=>'',
|
|
|
- 'difference_amount'=>'',
|
|
|
- 'occupied_amount'=>'',
|
|
|
- 'checked'=>'否',
|
|
|
- 'returned'=>'无',
|
|
|
- ]);
|
|
|
- }
|
|
|
- $this->response=$this->actingAs($this->user)->json('post','http://bswas/inventory/stockInventory',
|
|
|
- [ 'location'=>'A12-10-01',
|
|
|
- 'barcode'=>'9787511715364',
|
|
|
- 'count'=>50,
|
|
|
- 'inventoryId'=>$this->inventory['id'],
|
|
|
- ]);
|
|
|
- }
|
|
|
- function testStockInventoryNotHavingException(){
|
|
|
- $this->response->assertDontSee('Exception');
|
|
|
- }
|
|
|
-// function testStockInventoryFailJson(){
|
|
|
-// $this->response->assertJson([
|
|
|
-// 'success'=>false,
|
|
|
-// 'data'=>'盘点数不能为空!',
|
|
|
-// ]);
|
|
|
-// }
|
|
|
- function testStockInventorySuccessJson(){
|
|
|
- $this->response->assertJson([
|
|
|
- 'success'=>true,
|
|
|
- 'inventoryMission'=>$this->response->json()['inventoryMission'],
|
|
|
- 'inventory'=>$this->response->json()['inventory'],
|
|
|
- ]);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- function tearDown(): void
|
|
|
- {
|
|
|
- DB::table('user_role')->where('id_role',$this->role['id'])->delete();
|
|
|
- DB::table('authority_role')->where('id_role',$this->role['id'])->delete();
|
|
|
- User::where('id',$this->user['id'])->delete();
|
|
|
- Role::where('id',$this->role['id'])->delete();
|
|
|
- InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->delete();
|
|
|
- InventoryAccount::where('id',$this->inventory['id'])->forceDelete();
|
|
|
- parent::tearDown(); // TODO: Change the autogenerated stub
|
|
|
- }
|
|
|
-}
|