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(); $this->data['orders'] = factory(Order::class) ->createMany($this->makeArray($this->orderAmount,[ 'status'=>'未处理', 'batch_id' => function(){return $this->getTargetFieldCirculately($this->data['batches']);} ])); $this->data['orderCommodities'] = factory(OrderCommodity::class) ->createMany($this->makeArray($this->orderCommodityAmount,[ 'order_id' => function(){return $this->getTargetFieldCirculately($this->data['orders']);} ])); $this->data['station_rule_batches'] = factory(StationRuleBatch::class) ->createMany($this->makeArray($this->batchAmount,[ 'owner_id' => function(){return $this->getTargetFieldCirculately($this->data['batches'],'','owner_id');} ])); } public function testReturned() { $this->service->assignTasks($this->data['batches']); ($波次任务指向了波次=function(){ $this->data['batches']->load('stationTaskBatch'); $this->assertEquals( data_get($this->data['batches'],'*.id'), data_get($this->data['batches'],'*.stationTaskBatch.batch_id') ); })(); } function tearDown(): void { // MaterialBox::query() // ->whereIn('id',data_get($this->data['batches'],'*.stationTaskBatch.stationTask.stationTaskMaterialBoxes.*.materialBox.id')??[]) // ->delete(); // StationTaskMaterialBox::query() // ->whereIn('id',data_get($this->data['batches'],'*.stationTaskBatch.stationTask.stationTaskMaterialBoxes.*.id')??[]) // ->delete(); // StationTaskCommodity::query() // ->whereIn('id',data_get($this->data['batches'],'*.stationTaskBatch.stationTask.stationTaskCommodities.*.id')??[]) // ->delete(); // StationTaskBatch::query() // ->whereIn('id',data_get($this->data['batches'],'*.stationTaskBatch.id')??[]) // ->delete(); // StationTask::query() // ->whereIn('id',data_get($this->data['batches'],'*.stationTaskBatch.stationTask.id')??[]) // ->delete(); // StationRuleBatch::query() // ->whereIn('id',data_get($this->data['station_rule_batches'],'*.id')??[]) // ->delete(); // OrderCommodity::query() // ->whereIn('id',data_get($this->data['orderCommodities'],'*.id')??[]) // ->delete(); // Order::query() // ->whereIn('id',data_get($this->data['orders'],'*.id')??[]) // ->delete(); // Batch::query() // ->whereIn('id',data_get($this->data['batches'],'*.id')??[]) // ->delete(); parent::tearDown(); } }