data['station'] = factory(Station::class)->create(['name' => 'test', 'code'=> 'test']); $this->data['materialBox'] = factory(MaterialBox::class)->create(); $this->data['stationTaskMaterialBox'] = factory(StationTaskMaterialBox::class)->create([ 'station_id' => $this->data['station']['id'], 'material_box_id' => $this->data['materialBox']['id'], 'status' => 1 ]); $this->data['stationCacheShelfGrid'] = factory(StationCacheShelfGrid::class)->create([ 'station_id'=>$this->data['station']['id'], 'material_box_id'=>$this->data['materialBox']['id'], 'status' => 1 ]); $this->cacheShelfService = $this->subMock([ 'class' => CacheShelfService::class, 'subService' => [ // [ // 'serviceName' => 'stationTaskMaterialBoxService', // 'class' => StationTaskMaterialBoxService::class, // 'methods' => [ // 'createByStationMaterialBox' => $this->data['stationTaskMaterialBox'] // ] // ], [ 'serviceName' => 'stationCacheShelfGridService', 'class' => StationCacheShelfGridService::class, 'methods' => [ 'processGrid' => null ] ], [ 'serviceName' => 'foreignHaiRoboticsService', 'class' => ForeignHaiRoboticsService::class, 'methods' => [ // 'putBinToStore_fromCacheShelf' => true, 'controlHaiRobot' => true ] ] ] ]); } public function testPutBinToStore() { $bool = $this->cacheShelfService->putBinToStore($this->data['station'],$this->data['materialBox'],$this->data['stationCacheShelfGrid']); $boxTask = StationTaskMaterialBox::query()->where('station_id',$this->data['station']['id'])->where('material_box_id',$this->data['materialBox']['id'])->first(); $this->assertTrue($bool); $this->assertNotEmpty($boxTask); $this->assertEquals($boxTask['status'],'待处理'); } protected function tearDown(): void { Station::query()->where('id',$this->data['station']['id'])->delete(); MaterialBox::query()->where('id',$this->data['materialBox']['id'])->delete(); StationCacheShelfGrid::query()->where('id',$this->data['stationCacheShelfGrid']['id'])->delete(); StationTaskMaterialBox::query()->where('id',$this->data['stationTaskMaterialBox']['id'])->delete(); parent::tearDown(); } }