|
|
@@ -1,11 +1,19 @@
|
|
|
<?php
|
|
|
|
|
|
namespace Tests\Services\BatchService;
|
|
|
+use App\MaterialBox;
|
|
|
use App\Order;
|
|
|
use App\OrderCommodity;
|
|
|
use App\Services\BatchService;
|
|
|
+use App\Services\ForeignHaiRoboticsService;
|
|
|
+use App\Services\MaterialBoxService;
|
|
|
+use App\Services\StationTaskBatchService;
|
|
|
+use App\Services\StationTaskCommodityService;
|
|
|
use App\Station;
|
|
|
use App\StationRuleBatch;
|
|
|
+use App\StationTask;
|
|
|
+use App\StationTaskBatch;
|
|
|
+use App\StationTaskCommodity;
|
|
|
use Tests\TestCase;
|
|
|
use App\Batch;
|
|
|
use App\Traits\TestMockSubServices;
|
|
|
@@ -22,7 +30,27 @@ class AssignTasksTest extends TestCase
|
|
|
function setUp(): void
|
|
|
{
|
|
|
parent::setUp();
|
|
|
- $this->service = app('BatchService');
|
|
|
+ $this->service=$this->subMock([
|
|
|
+ 'class'=>BatchService::class,
|
|
|
+ 'subServices'=>[
|
|
|
+ [
|
|
|
+ 'serviceName'=>'stationTaskBatchService',
|
|
|
+ 'class'=>StationTaskBatchService::class,
|
|
|
+ 'methods'=>[
|
|
|
+ 'firstOrCreate'=>new MaterialBox(['id'=>1]),
|
|
|
+ ],
|
|
|
+ 'subServices'=>[
|
|
|
+ [
|
|
|
+ 'serviceName'=>'foreignHaiRoboticsService',
|
|
|
+ 'class'=>ForeignHaiRoboticsService::class,
|
|
|
+ 'methods'=>[
|
|
|
+ 'fetchGroup'=>true,
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ ]
|
|
|
+ ],
|
|
|
+ ]
|
|
|
+ ]);
|
|
|
$this->data['batches']
|
|
|
= factory(Batch::class, $this->batchAmount)
|
|
|
->create();
|
|
|
@@ -42,22 +70,44 @@ class AssignTasksTest extends TestCase
|
|
|
->createMany($this->makeArray($this->batchAmount,[
|
|
|
'owner_id' => function(){return $this->getTargetIdCirculately($this->data['batches'],'','owner_id');}
|
|
|
]));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public function testReturned()
|
|
|
{
|
|
|
$this->service->assignTasks($this->data['batches']);
|
|
|
- $this->data['batches']['0']->loadMissing('stationBatchTask.stationTask');
|
|
|
- $a=($this->data['batches']['0']['stationBatchTask']);
|
|
|
- dd($a);
|
|
|
- $this->assertEquals(data_get($this->data['batches'],'*.id'),$this->data['batches']);
|
|
|
+ ($波次任务指向了波次=function(){
|
|
|
+ $this->assertEquals(
|
|
|
+ data_get($this->data['batches'],'*.id'),
|
|
|
+ data_get($this->data['batches'],'*.stationBatchTask.batch_id')
|
|
|
+ );
|
|
|
+ })();
|
|
|
}
|
|
|
|
|
|
function tearDown(): void
|
|
|
{
|
|
|
+
|
|
|
+ $stationBatchTasks=data_get($this->data['batches'],'*.stationBatchTask');
|
|
|
+ $a3=data_get($this->data['batches'],'*.stationBatchTask.*.stationTask');
|
|
|
+ $a4=data_get($this->data['batches'],'*.stationBatchTask.stationTask');
|
|
|
+ foreach ($stationBatchTasks as $stationBatchTask){
|
|
|
+ $stationBatchTask->loadMissing('stationTask.stationTaskCommodities');
|
|
|
+ $stationBatchTask->loadMissing('stationTask.stationTaskMaterialBoxes.materialBox');
|
|
|
+ }
|
|
|
+ $a13=data_get($this->data['batches'],'*.stationBatchTask.*.stationTask');
|
|
|
+ $a14=data_get($this->data['batches'],'*.stationBatchTask.stationTask');
|
|
|
Batch::query()
|
|
|
->whereIn('id',data_get($this->data['batches'],'*.id')??[])
|
|
|
->delete();
|
|
|
+// StationTaskBatch::query()
|
|
|
+// ->whereIn('id',data_get($this->data['batches'],'*.stationBatchTask.id')??[])
|
|
|
+// ->delete();
|
|
|
+ StationTaskCommodity::query()
|
|
|
+ ->whereIn('id',data_get($this->data['batches'],'*.stationBatchTask.*.stationTask.*.stationTaskCommodities.id')??[])
|
|
|
+ ->delete();
|
|
|
+ StationTask::query()
|
|
|
+ ->whereIn('id',data_get($this->data['batches'],'*.stationBatchTask.stationTask.id')??[])
|
|
|
+ ->delete();
|
|
|
Order::query()
|
|
|
->whereIn('id',data_get($this->data['orders'],'*.id')??[])
|
|
|
->delete();
|