/** * @dataProvider getEmptyValues * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * * @param mixed $value */ public function testNotAllowedEmptyValuesThrowException($value) { $node = new ScalarNode('test'); $node->setAllowEmptyValue(false); $node->finalize($value); }
/** * Configures a scalar node. * * @param ScalarNode $configNode The node to configure * @param NodeBuilder $node The builder of the node */ protected function configureScalarNode(ScalarNode $configNode, NodeBuilder $node) { if (null !== $node->normalization) { $configNode->setNormalizationClosures($this->buildExpressions($node->normalization->before)); } if (null !== $node->merge) { $configNode->setAllowOverwrite($node->merge->allowOverwrite); } if (true === $node->default) { $configNode->setDefaultValue($node->defaultValue); } if (false === $node->allowEmptyValue) { $configNode->setAllowEmptyValue($node->allowEmptyValue); } $configNode->addEquivalentValue(null, $node->nullEquivalent); $configNode->addEquivalentValue(true, $node->trueEquivalent); $configNode->addEquivalentValue(false, $node->falseEquivalent); $configNode->setRequired($node->required); if (null !== $node->validation) { $configNode->setFinalValidationClosures($this->buildExpressions($node->validation->rules)); } }