| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace Tests\Inventory\Services\InventoryAccountService;
- use App\Commodity;
- use App\CommodityBarcode;
- use App\InventoryAccount;
- use App\InventoryAccountMission;
- use App\Services\InventoryAccountService;
- use Tests\TestCase;
- class InventoryServiceStockInventoryTest extends TestCase
- {
- public $inventory;
- public $inventoryMission;
- public $commodity;
- public $commodityBarcode;
- function setUp(): void
- {
- parent::setUp(); // TODO: Change the autogenerated stub
- $this->commodity=Commodity::create([
- 'name'=>'如意精箍棒',
- 'sku'=>'525252525252525',
- 'owner'=>3,
- ]);
- $this->commodityBarcode=CommodityBarcode::create([
- 'code'=>'89898989',
- 'commodity_id'=>$this->commodity['id'],
- ]);
- $this->inventory=factory(InventoryAccount::class)->create();
- $this->inventoryMission=InventoryAccountMission::create([
- 'inventory_account_id'=>$this->inventory['id'],
- 'location'=>'A21-02-02',
- 'commodity_id'=>$this->commodity['id'],
- 'produced_at'=>null,
- 'valid_at'=>null,
- 'stored_at'=>null,
- 'batch_number'=>'',
- 'erp_type_position'=>'',
- 'quality'=>'',
- 'stored_amount'=>50,
- 'valid_amount'=>'',
- 'verified_amount'=>null,
- 're_checked_amount'=>'',
- 'difference_amount'=>null,
- 'occupied_amount'=>'',
- 'checked'=>'否',
- 'returned'=>'无',
- ]);
- }
- function testStockInventoryNoDifferenceAndStockSuccess(){
- $inventoryService=new InventoryAccountService();
- $inventoryMission=$inventoryService->stockInventory('A21-02-02','89898989','50',$this->inventory['id']);
- $this->assertEquals('是',$inventoryMission['checked']);
- $this->assertEquals(0,$inventoryMission['difference_amount']);
- $this->assertEquals(50,$inventoryMission['verified_amount']);
- }
- function tearDown(): void
- {
- CommodityBarcode::where('commodity_id',$this->commodity['id'])->delete();
- Commodity::where('id',$this->commodity['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
- }
- }
|