/** * @param ConfigIdInterface $configId * @return string */ protected function buildConfigKey(ConfigIdInterface $configId) { return $configId instanceof FieldConfigId ? $configId->getScope() . '_' . $configId->getClassName() . '_' . $configId->getFieldName() : $configId->getScope() . '_' . $configId->getClassName(); }
/** * @dataProvider getConfigNotCachedProvider */ public function testGetConfigNotCached(ConfigIdInterface $configId, $getModelResult, $expectedConfig) { $this->modelManager->expects($this->any())->method('checkDatabase')->willReturn(true); if ($configId instanceof FieldConfigId) { $this->configCache->expects($this->exactly(2))->method('getConfigurable')->willReturnMap([[$configId->getClassName(), null, true], [$configId->getClassName(), $configId->getFieldName(), true]]); $this->configCache->expects($this->once())->method('getFieldConfig')->with($configId->getScope(), $configId->getClassName(), $configId->getFieldName())->willReturn(null); } else { $this->configCache->expects($this->once())->method('getConfigurable')->with($configId->getClassName())->willReturn(true); $this->configCache->expects($this->once())->method('getEntityConfig')->with($configId->getScope(), $configId->getClassName())->willReturn(null); } $this->configCache->expects($this->once())->method('saveConfig')->with($this->equalTo($expectedConfig)); if ($configId instanceof FieldConfigId) { $this->modelManager->expects($this->never())->method('getEntityModel'); $this->modelManager->expects($this->once())->method('getFieldModel')->with($configId->getClassName(), $configId->getFieldName())->willReturn($getModelResult); } else { $this->modelManager->expects($this->once())->method('getEntityModel')->with($configId->getClassName())->willReturn($getModelResult); $this->modelManager->expects($this->never())->method('getFieldModel'); } $result = $this->configManager->getConfig($configId); $this->assertEquals($expectedConfig, $result); $this->configManager->calculateConfigChangeSet($result); $this->assertEquals([], $this->configManager->getConfigChangeSet($result)); }
/** * Returns a string unique identifies each config item * * @param ConfigIdInterface $configId * @return string */ protected function buildConfigKey(ConfigIdInterface $configId) { return $configId instanceof FieldConfigId ? sprintf('%s_%s_%s', $configId->getScope(), $configId->getClassName(), $configId->getFieldName()) : sprintf('%s_%s', $configId->getScope(), $configId->getClassName()); }