Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Apr 6, 2019
1 parent 3e0b235 commit e55f6e6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass;
use Symfony\Component\DependencyInjection\Tests\Fixtures\includes\FooVariadic;
use Symfony\Component\DependencyInjection\TypedReference;
use Symfony\Component\HttpKernel\HttpKernelInterface;

require_once __DIR__.'/../Fixtures/includes/autowiring_classes.php';

Expand Down Expand Up @@ -606,13 +606,17 @@ public function testSetterInjection()
);
}

/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
* @exceptedExceptionMessage Invalid service "Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy": method "setLogger()" does not exist.
*/
public function testWithNonExistingSetterAndAutowiring()
{
$container = new ContainerBuilder();

$definition = $container->register(HttpKernelInterface::class, HttpKernelInterface::class)->setAutowired(true);
$definition = $container->register(CaseSensitiveClass::class, CaseSensitiveClass::class)->setAutowired(true);
$definition->addMethodCall('setLogger');
$this->expectException(RuntimeException::class);

(new ResolveClassPass())->process($container);
(new AutowireRequiredMethodsPass())->process($container);
(new AutowirePass())->process($container);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
use Symfony\Component\DependencyInjection\Compiler\ResolveBindingsPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass;
use Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy;
use Symfony\Component\DependencyInjection\Tests\Fixtures\ParentNotExists;
use Symfony\Component\DependencyInjection\TypedReference;
use Symfony\Component\HttpKernel\HttpKernelInterface;

require_once __DIR__.'/../Fixtures/includes/autowiring_classes.php';

Expand Down Expand Up @@ -115,6 +113,10 @@ public function testScalarSetter()
$this->assertEquals([['setDefaultLocale', ['fr']]], $definition->getMethodCalls());
}

/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
* @exceptedExceptionMessage Invalid service "Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy": method "setLogger()" does not exist.
*/
public function testWithNonExistingSetterAndBinding()
{
$container = new ContainerBuilder();
Expand All @@ -123,36 +125,11 @@ public function testWithNonExistingSetterAndBinding()
'$c' => (new Definition('logger'))->setFactory('logger'),
];

$definition = $container->register(HttpKernelInterface::class, HttpKernelInterface::class);
$definition->addMethodCall('setLogger');
$definition->setBindings($bindings);
$this->expectException(RuntimeException::class);

$pass = new ResolveBindingsPass();
$pass->process($container);
}

public function testTupleBinding()
{
$container = new ContainerBuilder();

$bindings = [
'$c' => new BoundArgument(new Reference('bar')),
CaseSensitiveClass::class.'$c' => new BoundArgument(new Reference('foo')),
];

$definition = $container->register(NamedArgumentsDummy::class, NamedArgumentsDummy::class);
$definition->addMethodCall('setSensitiveClass');
$definition->addMethodCall('setAnotherC');
$definition->addMethodCall('setLogger');
$definition->setBindings($bindings);

$pass = new ResolveBindingsPass();
$pass->process($container);

$expected = [
['setSensitiveClass', [new Reference('foo')]],
['setAnotherC', [new Reference('bar')]],
];
$this->assertEquals($expected, $definition->getMethodCalls());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ public function getCatalogue($locale = null)
*/
public function warmUp($cacheDir)
{
return $this->translator->warmUp($cacheDir);
if ($this->translator instanceof WarmableInterface) {
$this->translator->warmUp($cacheDir);
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Translation/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"require-dev": {
"symfony/config": "~2.8|~3.0|~4.0",
"symfony/dependency-injection": "~3.4|~4.0",
"symfony/http-kernel": "~3.4|~4.0",
"symfony/intl": "^2.8.18|^3.2.5|~4.0",
"symfony/var-dumper": "~3.4|~4.0",
"symfony/yaml": "~3.4|~4.0",
"symfony/finder": "~2.8|~3.0|~4.0",
"psr/log": "~1.0"
Expand Down

0 comments on commit e55f6e6

Please sign in to comment.