service = $this->subMock([ 'class' => CacheShelfService::class, 'subService' => [ 'serviceName' => 'foreignHaiRoboticsService', 'class' => ForeignHaiRoboticsService::class, 'methods'=>[ 'controlHaiRobot' =>true ] ] ]); $row = 2; $col = 1; $this->data['parentStation'] = factory(Station::class)->create(['code' => 'testParent']); $this->data['locCode'] = 'HAI'.$this->data['station']['code'].'-0'.$col.'-0'.$row; $this->data['station'] = factory(Station::class)->create(['parent_id'=>$this->data['parentStation']['id'],'code' => $this->data['locCode']]); $this->data['materialBox'] = factory(MaterialBox::class)->create(['code'=>'testMaterialBox']); $this->data['PTLAction'] = 0; } public function testLightOffTask() { $this->service->lightOffTask($this->data['locCode'],$this->data['PTLAction']); $task = StationTaskMaterialBox::query()->where('station_id',$this->data['station']['id'])->where('material_box_id',$this->data['materialBox']['id'])->first(); $this->assertNotEmpty($task); $this->assertEquals($task['status'],'处理中'); } protected function tearDown(): void { Station::query()->whereIn('id',[$this->data['station']['id'],$this->data['parentStation']['id']])->delete(); MaterialBox::query()->whereIn('id',$this->data['materialBox']['id'])->delete(); StationTaskMaterialBox::query()->where('station_id',$this->data['station']['id'])->where('material_box_id',$this->data['materialBox'])->delete(); parent::tearDown(); } }