service = app('StationTaskBatchService'); $this->stationTaskService = app('StationTaskService'); $this->data['owner'] = factory(Owner::class) ->create(); $this->data['batches'] = factory(Batch::class, self::AmountOfBatch) ->create([ 'status'=>'未处理', 'owner_id'=>$this->data['owner']['id'] ]); $this->data['stationType'] = factory(StationType::class) -> create(); $this->data['stationRuleBatch'] = factory(StationRuleBatch::class) -> create([ 'owner_id'=>$this->data['owner']['id'] ]); $this->data['stationTasks'] = $this->stationTaskService->create(self::AmountOfBatch); } public function testReturned() { $this->data['stationTaskBatches']=$this->service->createByBatches($this->data['batches'], $this->data['stationTasks']); $this->assertEquals(self::AmountOfBatch, $this->data['stationTaskBatches']->count()); } public function tearDown(): void { Batch::query()->whereIn('id',data_get($this->data['batches'],'*.id')??[])->delete(); StationTask::query()->whereIn('id',data_get($this->data['stationTasks'],'*.id')??[])->delete(); StationTaskBatch::query()->whereIn('id',data_get($this->data['stationTaskBatches'],'*.id')??[])->delete(); Owner::query()->where('id',$this->data['owner']['id']??'')->delete(); parent::tearDown(); } }