public function testHasEnumCodeForEmptyEnumCode() { $enumCode = ''; $className = 'Test\\Entity'; $fieldName = 'testField'; $config = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\Config')->disableOriginalConstructor()->getMock(); $config->expects($this->once())->method('get')->with('enum_code')->will($this->returnValue($enumCode)); $configProvider = $this->getConfigProviderMock(); $this->configManager->expects($this->once())->method('getProvider')->with('enum')->will($this->returnValue($configProvider)); $configProvider->expects($this->once())->method('hasConfig')->with($className, $fieldName)->will($this->returnValue(true)); $configProvider->expects($this->once())->method('getConfig')->with($className, $fieldName)->will($this->returnValue($config)); $this->assertFalse($this->typeHelper->hasEnumCode($className, $fieldName)); }
/** * Checks if the form type should be read-only or not * * @param Options $options * * @return bool */ protected function isReadOnly($options) { /** @var ConfigIdInterface $configId */ $configId = $options['config_id']; $className = $configId->getClassName(); if (empty($className)) { return false; } $fieldName = $this->typeHelper->getFieldName($configId); if (empty($fieldName)) { return false; } // check if new field reuses a public enum if ($options['config_is_new'] && $this->typeHelper->hasEnumCode($className, $fieldName)) { return true; } return false; }