InventoryAccountService_StockInventoryTest.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace Tests\Inventory\Services\InventoryAccountService;
  3. use App\Commodity;
  4. use App\CommodityBarcode;
  5. use App\InventoryAccount;
  6. use App\InventoryAccountMission;
  7. use App\Services\InventoryAccountService;
  8. use Tests\TestCase;
  9. class InventoryServiceStockInventoryTest extends TestCase
  10. {
  11. public $inventory;
  12. public $inventoryMission;
  13. public $commodity;
  14. public $commodityBarcode;
  15. function setUp(): void
  16. {
  17. parent::setUp(); // TODO: Change the autogenerated stub
  18. $this->commodity=Commodity::create([
  19. 'name'=>'如意精箍棒',
  20. 'sku'=>'525252525252525',
  21. 'owner'=>3,
  22. ]);
  23. $this->commodityBarcode=CommodityBarcode::create([
  24. 'code'=>'89898989',
  25. 'commodity_id'=>$this->commodity['id'],
  26. ]);
  27. $this->inventory=factory(InventoryAccount::class)->create();
  28. $this->inventoryMission=InventoryAccountMission::create([
  29. 'inventory_account_id'=>$this->inventory['id'],
  30. 'location'=>'A21-02-02',
  31. 'commodity_id'=>$this->commodity['id'],
  32. 'produced_at'=>null,
  33. 'valid_at'=>null,
  34. 'stored_at'=>null,
  35. 'batch_number'=>'',
  36. 'erp_type_position'=>'',
  37. 'quality'=>'',
  38. 'stored_amount'=>50,
  39. 'valid_amount'=>'',
  40. 'verified_amount'=>null,
  41. 're_checked_amount'=>'',
  42. 'difference_amount'=>null,
  43. 'occupied_amount'=>'',
  44. 'checked'=>'否',
  45. 'returned'=>'无',
  46. ]);
  47. }
  48. function testStockInventoryNoDifferenceAndStockSuccess(){
  49. $inventoryService=new InventoryAccountService();
  50. $inventoryMission=$inventoryService->stockInventory('A21-02-02','89898989','50',$this->inventory['id']);
  51. $this->assertEquals('是',$inventoryMission['checked']);
  52. $this->assertEquals(0,$inventoryMission['difference_amount']);
  53. $this->assertEquals(50,$inventoryMission['verified_amount']);
  54. }
  55. function tearDown(): void
  56. {
  57. CommodityBarcode::where('commodity_id',$this->commodity['id'])->delete();
  58. Commodity::where('id',$this->commodity['id'])->delete();
  59. InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->delete();
  60. InventoryAccount::where('id',$this->inventory['id'])->forceDelete();
  61. parent::tearDown(); // TODO: Change the autogenerated stub
  62. }
  63. }