| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace Tests\Services\StationTaskMaterialBoxService;
- use App\Batch;
- use App\Order;
- use App\OrderCommodity;
- use App\Services\StationTaskMaterialBoxService;
- use Tests\TestCase;
- use App\StationTaskMaterialBox;
- use App\Traits\TestMockSubServices;
- class CreateByBatchesTest extends TestCase
- {
- use TestMockSubServices;
- /** @var StationTaskMaterialBoxService $service */
- public $service;
- private $data;
- private $batchAmount=2;
- private $orderAmount=2;
- private $materialBoxAmount=2;
- function setUp(): void
- {
- parent::setUp();
- $this->service = app('StationTaskMaterialBoxService');
- $this->data['batches']
- = factory(Batch::class, $this->batchAmount)
- ->create();
- $this->data['orders']
- = factory(Order::class, $this->orderAmount)
- ->create([
- 'batch_id'=>$this->getTargetIdCirculately($this->data['batches'])
- ]);
- $this->data['materialBoxes']
- = factory(StationTaskMaterialBox::class, $this->materialBoxAmount)
- ->create();
- $this->data['orderCommodities']
- = factory(OrderCommodity::class, $this->materialBoxAmount)
- ->create([
- 'order_id'=>$this->getTargetIdCirculately($this->data['orders']),
- 'location'=>$this->getTargetIdCirculately($this->data['materialBoxes']),
- ]);
- }
- public function testReturned()
- {
- $this->service->createByBatches();
- $this->assertTrue(true);
- }
- function tearDown(): void
- {
- StationTaskMaterialBox::query()
- ->whereIn('id',data_get($this->data['stationTaskMaterialBoxes'],'*.id')??[])
- ->delete();
- parent::tearDown();
- }
- }
|