ProcessGridTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Tests\Services\StationCacheShelfGridService;
  3. use App\MaterialBox;
  4. use App\Services\StationCacheShelfGridService;
  5. use App\Station;
  6. use App\StationCacheShelfGrid;
  7. use Tests\TestCase;
  8. class ProcessGridTest extends TestCase
  9. {
  10. /** @var StationCacheShelfGridService $stationCacheShelfGridService */
  11. protected $stationCacheShelfGridService;
  12. protected $data = [];
  13. protected function setup(): void
  14. {
  15. parent::setUp();
  16. $this->stationCacheShelfGridService = app(StationCacheShelfGridService::class);
  17. $this->data['station'] = factory(Station::class)->create();
  18. $this->data['materialBox'] = factory(MaterialBox::class)->create();
  19. $this->data['stationCacheShelfGrid'] = factory(StationCacheShelfGrid::class)->create();
  20. }
  21. public function test()
  22. {
  23. $this->stationCacheShelfGridService->processGrid($this->data['stationCacheShelfGrid'],$this->data['station'],$this->data['materialBox']);
  24. $grid = StationCacheShelfGrid::query()->where('id',$this->data['stationCacheShelfGrid']['id'])->first();
  25. $this->assertEquals($grid['id'],$this->data['stationCacheShelfGrid']['id']);
  26. $this->assertEquals($grid['station_id'],$this->data['station']['id']);
  27. $this->assertEquals($grid['material_box_id'],$this->data['materialBox']['id']);
  28. }
  29. protected function tearDown(): void
  30. {
  31. Station::query()->where('id',$this->data['station']['id'])->delete();
  32. MaterialBox::query()->where('id',$this->data['materialBox']['id'])->delete();
  33. StationCacheShelfGrid::query()->where('id',$this->data['stationCacheShelfGrid']['id'])->delete();
  34. parent::tearDown();
  35. }
  36. }