Revert "bug #25789 Enableable ArrayNodeDefinition is disabled for empty configuration (kejwmen)"
This reverts commit132cec44f2
, reversing changes made tod41130153e
.
This commit is contained in:
parent
1fedcffbb9
commit
9312f794e8
@ -226,9 +226,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
|||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
->ifArray()
|
->ifArray()
|
||||||
->then(function ($v) {
|
->then(function ($v) {
|
||||||
if (!isset($v['enabled'])) {
|
$v['enabled'] = isset($v['enabled']) ? $v['enabled'] : true;
|
||||||
$v['enabled'] = !empty($v);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $v;
|
return $v;
|
||||||
})
|
})
|
||||||
|
@ -207,20 +207,6 @@ class ArrayNodeDefinitionTest extends TestCase
|
|||||||
$this->assertTrue($this->getField($enabledNode, 'defaultValue'));
|
$this->assertTrue($this->getField($enabledNode, 'defaultValue'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEnableableNodeIsDisabledForEmptyConfigurationWhenNormalized()
|
|
||||||
{
|
|
||||||
$config = array();
|
|
||||||
|
|
||||||
$node = new ArrayNodeDefinition('root');
|
|
||||||
$node->canBeEnabled();
|
|
||||||
|
|
||||||
$this->assertEquals(
|
|
||||||
array('enabled' => false),
|
|
||||||
$node->getNode()->normalize($config),
|
|
||||||
'An enableable node is disabled by default'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIgnoreExtraKeys()
|
public function testIgnoreExtraKeys()
|
||||||
{
|
{
|
||||||
$node = new ArrayNodeDefinition('root');
|
$node = new ArrayNodeDefinition('root');
|
||||||
@ -254,7 +240,6 @@ class ArrayNodeDefinitionTest extends TestCase
|
|||||||
array(array('enabled' => true, 'foo' => 'baz'), array(array('foo' => 'baz')), 'any configuration enables an enableable node'),
|
array(array('enabled' => true, 'foo' => 'baz'), array(array('foo' => 'baz')), 'any configuration enables an enableable node'),
|
||||||
array(array('enabled' => false, 'foo' => 'baz'), array(array('foo' => 'baz', 'enabled' => false)), 'An enableable node can be disabled'),
|
array(array('enabled' => false, 'foo' => 'baz'), array(array('foo' => 'baz', 'enabled' => false)), 'An enableable node can be disabled'),
|
||||||
array(array('enabled' => false, 'foo' => 'bar'), array(false), 'false disables an enableable node'),
|
array(array('enabled' => false, 'foo' => 'bar'), array(false), 'false disables an enableable node'),
|
||||||
array(array('enabled' => false, 'foo' => 'bar'), array(), 'enableable node is disabled by default'),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
namespace Symfony\Component\Config\Tests\Definition\Builder;
|
namespace Symfony\Component\Config\Tests\Definition\Builder;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Config\Definition\Processor;
|
|
||||||
use Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder as CustomNodeBuilder;
|
use Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder as CustomNodeBuilder;
|
||||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||||
|
|
||||||
@ -132,22 +131,4 @@ class TreeBuilderTest extends TestCase
|
|||||||
$this->assertInternalType('array', $tree->getExample());
|
$this->assertInternalType('array', $tree->getExample());
|
||||||
$this->assertEquals('example', $children['child']->getExample());
|
$this->assertEquals('example', $children['child']->getExample());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRootNodeThatCanBeEnabledIsDisabledByDefault()
|
|
||||||
{
|
|
||||||
$builder = new TreeBuilder();
|
|
||||||
|
|
||||||
$builder->root('test')
|
|
||||||
->canBeEnabled();
|
|
||||||
|
|
||||||
$tree = $builder->buildTree();
|
|
||||||
$children = $tree->getChildren();
|
|
||||||
|
|
||||||
$this->assertFalse($children['enabled']->getDefaultValue());
|
|
||||||
|
|
||||||
$processor = new Processor();
|
|
||||||
$result = $processor->process($tree, array());
|
|
||||||
|
|
||||||
$this->assertEquals(array('enabled' => false), $result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user