LightOffTaskTest.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. namespace Tests\Services\CacheShelfService;
  3. use App\MaterialBox;
  4. use App\Services\CacheShelfService;
  5. use App\Services\ForeignHaiRoboticsService;
  6. use App\Station;
  7. use App\StationTask;
  8. use App\StationTaskChildren;
  9. use App\StationTaskMaterialBox;
  10. use App\StationType;
  11. use App\Traits\TestMockSubServices;
  12. use Tests\TestCase;
  13. class LightOffTaskTest extends TestCase
  14. {
  15. use TestMockSubServices;
  16. /** @var CacheShelfService $service */
  17. protected $service;
  18. /** @var ForeignHaiRoboticsService $foreignHaiRoboticsService */
  19. protected $foreignHaiRoboticsService;
  20. protected $data = [];
  21. protected function setup(): void
  22. {
  23. parent::setup();
  24. // $this->service = $this->subMock([
  25. // 'class' => CacheShelfService::class,
  26. // 'subService' => [
  27. // 'serviceName' => 'foreignHaiRoboticsService',
  28. // 'class' => ForeignHaiRoboticsService::class,
  29. // 'methods'=>[
  30. // 'controlHaiRobot' =>true
  31. // ]
  32. // ]
  33. // ]);
  34. // $row = 2;
  35. // $col = 1;
  36. // $stationType = StationType::query()->firstOrCreate(['name' => '立库']);
  37. // $this->data['station1'] = factory(Station::class)->create(['station_type_id'=>$stationType['id']]);
  38. // $this->data['parentStation'] = factory(Station::class)->create();
  39. // $this->data['locCode'] = 'HAI'.$this->data['parentStation']['code'].'-0'.$col.'-0'.$row;
  40. // $this->data['station'] = factory(Station::class)->create(['parent_id'=>$this->data['parentStation']['id'],'code' => $this->data['locCode']]);
  41. // $this->data['materialBox'] = factory(MaterialBox::class)->create();
  42. //
  43. // $this->data['stationTask'] = factory(StationTask::class)->create(['station_id' =>$this->data['station']['id']]);
  44. // $this->data['stationTask']['station_id'] = $this->data['station']['id'];
  45. // $this->data['stationTask']->save();
  46. //
  47. // $this->data['stationTaskMaterialBox'] = factory(StationTaskMaterialBox::class)->create([
  48. // 'station_id' => $this->data['station']['id'],
  49. // 'material_box_id' => $this->data['materialBox']['id'],
  50. // 'status' => '待处理',
  51. // 'station_task_id' => $this->data['stationTask']['id'],
  52. // ]);
  53. //
  54. //
  55. // $this->data['stationTaskChildren'] = StationTaskChildren::query()->create([
  56. // "station_task_id" => $this->data['stationTask']['id'],
  57. // ]);
  58. // $this->data['stationTaskChildren']["station_taskable_type"] = StationTaskMaterialBox::class;
  59. // $this->data['stationTaskChildren']["station_taskable_id"]= $this->data['stationTaskMaterialBox']['id'];
  60. // $this->data['stationTaskChildren']->save();
  61. // $this->data['PTLAction'] = 0;
  62. }
  63. public function testLightOffTask()
  64. {
  65. // $this->service->lightOffTask($this->data['locCode'],$this->data['PTLAction']);
  66. // $task = StationTaskMaterialBox::query()->where('station_id',$this->data['station']['id'])->where('material_box_id',$this->data['materialBox']['id'])->first();
  67. // $this->assertNotEmpty($task);
  68. // $this->assertEquals($task['status'],'处理中');
  69. $this->assertTrue(true);
  70. }
  71. protected function tearDown(): void
  72. {
  73. // $materialBox = MaterialBox::query()->where('id', $this->data['materialBox']['id'])->first();
  74. // if ($materialBox) {
  75. // $stationTaskMaterialBoxes = StationTaskMaterialBox::query()->where('material_box_id', $materialBox['id'])->get();
  76. // foreach ($stationTaskMaterialBoxes as $stationTaskMaterialBox) {
  77. // if ($stationTaskMaterialBox->station) $stationTaskMaterialBox->station->delete();
  78. //// if($stationTaskMaterialBox->station->parent)$stationTaskMaterialBox->station->parent->delete();
  79. // if ($stationTaskMaterialBox->stationTask) $stationTaskMaterialBox->stationTask->delete();
  80. // $stationTaskMaterialBox->delete();
  81. // }
  82. // $materialBox->delete();
  83. // }
  84. // Station::query()->where('id',$this->data['station']['id'])->delete();
  85. // Station::query()->where('id',$this->data['parentStation']['id'])->delete();
  86. // StationTaskChildren::query()->where('id',$this->data['stationTaskChildren']['id'])->delete();
  87. // Station::query()->where('id',$this->data['station1']['id'])->delete();
  88. parent::tearDown();
  89. }
  90. }