InventoryAccountTest.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace Tests\Inventory\model;
  3. use App\InventoryAccount;
  4. use App\InventoryAccountMission;
  5. use Illuminate\Support\Str;
  6. use Tests\TestCase;
  7. class InventoryAccountTest extends TestCase
  8. {
  9. public $inventory;
  10. public $inventoryMission;
  11. function setUp(): void
  12. {
  13. parent::setUp(); // TODO: Change the autogenerated stub
  14. $this->inventory=factory(InventoryAccount::class)->create();
  15. $this->inventoryMission=InventoryAccountMission::create([
  16. 'inventory_account_id'=>$this->inventory['id'],
  17. 'location'=>Str::random(5),
  18. 'commodity_id'=>256226,
  19. 'produced_at'=>null,
  20. 'valid_at'=>null,
  21. 'stored_at'=>null,
  22. 'batch_number'=>'',
  23. 'erp_type_position'=>'',
  24. 'quality'=>'',
  25. 'stored_amount'=>50,
  26. 'valid_amount'=>'',
  27. 'verified_amount'=>'',
  28. 're_checked_amount'=>'',
  29. 'difference_amount'=>'',
  30. 'occupied_amount'=>'',
  31. 'checked'=>'否',
  32. 'returned'=>'无',
  33. ]);
  34. }
  35. function testOwner(){
  36. $this->assertEquals($this->inventory['owner_id'],$this->inventory->owner['id']);
  37. }
  38. function testInventoryMissions(){
  39. $this->assertEquals($this->inventory->id,$this->inventoryMission['inventory_account_id']);
  40. }
  41. function testGetSurplusAttribute(){
  42. $surplus=$this->inventory['surplus'];
  43. $this->assertEquals($surplus,$this->inventory['total']-$this->inventory['processed']);
  44. }
  45. function tearDown(): void
  46. {
  47. InventoryAccountMission::where('inventory_account_id',$this->inventory['id'])->delete();
  48. InventoryAccount::where('id',$this->inventory['id'])->forceDelete();
  49. parent::tearDown(); // TODO: Change the autogenerated stub
  50. }
  51. }