service = app(CacheShelfService::class); $stationType = StationType::query()->firstOrCreate(['name'=> '缓存架']); $this->data['parentStation'] = factory(Station::class)->create(['code' => 'test','station_type_id' => $stationType['id']]); $this->data['station'] = factory(Station::class)->create(['code'=>'childCode','parent_id'=>$this->data['parentStation']['id'],'station_type_id' => $stationType['id']]); $this->data['materialBox'] = factory(MaterialBox::class)->create(['code'=> 'test']); $this->data['stationTask'] = factory(StationTask::class)->create(['station_id'=>$this->data['station']['id'],'status'=> '处理中']); } public function testGetTasks() { $grids = $this->service->getChildStation($this->data['station']['id']); $this->assertTrue($grids ? true : false); } protected function tearDown(): void { if($this->data['station'])$this->data['station']->delete(); if($this->data['parentStation'])$this->data['parentStation']->delete(); if($this->data['materialBox'])$this->data['materialBox']->delete(); if($this->data['stationTask'])$this->data['stationTask']->delete(); parent::tearDown(); // TODO: Change the autogenerated stub } }