stationTaskService = app('StationTaskService'); $this->stationTaskCommodityService = app('StationTaskCommodityService'); $this->stationTaskMaterialBoxService = app('StationTaskMaterialBoxService'); $this->stationTaskBatchService=$this->subMock([ 'class'=>StationTaskBatchService::class, // 'subServices'=>[ // [ // 'serviceName'=>'foreignHaiRoboticsService', // 'class'=>ForeignHaiRoboticsService::class, // 'methods'=>[ // 'fetchGroup'=>true, // ], // ], // ] ]); $this->data['owner'] = factory(Owner::class) ->create(); $this->data['batches'] = factory(Batch::class, $this->bathAmount) ->create([ 'status'=>'未处理', 'owner_id'=>$this->data['owner']['id'] ]); $this->data['stationRuleBatch'] = factory(StationRuleBatch::class) -> create([ 'owner_id'=>$this->data['owner']['id'], ]); $this->data['stationTask'] = $this->stationTaskService->create($this->bathAmount); $this->data['stationTaskCommodities']=$this->stationTaskCommodityService->createByBatches($this->data['batches'],$this->data['stationTask']); //注册商品任务 $this->data['stationTaskMaterialBoxes']=$this->stationTaskMaterialBoxService->createByBatches($this->data['batches'],$this->data['stationTask']); //注册料箱任务 $this->data['stationTaskBathes']=$this->stationTaskBatchService->createByBatches($this->data['batches'],$this->data['stationTask']); //注册波次任务 } public function testReturned() { $taskBatches_failed=$this->stationTaskBatchService->runMany( $this->data['stationTaskBathes'] ); $this->assertTrue($taskBatches_failed->isEmpty()); $this->assertTrue(( $全部是处理中状态 =function(){ $arr=array_unique( data_get($this->data['stationTaskBathes'],'*.status') ); return count($arr)==1 && $arr[0]=='处理中'; })()); } function tearDown(): void { StationTaskBatch::query() ->whereIn('id',data_get($this->data['stationTaskBathes'],'*.id')??[]) ->delete(); StationRuleBatch::query() ->whereIn('id',$this->data['stationRuleBatch']['id']) ->delete(); StationTaskMaterialBox::query() ->whereIn('id',data_get($this->data['batches'],'*.id')??[]) ->delete(); Order::query() ->whereIn('id',data_get($this->data['orders'],'*.id')??[]) ->delete(); MaterialBox::query() ->whereIn('id',data_get($this->data['materialBoxes'],'*.id')??[]) ->delete(); OrderCommodity::query() ->whereIn('id',data_get($this->data['orderCommodities'],'*.id')??[]) ->delete(); StationTask::query() ->whereIn('id',data_get($this->data['stationTask'],'*.id')??[]) ->delete(); StationTaskCommodity::query() ->whereIn('id',data_get($this->data['stationTaskCommodities'],'*.id')??[]) ->delete(); parent::tearDown(); } }