LightOffTest.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Tests\Services\StationCacheShelfGridService;
  3. use App\Services\StationCacheShelfGridService;
  4. use App\Station;
  5. use App\StationCacheShelfGrid;
  6. use Tests\TestCase;
  7. class LightOffTest extends TestCase
  8. {
  9. /** @var StationCacheShelfGridService $stationCacheShelfGridService */
  10. protected $stationCacheShelfGridService;
  11. protected $data = [];
  12. protected function setup(): void
  13. {
  14. parent::setUp();
  15. $this->stationCacheShelfGridService = app(StationCacheShelfGridService::class);
  16. $row = 2;
  17. $col = 1;
  18. $gridIndex = ($row-1)*3 + (3-$col);
  19. $this->data['station'] = factory(Station::class)->create();
  20. $this->data['stationCacheShelfGrid'] = factory(StationCacheShelfGrid::class)->create(['station_id' => $this->data['station']['id'],'grid_id'=>$gridIndex]);
  21. $this->data['locCode'] = 'HAI'.$this->data['station']['code'].'-0'.$col.'-0'.$row;
  22. $this->data['PTLAction'] = 0;
  23. }
  24. public function testLightOff()
  25. {
  26. $this->stationCacheShelfGridService->lightOff($this->data['locCode'],$this->data['PTLAction']);
  27. $grid = StationCacheShelfGrid::query()->where('id',$this->data['stationCacheShelfGrid']['id'])->first();
  28. $this->assertEquals($grid['id'],$this->data['stationCacheShelfGrid']['id']);
  29. $this->assertEquals($grid['station']['id'],$this->data['stationCacheShelfGrid']['station_id']);
  30. $this->assertEquals($grid['material_box_id'],null);
  31. $this->assertEquals($grid['status'],0);
  32. }
  33. protected function tearDown(): void
  34. {
  35. Station::query()->where('id',$this->data['station']['id'])->delete();
  36. StationCacheShelfGrid::query()->where('id',$this->data['stationCacheShelfGrid']['id'])->delete();
  37. parent::tearDown(); // TODO: Change the autogenerated stub
  38. }
  39. }