service = app('StationRuleBatchService'); $this->batchService = app('BatchService'); $this->data['owner_target'] = factory(Owner::class)->create(); $this->data['owner_none_target'] = factory(Owner::class)->create(); $this->data['stationRuleBatch'] = factory(StationRuleBatch::class) ->create([ 'owner_id' => $this->data['owner_target']['id'], ]); $this->data['batches'] = factory(Batch::class, $this->amountOfInRule)->create([ 'owner_id' => $this->data['owner_target']['id'], ]); $this->data['batches'][]=factory(Batch::class)->create([ 'owner_id' => $this->data['owner_none_target']['id'], ]); } public function testCreateSuccess() { $batches=$this->service->getBatches_shouldProcess($this->data['batches']); $this->assertEquals($this->amountOfInRule,$batches->count()); } public function tearDown(): void { cache()->flush(); Owner::query()->whereIn('id',[ $this->data['owner_target']['id'], $this->data['owner_none_target']['id'], ])->delete(); StationRuleBatch::query()->where('id',$this->data['stationRuleBatch']['id'])->delete(); Batch::query()->whereIn('id',data_get($this->data['batches'],'*.id'))->delete(); parent::tearDown(); // TODO: Change the autogenerated stub } }