8000 minor #19399 [Config] Extra tests for Config component (zomberg) · l-vo/symfony@4af4878 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4af4878

Browse files
minor symfony#19399 [Config] Extra tests for Config component (zomberg)
This PR was squashed before being merged into the 2.7 branch (closes symfony#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
2 parents b27b0a9 + d0f4434 commit 4af4878

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,48 @@ public function testTrueEnableEnabledNode($expected, $config, $message)
185185
);
186186
}
187187

188+
public function testCanBeDisabled()
189+
{
190+
$node = new ArrayNodeDefinition('root');
191+
$node->canBeDisabled();
192+
193+
$this->assertTrue($this->getField($node, 'addDefaults'));
194+
$this->assertEquals(array('enabled' => false), $this->getField($node, 'falseEquivalent'));
195+
$this->assertEquals(array('enabled' => true), $this->getField($node, 'trueEquivalent'));
196+
$this->assertEquals(array('enabled' => true), $this->getField($node, 'nullEquivalent'));
197+
198+
$nodeChildren = $this->getField($node, 'children');
199+
$this->assertArrayHasKey('enabled', $nodeChildren);
200+
201+
$enabledNode = $nodeChildren['enabled'];
202+
$this->assertTrue($this->getField($enabledNode, 'default'));
203+
$this->assertTrue($this->getField($enabledNode, 'defaultValue'));
204+
}
205+
206+
public function testIgnoreExtraKeys()
207+
{
208+
$node = new ArrayNodeDefinition('root');
209+
210+
$this->assertFalse($this->getField($node, 'ignoreExtraKeys'));
211+
212+
$result = $node->ignoreExtraKeys();
213+
214+
$this->assertEquals($node, $result);
215+
$this->assertTrue($this->getField($node, 'ignoreExtraKeys'));
216+
}
217+
218+
public function testNormalizeKeys()
219+
{
220+
$node = new ArrayNodeDefinition('root');
221+
222+
$this->assertTrue($this->getField($node, 'normalizeKeys'));
223+
224+
$result = $node->normalizeKeys(false);
225+
226+
$this->assertEquals($node, $result);
227+
$this->assertFalse($this->getField($node, 'normalizeKeys'));
228+
}
229+
188230
public function getEnableableNodeFixtures()
189231
{
190232
return array(

src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,26 @@ public function testThenUnsetExpression()
150150
$this->assertEquals(array(), $this->finalizeTestBuilder($test));
151151
}
152152

153+
/**
154+
* @expectedException \RuntimeException
155+
* @expectedExceptionMessage You must specify an if part.
156+
*/
157+
public function testEndIfPartNotSpecified()
158+
{
159+
$this->getTestBuilder()->end();
160+
}
161+
162+
/**
163+
* @expectedException \RuntimeException
164+
* @expectedExceptionMessage You must specify a then part.
165+
*/
166+
public function testEndThenPartNotSpecified()
167+
{
168+
$builder = $this->getTestBuilder();
169+
$builder->ifPart = 'test';
170+
$builder->end();
171+
}
172+
153173
/**
154174
* Create a test treebuilder with a variable node, and init the validation.
155175
*

0 commit comments

Comments
 (0)
0