service = app('StationTaskBatchService'); $this->stationTaskService = app('StationTaskService'); $this->data['stationTaskBathes'] = factory(StationTaskBatch::class, $this->bathAmount) ->create(); $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['stationTasks'] = $this->stationTaskService->create($this->bathAmount); } public function testReturned() { $taskBatches_failed=$this->service->runMany( $this->data['stationTaskBathes'] ); $this->assertTrue($taskBatches_failed->isEmpty()); $this->assertTrue((function(){ $arr=array_unique( data_get($this->data['stationTaskBathes'],'*.status') ); })()); } function tearDown(): void { StationTaskBatch::query() ->whereIn('id',data_get($this->data['stationTaskBathes'],'*.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['stationTasks'],'*.id')??[]) ->delete(); parent::tearDown(); } }