GetTasksTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Tests\Services\CacheShelfService;
  3. use App\Services\CacheShelfService;
  4. use App\Station;
  5. use App\StationCacheShelfGrid;
  6. use Tests\TestCase;
  7. class GetTasksTest extends TestCase
  8. {
  9. /** @var CacheShelfService $service */
  10. protected $service;
  11. protected $data = [];
  12. protected function setup(): void
  13. {
  14. parent::setup();
  15. $this->service = app(CacheShelfService::class);
  16. $this->data['station'] = factory(Station::class)->create();
  17. $collect = collect();
  18. for ($i = 1; $i <= 8; $i++) {
  19. $collect->push(StationCacheShelfGrid::query()->create([
  20. 'station_id' => $this->data['station']['id'] ?? '',
  21. 'grid_id' => $i,
  22. 'status' => 1,
  23. ]));
  24. }
  25. $this->data['grids'] = $collect;
  26. }
  27. public function testGetTasks()
  28. {
  29. $grids = $this->service->getTasks($this->data['station']);
  30. $this->assertEquals(count($grids), count($this->data['grids']));
  31. }
  32. protected function tearDown(): void
  33. {
  34. Station::query()->where('id', $this->data['station']['id'])->delete();
  35. StationCacheShelfGrid::query()->where('station_id', $this->data['station']['id'])->delete();
  36. parent::tearDown(); // TODO: Change the autogenerated stub
  37. }
  38. }