PutBinToStoreTest.php 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace Tests\Services\CacheShelfService;
  3. use App\MaterialBox;
  4. use App\Services\CacheShelfService;
  5. use App\Services\ForeignHaiRoboticsService;
  6. use App\Services\StationCacheShelfGridService;
  7. use App\Station;
  8. use App\StationTask;
  9. use App\StationTaskChildren;
  10. use App\StationTaskMaterialBox;
  11. use App\Traits\TestMockSubServices;
  12. use Tests\TestCase;
  13. class PutBinToStoreTest extends TestCase
  14. {
  15. use TestMockSubServices;
  16. /** @var CacheShelfService $cacheShelfService */
  17. protected $cacheShelfService;
  18. protected $data = [];
  19. protected function setup(): void
  20. {
  21. parent::setup(); // todo: change the autogenerated stub
  22. // $this->data['station'] = factory(Station::class)->create(['station_type_id'=>1]);
  23. // $this->data['materialBox'] = factory(MaterialBox::class)->create();
  24. // $this->data['stationTask'] = factory(StationTask::class)->create();
  25. // $this->data['stationTask']['station_id'] = $this->data['station']['id'];
  26. // $this->data['stationTask']->save();
  27. //
  28. // $this->data['stationTaskMaterialBox'] = factory(StationTaskMaterialBox::class)->create([
  29. // 'station_id' => $this->data['station']['id'],
  30. // 'material_box_id' => $this->data['materialBox']['id'],
  31. // 'status' => '待处理'
  32. // ]);
  33. //
  34. // $this->data['stationTaskMaterialBox']['station_task_id'] = $this->data['stationTask']['id'];
  35. // $this->data['stationTaskMaterialBox']->save();
  36. //
  37. // $this->data['stationTaskChildren'] = StationTaskChildren::query()->create([
  38. // "station_task_id" => $this->data['stationTask']['id'],
  39. // ]);
  40. // $this->data['stationTaskChildren']["station_taskable_type"] = StationTaskMaterialBox::class;
  41. // $this->data['stationTaskChildren']["station_taskable_id"]= $this->data['stationTaskMaterialBox']['id'];
  42. // $this->data['stationTaskChildren']->save();
  43. //
  44. // $this->cacheShelfService = $this->subMock([
  45. // 'class' => CacheShelfService::class,
  46. // 'subService' => [
  47. // [
  48. // 'serviceName' => 'foreignHaiRoboticsService',
  49. // 'class' => ForeignHaiRoboticsService::class,
  50. // 'methods' => [
  51. // 'controlHaiRobot' => true
  52. // ]
  53. // ]
  54. // ]
  55. // ]);
  56. }
  57. public function testPutBinToStore()
  58. {
  59. // $bool = $this->cacheShelfService->putBinToStore($this->data['station']);
  60. // $boxTask = StationTaskMaterialBox::query()->where('material_box_id', $this->data['materialBox']['id'])->get();
  61. // $this->assertTrue($bool);
  62. // $this->assertNotEmpty($boxTask);
  63. $this->assertTrue(true);
  64. }
  65. protected function tearDown(): void
  66. {
  67. // StationTaskChildren::query()->where('station_taskable_id',$this->data['stationTaskMaterialBox']['id'])->delete();
  68. // $materialBox = MaterialBox::query()->where('id', $this->data['materialBox']['id'])->first();
  69. // if ($materialBox) {
  70. // $stationTaskMaterialBoxes = StationTaskMaterialBox::query()->where('material_box_id', $materialBox['id'])->get();
  71. // foreach ($stationTaskMaterialBoxes as $stationTaskMaterialBox) {
  72. // if ($stationTaskMaterialBox->station) $stationTaskMaterialBox->station->delete();
  73. // if ($stationTaskMaterialBox->stationTask) $stationTaskMaterialBox->stationTask->delete();
  74. // $stationTaskMaterialBox->delete();
  75. // }
  76. // $materialBox->delete();
  77. // }
  78. // if($this->data['stationTaskChildren'])StationTaskChildren::query()->where('id',$this->data['stationTaskChildren']['id'])->delete();
  79. parent::tearDown();
  80. }
  81. }