GetChildStationTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Tests\Services\CacheShelfService;
  3. use App\MaterialBox;
  4. use App\Services\CacheShelfService;
  5. use App\Station;
  6. use App\StationTask;
  7. use App\StationType;
  8. use Faker\Factory;
  9. use Illuminate\Database\Eloquent\Collection;
  10. use Tests\TestCase;
  11. class GetChildStationTest extends TestCase
  12. {
  13. /** @var CacheShelfService $service */
  14. protected $service;
  15. protected $data = [];
  16. protected function setup(): void
  17. {
  18. parent::setup();
  19. $this->service = app(CacheShelfService::class);
  20. $stationType = StationType::query()->firstOrCreate(['name'=> '缓存架']);
  21. $this->data['parentStation'] = factory(Station::class)->create(['code' => 'test','station_type_id' => $stationType['id']]);
  22. $this->data['station'] = factory(Station::class)->create(['code'=>'childCode','parent_id'=>$this->data['parentStation']['id'],'station_type_id' => $stationType['id']]);
  23. $this->data['materialBox'] = factory(MaterialBox::class)->create(['code'=> 'test']);
  24. $this->data['stationTask'] = factory(StationTask::class)->create(['station_id'=>$this->data['station']['id'],'status'=> '处理中']);
  25. }
  26. public function testGetTasks()
  27. {
  28. $grids = $this->service->getChildStation($this->data['station']['id']);
  29. $this->assertTrue($grids ? true : false);
  30. }
  31. protected function tearDown(): void
  32. {
  33. if($this->data['station'])$this->data['station']->delete();
  34. if($this->data['parentStation'])$this->data['parentStation']->delete();
  35. if($this->data['materialBox'])$this->data['materialBox']->delete();
  36. if($this->data['stationTask'])$this->data['stationTask']->delete();
  37. parent::tearDown(); // TODO: Change the autogenerated stub
  38. }
  39. }