public function testExistingField()
 {
     $testFieldName = 'field1';
     $configs = [self::CLASS_NAME => ['fields' => [$testFieldName => ['type' => 'integer', 'configs' => ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM], 'datagrid' => ['is_visible' => false]]]]]];
     $extendConfigEntity = $this->createConfig('extend', self::CLASS_NAME);
     $extendConfigEntity->set('is_extend', true);
     $extendConfigField = $this->createConfig('extend', self::CLASS_NAME, $testFieldName, 'string');
     $datagridConfigField = $this->createConfig('datagrid', self::CLASS_NAME, $testFieldName, 'string');
     $configFieldModel = new FieldConfigModel($testFieldName, 'string');
     // config providers configuration
     $extendConfigProvider = $this->getConfigProviderMock();
     $datagridConfigProvider = $this->getConfigProviderMock();
     $this->configManager->expects($this->any())->method('getProvider')->will($this->returnValueMap([['extend', $extendConfigProvider], ['datagrid', $datagridConfigProvider]]));
     // hasConfig/getConfig expectations
     $this->configManager->expects($this->any())->method('hasConfig')->will($this->returnValueMap([[self::CLASS_NAME, null, true], [self::CLASS_NAME, $testFieldName, true]]));
     $extendConfigProvider->expects($this->any())->method('getConfig')->will($this->returnValueMap([[self::CLASS_NAME, null, $extendConfigEntity], [self::CLASS_NAME, $testFieldName, $extendConfigField]]));
     $datagridConfigProvider->expects($this->any())->method('getConfig')->will($this->returnValueMap([[self::CLASS_NAME, $testFieldName, $datagridConfigField]]));
     $this->configManager->expects($this->never())->method('createConfigFieldModel');
     $this->configManager->expects($this->once())->method('getConfigFieldModel')->with(self::CLASS_NAME, $testFieldName)->will($this->returnValue($configFieldModel));
     $this->configManager->expects($this->once())->method('changeFieldType')->with(self::CLASS_NAME, $testFieldName, 'integer');
     $this->configManager->expects($this->once())->method('flush');
     $this->generator->processConfigs($configs);
     $this->assertEquals(['is_extend' => true], $extendConfigEntity->all());
     $this->assertEquals(['state' => ExtendScope::STATE_UPDATE, 'owner' => ExtendScope::OWNER_CUSTOM], $extendConfigField->all());
     $this->assertEquals(['is_visible' => false], $datagridConfigField->all());
 }
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testAppendForExistingField()
 {
     $testFieldName = 'field1';
     $configs = [self::CLASS_NAME => ['fields' => [$testFieldName => ['type' => 'integer', 'configs' => ['extend' => ['owner' => ExtendScope::OWNER_CUSTOM, 'array_attr1' => ['val1'], 'array_attr2' => ['val2'], 'array_attr3.attr31' => ['val3'], 'array_attr4.attr41' => 'val4']]]]], ExtendConfigProcessor::APPEND_CONFIGS => [self::CLASS_NAME => ['fields' => [$testFieldName => ['configs' => ['extend' => ['array_attr1', 'array_attr2', 'array_attr3.attr31']]]]]]];
     $extendConfigEntity = $this->createConfig('extend', self::CLASS_NAME);
     $extendConfigEntity->set('is_extend', true);
     $extendConfigField = $this->createConfig('extend', self::CLASS_NAME, $testFieldName, 'string');
     $configFieldModel = new FieldConfigModel($testFieldName, 'string');
     // config providers configuration
     $extendConfigProvider = $this->getConfigProviderMock();
     $this->configManager->expects($this->any())->method('getProvider')->with('extend')->willReturn($extendConfigProvider);
     // hasConfig/getConfig expectations
     $this->configManager->expects($this->any())->method('hasConfig')->will($this->returnValueMap([[self::CLASS_NAME, null, true], [self::CLASS_NAME, $testFieldName, true]]));
     $extendConfigProvider->expects($this->any())->method('getConfig')->will($this->returnValueMap([[self::CLASS_NAME, null, $extendConfigEntity], [self::CLASS_NAME, $testFieldName, $extendConfigField]]));
     $this->configManager->expects($this->never())->method('createConfigFieldModel');
     $this->configManager->expects($this->once())->method('getConfigFieldModel')->with(self::CLASS_NAME, $testFieldName)->will($this->returnValue($configFieldModel));
     $this->configManager->expects($this->once())->method('changeFieldType')->with(self::CLASS_NAME, $testFieldName, 'integer');
     $this->configManager->expects($this->once())->method('flush');
     $this->generator->processConfigs($configs);
     $this->assertEquals(['is_extend' => true], $extendConfigEntity->all());
     $this->assertEquals(['state' => ExtendScope::STATE_UPDATE, 'owner' => ExtendScope::OWNER_CUSTOM, 'array_attr1' => ['val1'], 'array_attr2' => ['val2'], 'array_attr3' => ['attr31' => ['val3']], 'array_attr4' => ['attr41' => 'val4']], $extendConfigField->all());
 }