minor #19399 [Config] Extra tests for Config component (zomberg)
This PR was squashed before being merged into the 2.7 branch (closes #19399).
Discussion
----------
[Config] Extra tests for Config component
| Q | A
| ------------- | ---
| Branch? | 2.7
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | ~
| License | MIT
| Doc PR | ~
Commits
-------
d0f4434
[Config] Extra tests for Config component
This commit is contained in:
commit
4af4878e3d
@ -185,6 +185,48 @@ class ArrayNodeDefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testCanBeDisabled()
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$node->canBeDisabled();
|
||||
|
||||
$this->assertTrue($this->getField($node, 'addDefaults'));
|
||||
$this->assertEquals(array('enabled' => false), $this->getField($node, 'falseEquivalent'));
|
||||
$this->assertEquals(array('enabled' => true), $this->getField($node, 'trueEquivalent'));
|
||||
$this->assertEquals(array('enabled' => true), $this->getField($node, 'nullEquivalent'));
|
||||
|
||||
$nodeChildren = $this->getField($node, 'children');
|
||||
$this->assertArrayHasKey('enabled', $nodeChildren);
|
||||
|
||||
$enabledNode = $nodeChildren['enabled'];
|
||||
$this->assertTrue($this->getField($enabledNode, 'default'));
|
||||
$this->assertTrue($this->getField($enabledNode, 'defaultValue'));
|
||||
}
|
||||
|
||||
public function testIgnoreExtraKeys()
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
|
||||
$this->assertFalse($this->getField($node, 'ignoreExtraKeys'));
|
||||
|
||||
$result = $node->ignoreExtraKeys();
|
||||
|
||||
$this->assertEquals($node, $result);
|
||||
$this->assertTrue($this->getField($node, 'ignoreExtraKeys'));
|
||||
}
|
||||
|
||||
public function testNormalizeKeys()
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
|
||||
$this->assertTrue($this->getField($node, 'normalizeKeys'));
|
||||
|
||||
$result = $node->normalizeKeys(false);
|
||||
|
||||
$this->assertEquals($node, $result);
|
||||
$this->assertFalse($this->getField($node, 'normalizeKeys'));
|
||||
}
|
||||
|
||||
public function getEnableableNodeFixtures()
|
||||
{
|
||||
return array(
|
||||
|
@ -150,6 +150,26 @@ class ExprBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(array(), $this->finalizeTestBuilder($test));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage You must specify an if part.
|
||||
*/
|
||||
public function testEndIfPartNotSpecified()
|
||||
{
|
||||
$this->getTestBuilder()->end();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage You must specify a then part.
|
||||
*/
|
||||
public function testEndThenPartNotSpecified()
|
||||
{
|
||||
$builder = $this->getTestBuilder();
|
||||
$builder->ifPart = 'test';
|
||||
$builder->end();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a test treebuilder with a variable node, and init the validation.
|
||||
*
|
||||
|
Reference in New Issue
Block a user