Beispiel #1
0
 /**
  * In case of FieldConfigId replaces OLD field name with given NEW one
  *
  * @param ConfigInterface $config
  * @param string          $newFieldName
  *
  * @return ConfigInterface
  */
 protected function changeConfigFieldName(ConfigInterface $config, $newFieldName)
 {
     $configId = $config->getId();
     if ($configId instanceof FieldConfigId) {
         $newConfigId = new FieldConfigId($configId->getScope(), $configId->getClassName(), $newFieldName, $configId->getFieldType());
         $config = new Config($newConfigId, $config->getValues());
     }
     return $config;
 }
Beispiel #2
0
 public function testSaveFieldConfigValues()
 {
     $config1 = new Config(new FieldConfigId('scope1', self::ENTITY_CLASS, self::FIELD_NAME, self::FIELD_TYPE), ['key1' => 'val1']);
     $config2 = new Config(new FieldConfigId('scope2', self::ENTITY_CLASS, self::FIELD_NAME, self::FIELD_TYPE), ['key2' => 'val2']);
     $this->cache->expects($this->once())->method('save')->willReturnCallback(function ($key, $data) {
         $this->cache->expects($this->once())->method('fetch')->with($key)->willReturn($data);
         return true;
     });
     $this->assertTrue($this->configCache->saveFieldConfigValues([$config1->getId()->getScope() => $config1->getValues(), $config2->getId()->getScope() => $config2->getValues()], self::ENTITY_CLASS, self::FIELD_NAME, self::FIELD_TYPE));
     // test that configs saved right
     $this->assertEquals($config1, $this->configCache->getFieldConfig($config1->getId()->getScope(), self::ENTITY_CLASS, self::FIELD_NAME));
     $this->assertEquals($config2, $this->configCache->getFieldConfig($config2->getId()->getScope(), self::ENTITY_CLASS, self::FIELD_NAME));
 }