Skip to content

Commit aa4cca3

Browse files
Merge branch '3.4' into 4.3
* 3.4: Fix tests Fix deprecated phpunit annotation
2 parents 066563a + 5cc779a commit aa4cca3

40 files changed

+382
-617
lines changed

Tests/AliasTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ public function testCanOverrideDeprecation()
8787

8888
/**
8989
* @dataProvider invalidDeprecationMessageProvider
90-
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
9190
*/
9291
public function testCannotDeprecateWithAnInvalidTemplate($message)
9392
{
93+
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
9494
$def = new Alias('foo');
9595
$def->setDeprecated(true, $message);
9696
}

Tests/ChildDefinitionTest.php

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

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

1718
class ChildDefinitionTest extends TestCase
1819
{
20+
use ForwardCompatTestTrait;
21+
1922
public function testConstructor()
2023
{
2124
$def = new ChildDefinition('foo');
@@ -89,11 +92,9 @@ public function testSetArgument()
8992
$this->assertSame(['index_0' => 'foo'], $def->getArguments());
9093
}
9194

92-
/**
93-
* @expectedException \InvalidArgumentException
94-
*/
9595
public function testReplaceArgumentShouldRequireIntegerIndex()
9696
{
97+
$this->expectException('InvalidArgumentException');
9798
$def = new ChildDefinition('foo');
9899

99100
$def->replaceArgument('0', 'foo');
@@ -118,11 +119,9 @@ public function testReplaceArgument()
118119
$this->assertSame([0 => 'foo', 1 => 'bar', 'index_1' => 'baz', '$bar' => 'val'], $def->getArguments());
119120
}
120121

121-
/**
122-
* @expectedException \OutOfBoundsException
123-
*/
124122
public function testGetArgumentShouldCheckBounds()
125123
{
124+
$this->expectException('OutOfBoundsException');
126125
$def = new ChildDefinition('foo');
127126

128127
$def->setArguments([0 => 'foo']);
@@ -131,20 +130,16 @@ public function testGetArgumentShouldCheckBounds()
131130
$def->getArgument(1);
132131
}
133132

134-
/**
135-
* @expectedException \Symfony\Component\DependencyInjection\Exception\BadMethodCallException
136-
*/
137133
public function testCannotCallSetAutoconfigured()
138134
{
135+
$this->expectException('Symfony\Component\DependencyInjection\Exception\BadMethodCallException');
139136
$def = new ChildDefinition('foo');
140137
$def->setAutoconfigured(true);
141138
}
142139

143-
/**
144-
* @expectedException \Symfony\Component\DependencyInjection\Exception\BadMethodCallException
145-
*/
146140
public function testCannotCallSetInstanceofConditionals()
147141
{
142+
$this->expectException('Symfony\Component\DependencyInjection\Exception\BadMethodCallException');
148143
$def = new ChildDefinition('foo');
149144
$def->setInstanceofConditionals(['Foo' => new ChildDefinition('')]);
150145
}

Tests/Compiler/AutoAliasServicePassTest.php

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

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\DependencyInjection\Compiler\AutoAliasServicePass;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
1718

1819
class AutoAliasServicePassTest extends TestCase
1920
{
20-
/**
21-
* @expectedException \Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException
22-
*/
21+
use ForwardCompatTestTrait;
22+
2323
public function testProcessWithMissingParameter()
2424
{
25+
$this->expectException('Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException');
2526
$container = new ContainerBuilder();
2627

2728
$container->register('example')
@@ -31,11 +32,9 @@ public function testProcessWithMissingParameter()
3132
$pass->process($container);
3233
}
3334

34-
/**
35-
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
36-
*/
3735
public function testProcessWithMissingFormat()
3836
{
37+
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
3938
$container = new ContainerBuilder();
4039

4140
$container->register('example')

Tests/Compiler/AutowirePassTest.php

Lines changed: 44 additions & 86 deletions
Large diffs are not rendered by default.

Tests/Compiler/CheckArgumentsValidityPassTest.php

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

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\DependencyInjection\Compiler\CheckArgumentsValidityPass;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
1718

@@ -20,6 +21,8 @@
2021
*/
2122
class CheckArgumentsValidityPassTest extends TestCase
2223
{
24+
use ForwardCompatTestTrait;
25+
2326
public function testProcess()
2427
{
2528
$container = new ContainerBuilder();
@@ -41,11 +44,11 @@ public function testProcess()
4144
}
4245

4346
/**
44-
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
4547
* @dataProvider definitionProvider
4648
*/
4749
public function testException(array $arguments, array $methodCalls)
4850
{
51+
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
4952
$container = new ContainerBuilder();
5053
$definition = $container->register('foo');
5154
$definition->setArguments($arguments);

Tests/Compiler/CheckCircularReferencesPassTest.php

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
1617
use Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass;
1718
use Symfony\Component\DependencyInjection\Compiler\CheckCircularReferencesPass;
@@ -21,23 +22,21 @@
2122

2223
class CheckCircularReferencesPassTest extends TestCase
2324
{
24-
/**
25-
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
26-
*/
25+
use ForwardCompatTestTrait;
26+
2727
public function testProcess()
2828
{
29+
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException');
2930
$container = new ContainerBuilder();
3031
$container->register('a')->addArgument(new Reference('b'));
3132
$container->register('b')->addArgument(new Reference('a'));
3233

3334
$this->process($container);
3435
}
3536

36-
/**
37-
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
38-
*/
3937
public function testProcessWithAliases()
4038
{
39+
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException');
4140
$container = new ContainerBuilder();
4241
$container->register('a')->addArgument(new Reference('b'));
4342
$container->setAlias('b', 'c');
@@ -46,11 +45,9 @@ public function testProcessWithAliases()
4645
$this->process($container);
4746
}
4847

49-
/**
50-
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
51-
*/
5248
public function testProcessWithFactory()
5349
{
50+
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException');
5451
$container = new ContainerBuilder();
5552

5653
$container
@@ -64,11 +61,9 @@ public function testProcessWithFactory()
6461
$this->process($container);
6562
}
6663

67-
/**
68-
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
69-
*/
7064
public function testProcessDetectsIndirectCircularReference()
7165
{
66+
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException');
7267
$container = new ContainerBuilder();
7368
$container->register('a')->addArgument(new Reference('b'));
7469
$container->register('b')->addArgument(new Reference('c'));
@@ -77,11 +72,9 @@ public function testProcessDetectsIndirectCircularReference()
7772
$this->process($container);
7873
}
7974

80-
/**
81-
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
82-
*/
8375
public function testProcessDetectsIndirectCircularReferenceWithFactory()
8476
{
77+
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException');
8578
$container = new ContainerBuilder();
8679

8780
$container->register('a')->addArgument(new Reference('b'));
@@ -95,11 +88,9 @@ public function testProcessDetectsIndirectCircularReferenceWithFactory()
9588
$this->process($container);
9689
}
9790

98-
/**
99-
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
100-
*/
10191
public function testDeepCircularReference()
10292
{
93+
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException');
10394
$container = new ContainerBuilder();
10495
$container->register('a')->addArgument(new Reference('b'));
10596
$container->register('b')->addArgument(new Reference('c'));

Tests/Compiler/CheckDefinitionValidityPassTest.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,26 @@
1212
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\DependencyInjection\Compiler\CheckDefinitionValidityPass;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
1718

1819
class CheckDefinitionValidityPassTest extends TestCase
1920
{
20-
/**
21-
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
22-
*/
21+
use ForwardCompatTestTrait;
22+
2323
public function testProcessDetectsSyntheticNonPublicDefinitions()
2424
{
25+
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
2526
$container = new ContainerBuilder();
2627
$container->register('a')->setSynthetic(true)->setPublic(false);
2728

2829
$this->process($container);
2930
}
3031

31-
/**
32-
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
33-
*/
3432
public function testProcessDetectsNonSyntheticNonAbstractDefinitionWithoutClass()
3533
{
34+
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
3635
$container = new ContainerBuilder();
3736
$container->register('a')->setSynthetic(false)->setAbstract(false);
3837

@@ -65,34 +64,28 @@ public function testValidTags()
6564
$this->addToAssertionCount(1);
6665
}
6766

68-
/**
69-
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
70-
*/
7167
public function testInvalidTags()
7268
{
69+
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
7370
$container = new ContainerBuilder();
7471
$container->register('a', 'class')->addTag('foo', ['bar' => ['baz' => 'baz']]);
7572

7673
$this->process($container);
7774
}
7875

79-
/**
80-
* @expectedException \Symfony\Component\DependencyInjection\Exception\EnvParameterException
81-
*/
8276
public function testDynamicPublicServiceName()
8377
{
78+
$this->expectException('Symfony\Component\DependencyInjection\Exception\EnvParameterException');
8479
$container = new ContainerBuilder();
8580
$env = $container->getParameterBag()->get('env(BAR)');
8681
$container->register("foo.$env", 'class')->setPublic(true);
8782

8883
$this->process($container);
8984
}
9085

91-
/**
92-
* @expectedException \Symfony\Component\DependencyInjection\Exception\EnvParameterException
93-
*/
9486
public function testDynamicPublicAliasName()
9587
{
88+
$this->expectException('Symfony\Component\DependencyInjection\Exception\EnvParameterException');
9689
$container = new ContainerBuilder();
9790
$env = $container->getParameterBag()->get('env(BAR)');
9891
$container->setAlias("foo.$env", 'class')->setPublic(true);

Tests/Compiler/CheckExceptionOnInvalidReferenceBehaviorPassTest.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\DependencyInjection\Argument\BoundArgument;
1617
use Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass;
1718
use Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass;
@@ -23,6 +24,8 @@
2324

2425
class CheckExceptionOnInvalidReferenceBehaviorPassTest extends TestCase
2526
{
27+
use ForwardCompatTestTrait;
28+
2629
public function testProcess()
2730
{
2831
$container = new ContainerBuilder();
@@ -38,11 +41,9 @@ public function testProcess()
3841
$this->addToAssertionCount(1);
3942
}
4043

41-
/**
42-
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
43-
*/
4444
public function testProcessThrowsExceptionOnInvalidReference()
4545
{
46+
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException');
4647
$container = new ContainerBuilder();
4748

4849
$container
@@ -53,11 +54,9 @@ public function testProcessThrowsExceptionOnInvalidReference()
5354
$this->process($container);
5455
}
5556

56-
/**
57-
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
58-
*/
5957
public function testProcessThrowsExceptionOnInvalidReferenceFromInlinedDefinition()
6058
{
59+
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException');
6160
$container = new ContainerBuilder();
6261

6362
$def = new Definition();
@@ -85,12 +84,10 @@ public function testProcessDefinitionWithBindings()
8584
$this->addToAssertionCount(1);
8685
}
8786

88-
/**
89-
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
90-
* @expectedExceptionMessage The service "foo" in the container provided to "bar" has a dependency on a non-existent service "baz".
91-
*/
9287
public function testWithErroredServiceLocator()
9388
{
89+
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException');
90+
$this->expectExceptionMessage('The service "foo" in the container provided to "bar" has a dependency on a non-existent service "baz".');
9491
$container = new ContainerBuilder();
9592

9693
ServiceLocatorTagPass::register($container, ['foo' => new Reference('baz')], 'bar');
@@ -100,12 +97,10 @@ public function testWithErroredServiceLocator()
10097
$this->process($container);
10198
}
10299

103-
/**
104-
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
105-
* @expectedExceptionMessage The service "bar" has a dependency on a non-existent service "foo".
106-
*/
107100
public function testWithErroredHiddenService()
108101
{
102+
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException');
103+
$this->expectExceptionMessage('The service "bar" has a dependency on a non-existent service "foo".');
109104
$container = new ContainerBuilder();
110105

111106
ServiceLocatorTagPass::register($container, ['foo' => new Reference('foo')], 'bar');

Tests/Compiler/CheckReferenceValidityPassTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@
1212
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\DependencyInjection\Compiler\CheckReferenceValidityPass;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
1718
use Symfony\Component\DependencyInjection\Reference;
1819

1920
class CheckReferenceValidityPassTest extends TestCase
2021
{
21-
/**
22-
* @expectedException \RuntimeException
23-
*/
22+
use ForwardCompatTestTrait;
23+
2424
public function testProcessDetectsReferenceToAbstractDefinition()
2525
{
26+
$this->expectException('RuntimeException');
2627
$container = new ContainerBuilder();
2728

2829
$container->register('a')->setAbstract(true);

0 commit comments

Comments
 (0)