CreateByBatchesTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace Tests\Services\StationTaskMaterialBoxService;
  3. use App\Batch;
  4. use App\Order;
  5. use App\OrderCommodity;
  6. use App\Services\StationTaskMaterialBoxService;
  7. use Tests\TestCase;
  8. use App\StationTaskMaterialBox;
  9. use App\Traits\TestMockSubServices;
  10. class CreateByBatchesTest extends TestCase
  11. {
  12. use TestMockSubServices;
  13. /** @var StationTaskMaterialBoxService $service */
  14. public $service;
  15. private $data;
  16. private $batchAmount=2;
  17. private $orderAmount=2;
  18. private $materialBoxAmount=2;
  19. function setUp(): void
  20. {
  21. parent::setUp();
  22. $this->service = app('StationTaskMaterialBoxService');
  23. $this->data['batches']
  24. = factory(Batch::class, $this->batchAmount)
  25. ->create();
  26. $this->data['orders']
  27. = factory(Order::class, $this->orderAmount)
  28. ->create([
  29. 'batch_id'=>$this->getTargetIdCirculately($this->data['batches'])
  30. ]);
  31. $this->data['materialBoxes']
  32. = factory(StationTaskMaterialBox::class, $this->materialBoxAmount)
  33. ->create();
  34. $this->data['orderCommodities']
  35. = factory(OrderCommodity::class, $this->materialBoxAmount)
  36. ->create([
  37. 'order_id'=>$this->getTargetIdCirculately($this->data['orders']),
  38. 'location'=>$this->getTargetIdCirculately($this->data['materialBoxes']),
  39. ]);
  40. }
  41. public function testReturned()
  42. {
  43. $this->service->createByBatches();
  44. $this->assertTrue(true);
  45. }
  46. function tearDown(): void
  47. {
  48. StationTaskMaterialBox::query()
  49. ->whereIn('id',data_get($this->data['stationTaskMaterialBoxes'],'*.id')??[])
  50. ->delete();
  51. parent::tearDown();
  52. }
  53. }