Skip to content

Commit 2468b95

Browse files
OskarStarknicolas-grekas
authored andcommitted
Use createMock() and use import instead of FQCN
1 parent d749132 commit 2468b95

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+223
-150
lines changed

Tests/AliasTest.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\DependencyInjection\Alias;
16+
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
1617

1718
class AliasTest extends TestCase
1819
{
@@ -90,7 +91,7 @@ public function testCanOverrideDeprecation()
9091
*/
9192
public function testCannotDeprecateWithAnInvalidTemplate($message)
9293
{
93-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
94+
$this->expectException(InvalidArgumentException::class);
9495
$def = new Alias('foo');
9596
$def->setDeprecated(true, $message);
9697
}

Tests/ChildDefinitionTest.php

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

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DependencyInjection\ChildDefinition;
16+
use Symfony\Component\DependencyInjection\Exception\BadMethodCallException;
1617

1718
class ChildDefinitionTest extends TestCase
1819
{
@@ -129,14 +130,14 @@ public function testGetArgumentShouldCheckBounds()
129130

130131
public function testCannotCallSetAutoconfigured()
131132
{
132-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\BadMethodCallException::class);
133+
$this->expectException(BadMethodCallException::class);
133134
$def = new ChildDefinition('foo');
134135
$def->setAutoconfigured(true);
135136
}
136137

137138
public function testCannotCallSetInstanceofConditionals()
138139
{
139-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\BadMethodCallException::class);
140+
$this->expectException(BadMethodCallException::class);
140141
$def = new ChildDefinition('foo');
141142
$def->setInstanceofConditionals(['Foo' => new ChildDefinition('')]);
142143
}

Tests/Compiler/AutoAliasServicePassTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DependencyInjection\Compiler\AutoAliasServicePass;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
17+
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
18+
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
1719

1820
class AutoAliasServicePassTest extends TestCase
1921
{
2022
public function testProcessWithMissingParameter()
2123
{
22-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException::class);
24+
$this->expectException(ParameterNotFoundException::class);
2325
$container = new ContainerBuilder();
2426

2527
$container->register('example')
@@ -31,7 +33,7 @@ public function testProcessWithMissingParameter()
3133

3234
public function testProcessWithMissingFormat()
3335
{
34-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
36+
$this->expectException(InvalidArgumentException::class);
3537
$container = new ContainerBuilder();
3638

3739
$container->register('example')

Tests/Compiler/CheckArgumentsValidityPassTest.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\DependencyInjection\Compiler\CheckArgumentsValidityPass;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
17+
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
1718

1819
/**
1920
* @author Kévin Dunglas <dunglas@gmail.com>
@@ -45,7 +46,7 @@ public function testProcess()
4546
*/
4647
public function testException(array $arguments, array $methodCalls)
4748
{
48-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class);
49+
$this->expectException(RuntimeException::class);
4950
$container = new ContainerBuilder();
5051
$definition = $container->register('foo');
5152
$definition->setArguments($arguments);

Tests/Compiler/CheckCircularReferencesPassTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
use Symfony\Component\DependencyInjection\Compiler\CheckCircularReferencesPass;
1818
use Symfony\Component\DependencyInjection\Compiler\Compiler;
1919
use Symfony\Component\DependencyInjection\ContainerBuilder;
20+
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
2021
use Symfony\Component\DependencyInjection\Reference;
2122

2223
class CheckCircularReferencesPassTest extends TestCase
2324
{
2425
public function testProcess()
2526
{
26-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class);
27+
$this->expectException(ServiceCircularReferenceException::class);
2728
$container = new ContainerBuilder();
2829
$container->register('a')->addArgument(new Reference('b'));
2930
$container->register('b')->addArgument(new Reference('a'));
@@ -33,7 +34,7 @@ public function testProcess()
3334

3435
public function testProcessWithAliases()
3536
{
36-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class);
37+
$this->expectException(ServiceCircularReferenceException::class);
3738
$container = new ContainerBuilder();
3839
$container->register('a')->addArgument(new Reference('b'));
3940
$container->setAlias('b', 'c');
@@ -44,7 +45,7 @@ public function testProcessWithAliases()
4445

4546
public function testProcessWithFactory()
4647
{
47-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class);
48+
$this->expectException(ServiceCircularReferenceException::class);
4849
$container = new ContainerBuilder();
4950

5051
$container
@@ -60,7 +61,7 @@ public function testProcessWithFactory()
6061

6162
public function testProcessDetectsIndirectCircularReference()
6263
{
63-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class);
64+
$this->expectException(ServiceCircularReferenceException::class);
6465
$container = new ContainerBuilder();
6566
$container->register('a')->addArgument(new Reference('b'));
6667
$container->register('b')->addArgument(new Reference('c'));
@@ -71,7 +72,7 @@ public function testProcessDetectsIndirectCircularReference()
7172

7273
public function testProcessDetectsIndirectCircularReferenceWithFactory()
7374
{
74-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class);
75+
$this->expectException(ServiceCircularReferenceException::class);
7576
$container = new ContainerBuilder();
7677

7778
$container->register('a')->addArgument(new Reference('b'));
@@ -87,7 +88,7 @@ public function testProcessDetectsIndirectCircularReferenceWithFactory()
8788

8889
public function testDeepCircularReference()
8990
{
90-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class);
91+
$this->expectException(ServiceCircularReferenceException::class);
9192
$container = new ContainerBuilder();
9293
$container->register('a')->addArgument(new Reference('b'));
9394
$container->register('b')->addArgument(new Reference('c'));

Tests/Compiler/CheckDefinitionValidityPassTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DependencyInjection\Compiler\CheckDefinitionValidityPass;
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
17+
use Symfony\Component\DependencyInjection\Exception\EnvParameterException;
1718
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
1819

1920
class CheckDefinitionValidityPassTest extends TestCase
@@ -86,7 +87,7 @@ public function testInvalidTags()
8687

8788
public function testDynamicPublicServiceName()
8889
{
89-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\EnvParameterException::class);
90+
$this->expectException(EnvParameterException::class);
9091
$container = new ContainerBuilder();
9192
$env = $container->getParameterBag()->get('env(BAR)');
9293
$container->register("foo.$env", 'class')->setPublic(true);
@@ -96,7 +97,7 @@ public function testDynamicPublicServiceName()
9697

9798
public function testDynamicPublicAliasName()
9899
{
99-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\EnvParameterException::class);
100+
$this->expectException(EnvParameterException::class);
100101
$container = new ContainerBuilder();
101102
$env = $container->getParameterBag()->get('env(BAR)');
102103
$container->setAlias("foo.$env", 'class')->setPublic(true);

Tests/Compiler/CheckExceptionOnInvalidReferenceBehaviorPassTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
2020
use Symfony\Component\DependencyInjection\ContainerBuilder;
2121
use Symfony\Component\DependencyInjection\Definition;
22+
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
2223
use Symfony\Component\DependencyInjection\Reference;
2324

2425
class CheckExceptionOnInvalidReferenceBehaviorPassTest extends TestCase
@@ -40,7 +41,7 @@ public function testProcess()
4041

4142
public function testProcessThrowsExceptionOnInvalidReference()
4243
{
43-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class);
44+
$this->expectException(ServiceNotFoundException::class);
4445
$container = new ContainerBuilder();
4546

4647
$container
@@ -53,7 +54,7 @@ public function testProcessThrowsExceptionOnInvalidReference()
5354

5455
public function testProcessThrowsExceptionOnInvalidReferenceFromInlinedDefinition()
5556
{
56-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class);
57+
$this->expectException(ServiceNotFoundException::class);
5758
$container = new ContainerBuilder();
5859

5960
$def = new Definition();
@@ -83,7 +84,7 @@ public function testProcessDefinitionWithBindings()
8384

8485
public function testWithErroredServiceLocator()
8586
{
86-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class);
87+
$this->expectException(ServiceNotFoundException::class);
8788
$this->expectExceptionMessage('The service "foo" in the container provided to "bar" has a dependency on a non-existent service "baz".');
8889
$container = new ContainerBuilder();
8990

@@ -96,7 +97,7 @@ public function testWithErroredServiceLocator()
9697

9798
public function testWithErroredHiddenService()
9899
{
99-
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class);
100+
$this->expectException(ServiceNotFoundException::class);
100101
$this->expectExceptionMessage('The service "bar" has a dependency on a non-existent service "foo".');
101102
$container = new ContainerBuilder();
102103

0 commit comments

Comments
 (0)