service = app(CacheShelfService::class); $this->data['station'] = factory(Station::class)->create(); $collect = collect(); for ($i = 1; $i <= 8; $i++) { $collect->push(StationCacheShelfGrid::query()->create([ 'station_id' => $this->data['station']['id'] ?? '', 'grid_id' => $i, 'status' => 1, ])); } $this->data['grids'] = $collect; } public function testGetTasks() { $grids = $this->service->getTasks($this->data['station']); $this->assertEquals(count($grids), count($this->data['grids'])); } protected function tearDown(): void { Station::query()->where('id', $this->data['station']['id'])->delete(); StationCacheShelfGrid::query()->where('station_id', $this->data['station']['id'])->delete(); parent::tearDown(); // TODO: Change the autogenerated stub } }