PutBinToStoreFromCacheShelfTest.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace Tests\Services\ForeignHaiRoboticsService;
  3. use App\Exceptions\ErrorException;
  4. use App\MaterialBox;
  5. use App\Services\ForeignHaiRoboticsService;
  6. use App\Services\StationService;
  7. use App\Station;
  8. use App\StationCacheShelfGrid;
  9. use App\StationTaskMaterialBox;
  10. use App\Traits\TestMockSubServices;
  11. use Tests\TestCase;
  12. class PutBinToStoreFromCacheShelfTest extends TestCase
  13. {
  14. use TestMockSubServices;
  15. /** @var ForeignHaiRoboticsService $service */
  16. protected $service;
  17. protected $data = [];
  18. protected function setUp(): void
  19. {
  20. parent::setUp();
  21. $this->service = $this->subMock([
  22. 'class' => ForeignHaiRoboticsService::class,
  23. 'subService' => [
  24. 'serviceName' => 'StationService',
  25. 'class' => StationService::class,
  26. 'methods' => [
  27. 'controlHaiRobot' => true
  28. ]
  29. ]
  30. ]);
  31. $this->data['station'] = factory(Station::class)->create();
  32. $this->data['materialBox'] = factory(MaterialBox::class)->create();
  33. $this->data['grids'] = factory(StationCacheShelfGrid::class)->create();
  34. $this->data['stationTaskMaterialBox'] = factory(StationTaskMaterialBox::class)
  35. ->create(['station_id'=>$this->data['station']['id']]);
  36. $this->data['station']->setRelation('grids',collect([$this->data['grids']]));
  37. $this->data['stationTaskMaterialBox']->setRelation('station', $this->data['station']);
  38. $this->data['stationTaskMaterialBox']->setRelation('materialBox', $this->data['materialBox']);
  39. }
  40. public function testSuccess1()
  41. {
  42. $success = $this->service->putBinToStore_fromCacheShelf($this->data['stationTaskMaterialBox']);
  43. $this->assertEquals($success,true);
  44. }
  45. protected function tearDown(): void
  46. {
  47. Station::query()->where('id',$this->data['station']['id'])->delete();
  48. StationCacheShelfGrid::query()->where('id',$this->data['grids']['id'])->delete();
  49. MaterialBox::query()->where('id',$this->data['materialBox']['id'])->delete();
  50. StationTaskMaterialBox::query()->where('id',$this->data['stationTaskMaterialBox']['id'])->delete();
  51. parent::tearDown();
  52. }
  53. }