Skip to content

Commit 8f3c948

Browse files
committed
Fix deprecated phpunit annotation
1 parent 174a1b6 commit 8f3c948

22 files changed

+120
-143
lines changed

Tests/ConfigCacheFactoryTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@
1212
namespace Symfony\Component\Config\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Config\ConfigCacheFactory;
1617

1718
class ConfigCacheFactoryTest extends TestCase
1819
{
19-
/**
20-
* @expectedException \InvalidArgumentException
21-
* @expectedExceptionMessage Invalid type for callback argument. Expected callable, but got "object".
22-
*/
20+
use ForwardCompatTestTrait;
21+
2322
public function testCacheWithInvalidCallback()
2423
{
24+
$this->expectException('InvalidArgumentException');
25+
$this->expectExceptionMessage('Invalid type for callback argument. Expected callable, but got "object".');
2526
$cacheFactory = new ConfigCacheFactory(true);
2627

2728
$cacheFactory->cache('file', new \stdClass());

Tests/Definition/ArrayNodeTest.php

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,17 @@ class ArrayNodeTest extends TestCase
2121
{
2222
use ForwardCompatTestTrait;
2323

24-
/**
25-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidTypeException
26-
*/
2724
public function testNormalizeThrowsExceptionWhenFalseIsNotAllowed()
2825
{
26+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException');
2927
$node = new ArrayNode('root');
3028
$node->normalize(false);
3129
}
3230

33-
/**
34-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
35-
* @expectedExceptionMessage Unrecognized option "foo" under "root"
36-
*/
3731
public function testExceptionThrownOnUnrecognizedChild()
3832
{
33+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
34+
$this->expectExceptionMessage('Unrecognized option "foo" under "root"');
3935
$node = new ArrayNode('root');
4036
$node->normalize(['foo' => 'bar']);
4137
}
@@ -179,24 +175,20 @@ public function getPreNormalizedNormalizedOrderedData()
179175
];
180176
}
181177

182-
/**
183-
* @expectedException \InvalidArgumentException
184-
* @expectedExceptionMessage Child nodes must be named.
185-
*/
186178
public function testAddChildEmptyName()
187179
{
180+
$this->expectException('InvalidArgumentException');
181+
$this->expectExceptionMessage('Child nodes must be named.');
188182
$node = new ArrayNode('root');
189183

190184
$childNode = new ArrayNode('');
191185
$node->addChild($childNode);
192186
}
193187

194-
/**
195-
* @expectedException \InvalidArgumentException
196-
* @expectedExceptionMessage A child node named "foo" already exists.
197-
*/
198188
public function testAddChildNameAlreadyExists()
199189
{
190+
$this->expectException('InvalidArgumentException');
191+
$this->expectExceptionMessage('A child node named "foo" already exists.');
200192
$node = new ArrayNode('root');
201193

202194
$childNode = new ArrayNode('foo');
@@ -206,12 +198,10 @@ public function testAddChildNameAlreadyExists()
206198
$node->addChild($childNodeWithSameName);
207199
}
208200

209-
/**
210-
* @expectedException \RuntimeException
211-
* @expectedExceptionMessage The node at path "foo" has no default value.
212-
*/
213201
public function testGetDefaultValueWithoutDefaultValue()
214202
{
203+
$this->expectException('RuntimeException');
204+
$this->expectExceptionMessage('The node at path "foo" has no default value.');
215205
$node = new ArrayNode('foo');
216206
$node->getDefaultValue();
217207
}

Tests/Definition/BooleanNodeTest.php

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

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Config\Definition\BooleanNode;
1617

1718
class BooleanNodeTest extends TestCase
1819
{
20+
use ForwardCompatTestTrait;
21+
1922
/**
2023
* @dataProvider getValidValues
2124
*/
@@ -48,10 +51,10 @@ public function getValidValues()
4851

4952
/**
5053
* @dataProvider getInvalidValues
51-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidTypeException
5254
*/
5355
public function testNormalizeThrowsExceptionOnInvalidValues($value)
5456
{
57+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException');
5558
$node = new BooleanNode('test');
5659
$node->normalize($value);
5760
}

Tests/Definition/Builder/ArrayNodeDefinitionTest.php

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

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
1617
use Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition;
1718
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
1819
use Symfony\Component\Config\Definition\Processor;
1920

2021
class ArrayNodeDefinitionTest extends TestCase
2122
{
23+
use ForwardCompatTestTrait;
24+
2225
public function testAppendingSomeNode()
2326
{
2427
$parent = new ArrayNodeDefinition('root');
@@ -36,11 +39,11 @@ public function testAppendingSomeNode()
3639
}
3740

3841
/**
39-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidDefinitionException
4042
* @dataProvider providePrototypeNodeSpecificCalls
4143
*/
4244
public function testPrototypeNodeSpecificOption($method, $args)
4345
{
46+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidDefinitionException');
4447
$node = new ArrayNodeDefinition('root');
4548

4649
\call_user_func_array([$node, $method], $args);
@@ -58,11 +61,9 @@ public function providePrototypeNodeSpecificCalls()
5861
];
5962
}
6063

61-
/**
62-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidDefinitionException
63-
*/
6464
public function testConcreteNodeSpecificOption()
6565
{
66+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidDefinitionException');
6667
$node = new ArrayNodeDefinition('root');
6768
$node
6869
->addDefaultsIfNotSet()
@@ -71,11 +72,9 @@ public function testConcreteNodeSpecificOption()
7172
$node->getNode();
7273
}
7374

74-
/**
75-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidDefinitionException
76-
*/
7775
public function testPrototypeNodesCantHaveADefaultValueWhenUsingDefaultChildren()
7876
{
77+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidDefinitionException');
7978
$node = new ArrayNodeDefinition('root');
8079
$node
8180
->defaultValue([])

Tests/Definition/Builder/BooleanNodeDefinitionTest.php

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

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition;
1617

1718
class BooleanNodeDefinitionTest extends TestCase
1819
{
19-
/**
20-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidDefinitionException
21-
* @expectedExceptionMessage ->cannotBeEmpty() is not applicable to BooleanNodeDefinition.
22-
*/
20+
use ForwardCompatTestTrait;
21+
2322
public function testCannotBeEmptyThrowsAnException()
2423
{
24+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidDefinitionException');
25+
$this->expectExceptionMessage('->cannotBeEmpty() is not applicable to BooleanNodeDefinition.');
2526
$def = new BooleanNodeDefinition('foo');
2627
$def->cannotBeEmpty();
2728
}

Tests/Definition/Builder/EnumNodeDefinitionTest.php

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

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Config\Definition\Builder\EnumNodeDefinition;
1617

1718
class EnumNodeDefinitionTest extends TestCase
1819
{
20+
use ForwardCompatTestTrait;
21+
1922
public function testWithOneValue()
2023
{
2124
$def = new EnumNodeDefinition('foo');
@@ -34,22 +37,18 @@ public function testWithOneDistinctValue()
3437
$this->assertEquals(['foo'], $node->getValues());
3538
}
3639

37-
/**
38-
* @expectedException \RuntimeException
39-
* @expectedExceptionMessage You must call ->values() on enum nodes.
40-
*/
4140
public function testNoValuesPassed()
4241
{
42+
$this->expectException('RuntimeException');
43+
$this->expectExceptionMessage('You must call ->values() on enum nodes.');
4344
$def = new EnumNodeDefinition('foo');
4445
$def->getNode();
4546
}
4647

47-
/**
48-
* @expectedException \InvalidArgumentException
49-
* @expectedExceptionMessage ->values() must be called with at least one value.
50-
*/
5148
public function testWithNoValues()
5249
{
50+
$this->expectException('InvalidArgumentException');
51+
$this->expectExceptionMessage('->values() must be called with at least one value.');
5352
$def = new EnumNodeDefinition('foo');
5453
$def->values([]);
5554
}

Tests/Definition/Builder/ExprBuilderTest.php

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

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
1617

1718
class ExprBuilderTest extends TestCase
1819
{
20+
use ForwardCompatTestTrait;
21+
1922
public function testAlwaysExpression()
2023
{
2124
$test = $this->getTestBuilder()
@@ -164,11 +167,9 @@ public function castToArrayValues()
164167
yield [['value'], ['value']];
165168
}
166169

167-
/**
168-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
169-
*/
170170
public function testThenInvalid()
171171
{
172+
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException');
172173
$test = $this->getTestBuilder()
173174
->ifString()
174175
->thenInvalid('Invalid value')
@@ -185,21 +186,17 @@ public function testThenUnsetExpression()
185186
$this->assertEquals([], $this->finalizeTestBuilder($test));
186187
}
187188

188-
/**
189-
* @expectedException \RuntimeException
190-
* @expectedExceptionMessage You must specify an if part.
191-
*/
192189
public function testEndIfPartNotSpecified()
193190
{
191+
$this->expectException('RuntimeException');
192+
$this->expectExceptionMessage('You must specify an if part.');
194193
$this->getTestBuilder()->end();
195194
}
196195

197-
/**
198-
* @expectedException \RuntimeException
199-
* @expectedExceptionMessage You must specify a then part.
200-
*/
201196
public function testEndThenPartNotSpecified()
202197
{
198+
$this->expectException('RuntimeException');
199+
$this->expectExceptionMessage('You must specify a then part.');
203200
$builder = $this->getTestBuilder();
204201
$builder->ifPart = 'test';
205202
$builder->end();

Tests/Definition/Builder/NodeBuilderTest.php

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

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Config\Definition\Builder\NodeBuilder as BaseNodeBuilder;
1617
use Symfony\Component\Config\Definition\Builder\VariableNodeDefinition as BaseVariableNodeDefinition;
1718

1819
class NodeBuilderTest extends TestCase
1920
{
20-
/**
21-
* @expectedException \RuntimeException
22-
*/
21+
use ForwardCompatTestTrait;
22+
2323
public function testThrowsAnExceptionWhenTryingToCreateANonRegisteredNodeType()
2424
{
25+
$this->expectException('RuntimeException');
2526
$builder = new BaseNodeBuilder();
2627
$builder->node('', 'foobar');
2728
}
2829

29-
/**
30-
* @expectedException \RuntimeException
31-
*/
3230
public function testThrowsAnExceptionWhenTheNodeClassIsNotFound()
3331
{
32+
$this->expectException('RuntimeException');
3433
$builder = new BaseNodeBuilder();
3534
$builder
3635
->setNodeClass('noclasstype', '\\foo\\bar\\noclass')

0 commit comments

Comments
 (0)