Skip to content

Commit 96cc8f6

Browse files
Merge branch '4.4' into 5.1
* 4.4: Use createMock() and use import instead of FQCN
2 parents b3059c2 + 2c4c782 commit 96cc8f6

21 files changed

+107
-74
lines changed

Tests/Definition/ArrayNodeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1616
use Symfony\Component\Config\Definition\ArrayNode;
1717
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
18+
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
1819
use Symfony\Component\Config\Definition\ScalarNode;
1920

2021
class ArrayNodeTest extends TestCase
@@ -23,7 +24,7 @@ class ArrayNodeTest extends TestCase
2324

2425
public function testNormalizeThrowsExceptionWhenFalseIsNotAllowed()
2526
{
26-
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class);
27+
$this->expectException(InvalidTypeException::class);
2728
$node = new ArrayNode('root');
2829
$node->normalize(false);
2930
}

Tests/Definition/BooleanNodeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Config\Definition\BooleanNode;
16+
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
1617

1718
class BooleanNodeTest extends TestCase
1819
{
@@ -51,7 +52,7 @@ public function getValidValues()
5152
*/
5253
public function testNormalizeThrowsExceptionOnInvalidValues($value)
5354
{
54-
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class);
55+
$this->expectException(InvalidTypeException::class);
5556
$node = new BooleanNode('test');
5657
$node->normalize($value);
5758
}

Tests/Definition/Builder/ArrayNodeDefinitionTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
use Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition;
1818
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
1919
use Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition;
20+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
2021
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
2122
use Symfony\Component\Config\Definition\Processor;
23+
use Symfony\Component\Config\Definition\PrototypedArrayNode;
2224

2325
class ArrayNodeDefinitionTest extends TestCase
2426
{
@@ -155,8 +157,8 @@ public function testNestedPrototypedArrayNodes()
155157
;
156158
$node = $nodeDefinition->getNode();
157159

158-
$this->assertInstanceOf(\Symfony\Component\Config\Definition\PrototypedArrayNode::class, $node);
159-
$this->assertInstanceOf(\Symfony\Component\Config\Definition\PrototypedArrayNode::class, $node->getPrototype());
160+
$this->assertInstanceOf(PrototypedArrayNode::class, $node);
161+
$this->assertInstanceOf(PrototypedArrayNode::class, $node->getPrototype());
160162
}
161163

162164
public function testEnabledNodeDefaults()
@@ -320,7 +322,7 @@ public function testRequiresAtLeastOneElement()
320322

321323
public function testCannotBeEmpty()
322324
{
323-
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
325+
$this->expectException(InvalidConfigurationException::class);
324326
$this->expectExceptionMessage('The path "root" should have at least 1 element(s) defined.');
325327
$node = new ArrayNodeDefinition('root');
326328
$node

Tests/Definition/Builder/BooleanNodeDefinitionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition;
16+
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
1617

1718
class BooleanNodeDefinitionTest extends TestCase
1819
{
1920
public function testCannotBeEmptyThrowsAnException()
2021
{
21-
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidDefinitionException::class);
22+
$this->expectException(InvalidDefinitionException::class);
2223
$this->expectExceptionMessage('->cannotBeEmpty() is not applicable to BooleanNodeDefinition.');
2324
$def = new BooleanNodeDefinition('foo');
2425
$def->cannotBeEmpty();

Tests/Definition/Builder/ExprBuilderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Config\Definition\Builder\ExprBuilder;
1616
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
17+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1718

1819
class ExprBuilderTest extends TestCase
1920
{
@@ -167,7 +168,7 @@ public function castToArrayValues()
167168

168169
public function testThenInvalid()
169170
{
170-
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
171+
$this->expectException(InvalidConfigurationException::class);
171172
$test = $this->getTestBuilder()
172173
->ifString()
173174
->thenInvalid('Invalid value')

Tests/Definition/Builder/NodeBuilderTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespace Symfony\Component\Config\Tests\Definition\Builder;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Config\Definition\Builder\FloatNodeDefinition;
16+
use Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition;
1517
use Symfony\Component\Config\Definition\Builder\NodeBuilder as BaseNodeBuilder;
1618
use Symfony\Component\Config\Definition\Builder\VariableNodeDefinition as BaseVariableNodeDefinition;
1719

@@ -79,10 +81,10 @@ public function testNumericNodeCreation()
7981
$builder = new BaseNodeBuilder();
8082

8183
$node = $builder->integerNode('foo')->min(3)->max(5);
82-
$this->assertInstanceOf(\Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition::class, $node);
84+
$this->assertInstanceOf(IntegerNodeDefinition::class, $node);
8385

8486
$node = $builder->floatNode('bar')->min(3.0)->max(5.0);
85-
$this->assertInstanceOf(\Symfony\Component\Config\Definition\Builder\FloatNodeDefinition::class, $node);
87+
$this->assertInstanceOf(FloatNodeDefinition::class, $node);
8688
}
8789
}
8890

Tests/Definition/Builder/NumericNodeDefinitionTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Config\Definition\Builder\FloatNodeDefinition;
1616
use Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition;
17+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
18+
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
1719

1820
class NumericNodeDefinitionTest extends TestCase
1921
{
@@ -35,15 +37,15 @@ public function testIncoherentMaxAssertion()
3537

3638
public function testIntegerMinAssertion()
3739
{
38-
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
40+
$this->expectException(InvalidConfigurationException::class);
3941
$this->expectExceptionMessage('The value 4 is too small for path "foo". Should be greater than or equal to 5');
4042
$def = new IntegerNodeDefinition('foo');
4143
$def->min(5)->getNode()->finalize(4);
4244
}
4345

4446
public function testIntegerMaxAssertion()
4547
{
46-
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
48+
$this->expectException(InvalidConfigurationException::class);
4749
$this->expectExceptionMessage('The value 4 is too big for path "foo". Should be less than or equal to 3');
4850
$def = new IntegerNodeDefinition('foo');
4951
$def->max(3)->getNode()->finalize(4);
@@ -58,15 +60,15 @@ public function testIntegerValidMinMaxAssertion()
5860

5961
public function testFloatMinAssertion()
6062
{
61-
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
63+
$this->expectException(InvalidConfigurationException::class);
6264
$this->expectExceptionMessage('The value 400 is too small for path "foo". Should be greater than or equal to 500');
6365
$def = new FloatNodeDefinition('foo');
6466
$def->min(5E2)->getNode()->finalize(4e2);
6567
}
6668

6769
public function testFloatMaxAssertion()
6870
{
69-
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
71+
$this->expectException(InvalidConfigurationException::class);
7072
$this->expectExceptionMessage('The value 4.3 is too big for path "foo". Should be less than or equal to 0.3');
7173
$def = new FloatNodeDefinition('foo');
7274
$def->max(0.3)->getNode()->finalize(4.3);
@@ -81,7 +83,7 @@ public function testFloatValidMinMaxAssertion()
8183

8284
public function testCannotBeEmptyThrowsAnException()
8385
{
84-
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidDefinitionException::class);
86+
$this->expectException(InvalidDefinitionException::class);
8587
$this->expectExceptionMessage('->cannotBeEmpty() is not applicable to NumericNodeDefinition.');
8688
$def = new IntegerNodeDefinition('foo');
8789
$def->cannotBeEmpty();

Tests/Definition/Builder/TreeBuilderTest.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@
1212
namespace Symfony\Component\Config\Tests\Definition\Builder;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Config\Definition\BaseNode;
16+
use Symfony\Component\Config\Definition\BooleanNode;
17+
use Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition;
1518
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
19+
use Symfony\Component\Config\Tests\Fixtures\BarNode;
20+
use Symfony\Component\Config\Tests\Fixtures\Builder\BarNodeDefinition;
1621
use Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder as CustomNodeBuilder;
22+
use Symfony\Component\Config\Tests\Fixtures\Builder\VariableNodeDefinition;
1723

1824
class TreeBuilderTest extends TestCase
1925
{
@@ -23,11 +29,11 @@ public function testUsingACustomNodeBuilder()
2329

2430
$nodeBuilder = $builder->getRootNode()->children();
2531

26-
$this->assertInstanceOf(\Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder::class, $nodeBuilder);
32+
$this->assertInstanceOf(CustomNodeBuilder::class, $nodeBuilder);
2733

2834
$nodeBuilder = $nodeBuilder->arrayNode('deeper')->children();
2935

30-
$this->assertInstanceOf(\Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder::class, $nodeBuilder);
36+
$this->assertInstanceOf(CustomNodeBuilder::class, $nodeBuilder);
3137
}
3238

3339
public function testOverrideABuiltInNodeType()
@@ -36,7 +42,7 @@ public function testOverrideABuiltInNodeType()
3642

3743
$definition = $builder->getRootNode()->children()->variableNode('variable');
3844

39-
$this->assertInstanceOf(\Symfony\Component\Config\Tests\Fixtures\Builder\VariableNodeDefinition::class, $definition);
45+
$this->assertInstanceOf(VariableNodeDefinition::class, $definition);
4046
}
4147

4248
public function testAddANodeType()
@@ -45,7 +51,7 @@ public function testAddANodeType()
4551

4652
$definition = $builder->getRootNode()->children()->barNode('variable');
4753

48-
$this->assertInstanceOf(\Symfony\Component\Config\Tests\Fixtures\Builder\BarNodeDefinition::class, $definition);
54+
$this->assertInstanceOf(BarNodeDefinition::class, $definition);
4955
}
5056

5157
public function testCreateABuiltInNodeTypeWithACustomNodeBuilder()
@@ -54,7 +60,7 @@ public function testCreateABuiltInNodeTypeWithACustomNodeBuilder()
5460

5561
$definition = $builder->getRootNode()->children()->booleanNode('boolean');
5662

57-
$this->assertInstanceOf(\Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition::class, $definition);
63+
$this->assertInstanceOf(BooleanNodeDefinition::class, $definition);
5864
}
5965

6066
public function testPrototypedArrayNodeUseTheCustomNodeBuilder()
@@ -64,7 +70,7 @@ public function testPrototypedArrayNodeUseTheCustomNodeBuilder()
6470
$root = $builder->getRootNode();
6571
$root->prototype('bar')->end();
6672

67-
$this->assertInstanceOf(\Symfony\Component\Config\Tests\Fixtures\BarNode::class, $root->getNode(true)->getPrototype());
73+
$this->assertInstanceOf(BarNode::class, $root->getNode(true)->getPrototype());
6874
}
6975

7076
public function testAnExtendedNodeBuilderGetsPropagatedToTheChildren()
@@ -86,11 +92,11 @@ public function testAnExtendedNodeBuilderGetsPropagatedToTheChildren()
8692
$node = $builder->buildTree();
8793
$children = $node->getChildren();
8894

89-
$this->assertInstanceOf(\Symfony\Component\Config\Definition\BooleanNode::class, $children['foo']);
95+
$this->assertInstanceOf(BooleanNode::class, $children['foo']);
9096

9197
$childChildren = $children['child']->getChildren();
9298

93-
$this->assertInstanceOf(\Symfony\Component\Config\Definition\BooleanNode::class, $childChildren['foo']);
99+
$this->assertInstanceOf(BooleanNode::class, $childChildren['foo']);
94100
}
95101

96102
public function testDefinitionInfoGetsTransferredToNode()
@@ -147,14 +153,14 @@ public function testDefaultPathSeparatorIsDot()
147153
$children = $node->getChildren();
148154

149155
$this->assertArrayHasKey('foo', $children);
150-
$this->assertInstanceOf(\Symfony\Component\Config\Definition\BaseNode::class, $children['foo']);
156+
$this->assertInstanceOf(BaseNode::class, $children['foo']);
151157
$this->assertSame('propagation.foo', $children['foo']->getPath());
152158

153159
$this->assertArrayHasKey('child', $children);
154160
$childChildren = $children['child']->getChildren();
155161

156162
$this->assertArrayHasKey('foo', $childChildren);
157-
$this->assertInstanceOf(\Symfony\Component\Config\Definition\BaseNode::class, $childChildren['foo']);
163+
$this->assertInstanceOf(BaseNode::class, $childChildren['foo']);
158164
$this->assertSame('propagation.child.foo', $childChildren['foo']->getPath());
159165
}
160166

@@ -178,14 +184,14 @@ public function testPathSeparatorIsPropagatedToChildren()
178184
$children = $node->getChildren();
179185

180186
$this->assertArrayHasKey('foo', $children);
181-
$this->assertInstanceOf(\Symfony\Component\Config\Definition\BaseNode::class, $children['foo']);
187+
$this->assertInstanceOf(BaseNode::class, $children['foo']);
182188
$this->assertSame('propagation/foo', $children['foo']->getPath());
183189

184190
$this->assertArrayHasKey('child', $children);
185191
$childChildren = $children['child']->getChildren();
186192

187193
$this->assertArrayHasKey('foo', $childChildren);
188-
$this->assertInstanceOf(\Symfony\Component\Config\Definition\BaseNode::class, $childChildren['foo']);
194+
$this->assertInstanceOf(BaseNode::class, $childChildren['foo']);
189195
$this->assertSame('propagation/child/foo', $childChildren['foo']->getPath());
190196
}
191197
}

Tests/Definition/EnumNodeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Config\Definition\EnumNode;
16+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1617

1718
class EnumNodeTest extends TestCase
1819
{
@@ -49,7 +50,7 @@ public function testConstructionWithNullName()
4950

5051
public function testFinalizeWithInvalidValue()
5152
{
52-
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);
53+
$this->expectException(InvalidConfigurationException::class);
5354
$this->expectExceptionMessage('The value "foobar" is not allowed for path "foo". Permissible values: "foo", "bar"');
5455
$node = new EnumNode('foo', null, ['foo', 'bar']);
5556
$node->finalize('foobar');

Tests/Definition/FloatNodeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Config\Tests\Definition;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
1516
use Symfony\Component\Config\Definition\FloatNode;
1617

1718
class FloatNodeTest extends TestCase
@@ -57,7 +58,7 @@ public function getValidValues()
5758
*/
5859
public function testNormalizeThrowsExceptionOnInvalidValues($value)
5960
{
60-
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidTypeException::class);
61+
$this->expectException(InvalidTypeException::class);
6162
$node = new FloatNode('test');
6263
$node->normalize($value);
6364
}

0 commit comments

Comments
 (0)