| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace Tests\Services\CacheShelfService;
- use App\Services\CacheShelfService;
- use App\Station;
- use App\StationCacheShelfGrid;
- use Tests\TestCase;
- class GetTasksTest extends TestCase
- {
- /** @var CacheShelfService $service */
- protected $service;
- protected $data = [];
- protected function setup(): void
- {
- parent::setup();
- $this->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
- }
- }
|