Skip to content

Commit

Permalink
Merge branch '5.1' into 5.2
Browse files Browse the repository at this point in the history
* 5.1:
  Use createMock() and use import instead of FQCN
  • Loading branch information
nicolas-grekas committed Jan 27, 2021
2 parents a607186 + 2fd8fe8 commit b34536b
Show file tree
Hide file tree
Showing 40 changed files with 213 additions and 143 deletions.
3 changes: 2 additions & 1 deletion Tests/AliasTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;

class AliasTest extends TestCase
{
Expand Down Expand Up @@ -122,7 +123,7 @@ public function testCanOverrideDeprecation()
*/
public function testCannotDeprecateWithAnInvalidTemplate($message)
{
$this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
$this->expectException(InvalidArgumentException::class);
$def = new Alias('foo');
$def->setDeprecated('package', '1.1', $message);
}
Expand Down
6 changes: 4 additions & 2 deletions Tests/Compiler/AutoAliasServicePassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Compiler\AutoAliasServicePass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;

class AutoAliasServicePassTest extends TestCase
{
public function testProcessWithMissingParameter()
{
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException::class);
$this->expectException(ParameterNotFoundException::class);
$container = new ContainerBuilder();

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

public function testProcessWithMissingFormat()
{
$this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
$this->expectException(InvalidArgumentException::class);
$container = new ContainerBuilder();

$container->register('example')
Expand Down
3 changes: 2 additions & 1 deletion Tests/Compiler/CheckArgumentsValidityPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Compiler\CheckArgumentsValidityPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;

/**
* @author Kévin Dunglas <dunglas@gmail.com>
Expand Down Expand Up @@ -45,7 +46,7 @@ public function testProcess()
*/
public function testException(array $arguments, array $methodCalls)
{
$this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class);
$this->expectException(RuntimeException::class);
$container = new ContainerBuilder();
$definition = $container->register('foo');
$definition->setArguments($arguments);
Expand Down
13 changes: 7 additions & 6 deletions Tests/Compiler/CheckCircularReferencesPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
use Symfony\Component\DependencyInjection\Compiler\CheckCircularReferencesPass;
use Symfony\Component\DependencyInjection\Compiler\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
use Symfony\Component\DependencyInjection\Reference;

class CheckCircularReferencesPassTest extends TestCase
{
public function testProcess()
{
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class);
$this->expectException(ServiceCircularReferenceException::class);
$container = new ContainerBuilder();
$container->register('a')->addArgument(new Reference('b'));
$container->register('b')->addArgument(new Reference('a'));
Expand All @@ -33,7 +34,7 @@ public function testProcess()

public function testProcessWithAliases()
{
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class);
$this->expectException(ServiceCircularReferenceException::class);
$container = new ContainerBuilder();
$container->register('a')->addArgument(new Reference('b'));
$container->setAlias('b', 'c');
Expand All @@ -44,7 +45,7 @@ public function testProcessWithAliases()

public function testProcessWithFactory()
{
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class);
$this->expectException(ServiceCircularReferenceException::class);
$container = new ContainerBuilder();

$container
Expand All @@ -60,7 +61,7 @@ public function testProcessWithFactory()

public function testProcessDetectsIndirectCircularReference()
{
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class);
$this->expectException(ServiceCircularReferenceException::class);
$container = new ContainerBuilder();
$container->register('a')->addArgument(new Reference('b'));
$container->register('b')->addArgument(new Reference('c'));
Expand All @@ -71,7 +72,7 @@ public function testProcessDetectsIndirectCircularReference()

public function testProcessDetectsIndirectCircularReferenceWithFactory()
{
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class);
$this->expectException(ServiceCircularReferenceException::class);
$container = new ContainerBuilder();

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

public function testDeepCircularReference()
{
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException::class);
$this->expectException(ServiceCircularReferenceException::class);
$container = new ContainerBuilder();
$container->register('a')->addArgument(new Reference('b'));
$container->register('b')->addArgument(new Reference('c'));
Expand Down
5 changes: 3 additions & 2 deletions Tests/Compiler/CheckDefinitionValidityPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Compiler\CheckDefinitionValidityPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\EnvParameterException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;

class CheckDefinitionValidityPassTest extends TestCase
Expand Down Expand Up @@ -86,7 +87,7 @@ public function testInvalidTags()

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

public function testDynamicPublicAliasName()
{
$this->expectException(\Symfony\Component\DependencyInjection\Exception\EnvParameterException::class);
$this->expectException(EnvParameterException::class);
$container = new ContainerBuilder();
$env = $container->getParameterBag()->get('env(BAR)');
$container->setAlias("foo.$env", 'class')->setPublic(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testProcess()

public function testProcessThrowsExceptionOnInvalidReference()
{
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class);
$this->expectException(ServiceNotFoundException::class);
$container = new ContainerBuilder();

$container
Expand All @@ -54,7 +54,7 @@ public function testProcessThrowsExceptionOnInvalidReference()

public function testProcessThrowsExceptionOnInvalidReferenceFromInlinedDefinition()
{
$this->expectException(\Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException::class);
$this->expectException(ServiceNotFoundException::class);
$container = new ContainerBuilder();

$def = new Definition();
Expand Down Expand Up @@ -84,7 +84,7 @@ public function testProcessDefinitionWithBindings()

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

Expand All @@ -97,7 +97,7 @@ public function testWithErroredServiceLocator()

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

Expand Down

0 comments on commit b34536b

Please sign in to comment.