|
|
@@ -29,17 +29,17 @@ class CreateByBatchesTest extends TestCase
|
|
|
->create();
|
|
|
$this->data['orders']
|
|
|
= factory(Order::class)
|
|
|
- ->createMany(array_fill(0, $this->orderAmount, [
|
|
|
- 'batch_id' => $this->getTargetIdCirculately($this->data['batches'])
|
|
|
+ ->createMany($this->makeArray($this->orderAmount,[
|
|
|
+ 'batch_id' => function(){return $this->getTargetIdCirculately($this->data['batches']);}
|
|
|
]));
|
|
|
$this->data['materialBoxes']
|
|
|
= factory(MaterialBox::class, $this->materialBoxAmount)
|
|
|
->create();
|
|
|
$this->data['orderCommodities']
|
|
|
= factory(OrderCommodity::class)
|
|
|
- ->createMany(array_fill(0, $this->orderAmount, [
|
|
|
- 'order_id'=>$this->getTargetIdCirculately($this->data['orders']),
|
|
|
- 'location'=>$this->getTargetIdCirculately($this->data['materialBoxes'],'','code'),
|
|
|
+ ->createMany($this->makeArray($this->materialBoxAmount,[
|
|
|
+ 'order_id' => function(){return $this->getTargetIdCirculately($this->data['orders']);},
|
|
|
+ 'location' => function(){return $this->getTargetIdCirculately($this->data['materialBoxes'],'','code');},
|
|
|
]));
|
|
|
$this->data['stationTasks']
|
|
|
= factory(StationTask::class, $this->batchAmount)
|
|
|
@@ -50,8 +50,16 @@ class CreateByBatchesTest extends TestCase
|
|
|
{
|
|
|
$this->data['stationTaskMaterialBoxes']=$this->service->createByBatches($this->data['batches'],$this->data['stationTasks'] );
|
|
|
$this->assertTrue($this->data['stationTaskMaterialBoxes']->isNotEmpty());
|
|
|
- $this->assertEquals(StationTaskMaterialBox::class, $this->data['stationTaskMaterialBoxes']->first());
|
|
|
+ $this->assertEquals(StationTaskMaterialBox::class, get_class($this->data['stationTaskMaterialBoxes']->first()));
|
|
|
$this->assertEquals($this->materialBoxAmount, $this->data['stationTaskMaterialBoxes']->count());
|
|
|
+ $this->assertEquals($this->materialBoxAmount, (function(){
|
|
|
+ $taskBoxes=collect();
|
|
|
+ foreach ($this->data['stationTasks'] as $stationTask){
|
|
|
+ $stationTask->loadMissing('stationTaskMaterialBoxes');
|
|
|
+ $taskBoxes=$taskBoxes->merge($stationTask['stationTaskMaterialBoxes']);
|
|
|
+ }
|
|
|
+ return $taskBoxes->count();
|
|
|
+ })());
|
|
|
}
|
|
|
|
|
|
function tearDown(): void
|