cacheShelfService = app(CacheShelfService::class); $this->stationTaskMaterialBoxService = app(StationTaskMaterialBoxService::class); $stationType = StationType::query()->firstOrCreate(['name' => '缓存架']); $this->data['materialBox'] = factory(MaterialBox::class)->create(['code'=>'testCode']); $this->data['parentStation'] = factory(Station::class)->create(['code' => 'TestParent','station_type_id' => $stationType['id']]); $this->data['station'] = factory(Station::class)->create(['code' => 'Test','station_type_id' => $stationType['id'],'parent_id'=>$this->data['parentStation']['id']]); $this->data['stationTask'] = factory(StationTask::class)->create(['station_id'=>$this->data['station']['id'],'status'=>'处理中']); $this->data['takeStationTaskMaterialBox'] = $this->stationTaskMaterialBoxService->createByStationAndMaterialBox($this->data['station'],$this->data['materialBox']); $this->data['putStationTaskMaterialBox'] = $this->stationTaskMaterialBoxService->createByStationAndMaterialBox($this->data['station'],$this->data['materialBox']); } public function testPutStationTaskMaterialBoxProcess() { $this->data['takeStationTaskMaterialBox']->update(['status' => '处理中']); $this->cacheShelfService->putStationTaskMaterialBoxProcess($this->data['putStationTaskMaterialBox']); $task = StationTaskMaterialBox::query()->where('id',$this->data['takeStationTaskMaterialBox']['id'])->first(); $this->assertTrue($task ? true : false); $this->assertEquals($task['status'] ?? '' ,'完成'); } public function testPutStationTaskMaterialBoxProcessT() { $this->cacheShelfService->putStationTaskMaterialBoxProcess($this->data['putStationTaskMaterialBox']); $task = StationTaskMaterialBox::query()->where('id',$this->data['takeStationTaskMaterialBox']['id'])->first(); $this->assertTrue($task ? true : false); $this->assertNotEquals($task['status'] ?? '' ,'完成'); } protected function tearDown(): void { if($this->data['materialBox'])$this->data['materialBox']->delete(); if($this->data['parentStation'])$this->data['parentStation']->delete(); if($this->data['station'])$this->data['station']->delete(); if($this->data['stationTask'])$this->data['stationTask']->delete(); if($this->data['takeStationTaskMaterialBox'])$this->data['takeStationTaskMaterialBox']->delete(); if($this->data['putStationTaskMaterialBox'])$this->data['putStationTaskMaterialBox']->delete(); parent::tearDown(); // TODO: Change the autogenerated stub } }