Skip to content

Commit

Permalink
minor #19399 [Config] Extra tests for Config component (zomberg)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nicolas-grekas committed Jul 26, 2016
2 parents b27b0a9 + d0f4434 commit 4af4878
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
Expand Up @@ -185,6 +185,48 @@ public function testTrueEnableEnabledNode($expected, $config, $message)
);
}

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(
Expand Down
Expand Up @@ -150,6 +150,26 @@ public function testThenUnsetExpression()
$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.
*
Expand Down

0 comments on commit 4af4878

Please sign in to comment.