|
|
@@ -47,7 +47,7 @@ class ClearTaskTest extends TestCase
|
|
|
$this->data['stationTaskMaterialBoxes'] = [];
|
|
|
$this->data['materialBox'] = factory(MaterialBox::class)->create();
|
|
|
|
|
|
- $this->data['stationTask'] = $this->stationTaskService->create(1); // 生成站任务
|
|
|
+ $this->data['stationTask'] = $this->stationTaskService->create(1); // 生成站任务
|
|
|
$this->data['stationTaskMaterialBoxes'][] = $this->stationTaskMaterialBoxService->createByStationAndMaterialBox($this->data['station'],$this->data['materialBox']); // 创建料箱任务
|
|
|
$this->stationTaskService->registerStations($this->data['stationTask'],[$this->data['station']['id']]); // 注册站任务站
|
|
|
$this->data['stationTaskMaterialBoxes'][0]['station_task_id'] = $this->data['stationTask'][0]['id'];
|
|
|
@@ -66,8 +66,6 @@ class ClearTaskTest extends TestCase
|
|
|
$result = $this->service->clearTask($this->data['station']->code);
|
|
|
$stationTask = StationTask::query()->where('station_id',$this->data['station']['id'])->first();
|
|
|
$this->assertEmpty($stationTask);
|
|
|
- $stationTaskMaterialBox = StationTaskMaterialBox::query()->where('material_box_id',$this->data['materialBox']['id'])->get();
|
|
|
- $this->assertEmpty($stationTaskMaterialBox);
|
|
|
}
|
|
|
|
|
|
public function testClearTask_taskIsRunning()
|
|
|
@@ -84,30 +82,16 @@ class ClearTaskTest extends TestCase
|
|
|
|
|
|
protected function tearDown(): void
|
|
|
{
|
|
|
- if($this->data['station']){
|
|
|
- $stationTasks = StationTask::query()->where('station_id',$this->data['station']['id'])->get();
|
|
|
- foreach ($stationTasks as $stationTask) {
|
|
|
- $stationTaskMaterialBoxes = $stationTask->stationTaskMaterialBoxes;
|
|
|
- foreach ($stationTaskMaterialBoxes as $stationTaskMaterialBox) {
|
|
|
- StationTaskChildren::query()->where(['station_task_id' => $stationTask['id'],'station_taskable_type'=> StationTaskMaterialBox::class,'station_taskable_id'=>$stationTaskMaterialBox['id']])->delete();
|
|
|
- $stationTaskMaterialBox->delete();
|
|
|
- }
|
|
|
- }
|
|
|
- Station::query()->where('id',$this->data['station']['id'])->delete();
|
|
|
- }
|
|
|
-
|
|
|
- if($this->data['LiKuStation']){
|
|
|
- $stationTasks = StationTask::query()->where('station_id',$this->data['LiKuStation']['id'])->get();
|
|
|
- foreach ($stationTasks as $stationTask) {
|
|
|
- $stationTaskMaterialBoxes = $stationTask->stationTaskMaterialBoxes;
|
|
|
- foreach ($stationTaskMaterialBoxes as $stationTaskMaterialBox) {
|
|
|
- StationTaskChildren::query()->where(['station_task_id' => $stationTask['id'],'station_taskable_type'=> StationTaskMaterialBox::class,'station_taskable_id'=>$stationTaskMaterialBox['id']])->delete();
|
|
|
- $stationTaskMaterialBox->delete();
|
|
|
- }
|
|
|
- }
|
|
|
- Station::query()->where('id',$this->data['LiKuStation']['id'])->delete();
|
|
|
- }
|
|
|
- if($this->data['materialBox'])MaterialBox::query()->where('id',$this->data['materialBox'])->delete();
|
|
|
+
|
|
|
+ StationTask::query()->whereIn('id',data_get($this->data['stationTask'],'*.id'))->delete();
|
|
|
+ StationTaskChildren::query()
|
|
|
+// ->where('station_task_id', data_get($this->data['stationTask'],'*.id'))
|
|
|
+ ->where('station_taskable_type', 'App\StationTaskMaterialBox')
|
|
|
+ ->whereIn('station_taskable_id',data_get($this->data['stationTaskMaterialBoxes'],'*.id'))->delete();
|
|
|
+ Station::query()->where('id',$this->data['LiKuStation']['id'])->delete();
|
|
|
+ Station::query()->where('id',$this->data['station']['id'])->delete();
|
|
|
+ StationTaskMaterialBox::query()->where('material_box_id',$this->data['materialBox']['id'])->delete();
|
|
|
+ if($this->data['materialBox'])MaterialBox::query()->where('id',$this->data['materialBox']['id'])->delete();
|
|
|
parent::tearDown(); // TODO: Change the autogenerated stub
|
|
|
}
|
|
|
|