fix tests
This commit is contained in:
parent
3e0b2354db
commit
e55f6e6f5e
@ -21,9 +21,9 @@ use Symfony\Component\DependencyInjection\Exception\AutowiringFailedException;
|
|||||||
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
||||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass;
|
||||||
use Symfony\Component\DependencyInjection\Tests\Fixtures\includes\FooVariadic;
|
use Symfony\Component\DependencyInjection\Tests\Fixtures\includes\FooVariadic;
|
||||||
use Symfony\Component\DependencyInjection\TypedReference;
|
use Symfony\Component\DependencyInjection\TypedReference;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
|
||||||
|
|
||||||
require_once __DIR__.'/../Fixtures/includes/autowiring_classes.php';
|
require_once __DIR__.'/../Fixtures/includes/autowiring_classes.php';
|
||||||
|
|
||||||
@ -606,13 +606,17 @@ class AutowirePassTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
|
||||||
|
* @exceptedExceptionMessage Invalid service "Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy": method "setLogger()" does not exist.
|
||||||
|
*/
|
||||||
public function testWithNonExistingSetterAndAutowiring()
|
public function testWithNonExistingSetterAndAutowiring()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
|
|
||||||
$definition = $container->register(HttpKernelInterface::class, HttpKernelInterface::class)->setAutowired(true);
|
$definition = $container->register(CaseSensitiveClass::class, CaseSensitiveClass::class)->setAutowired(true);
|
||||||
$definition->addMethodCall('setLogger');
|
$definition->addMethodCall('setLogger');
|
||||||
$this->expectException(RuntimeException::class);
|
|
||||||
(new ResolveClassPass())->process($container);
|
(new ResolveClassPass())->process($container);
|
||||||
(new AutowireRequiredMethodsPass())->process($container);
|
(new AutowireRequiredMethodsPass())->process($container);
|
||||||
(new AutowirePass())->process($container);
|
(new AutowirePass())->process($container);
|
||||||
|
@ -17,13 +17,11 @@ use Symfony\Component\DependencyInjection\Compiler\AutowireRequiredMethodsPass;
|
|||||||
use Symfony\Component\DependencyInjection\Compiler\ResolveBindingsPass;
|
use Symfony\Component\DependencyInjection\Compiler\ResolveBindingsPass;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass;
|
use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass;
|
||||||
use Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy;
|
use Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy;
|
||||||
use Symfony\Component\DependencyInjection\Tests\Fixtures\ParentNotExists;
|
use Symfony\Component\DependencyInjection\Tests\Fixtures\ParentNotExists;
|
||||||
use Symfony\Component\DependencyInjection\TypedReference;
|
use Symfony\Component\DependencyInjection\TypedReference;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
|
||||||
|
|
||||||
require_once __DIR__.'/../Fixtures/includes/autowiring_classes.php';
|
require_once __DIR__.'/../Fixtures/includes/autowiring_classes.php';
|
||||||
|
|
||||||
@ -115,6 +113,10 @@ class ResolveBindingsPassTest extends TestCase
|
|||||||
$this->assertEquals([['setDefaultLocale', ['fr']]], $definition->getMethodCalls());
|
$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()
|
public function testWithNonExistingSetterAndBinding()
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
@ -123,36 +125,11 @@ class ResolveBindingsPassTest extends TestCase
|
|||||||
'$c' => (new Definition('logger'))->setFactory('logger'),
|
'$c' => (new Definition('logger'))->setFactory('logger'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$definition = $container->register(HttpKernelInterface::class, HttpKernelInterface::class);
|
$definition = $container->register(NamedArgumentsDummy::class, NamedArgumentsDummy::class);
|
||||||
$definition->addMethodCall('setLogger');
|
$definition->addMethodCall('setLogger');
|
||||||
$definition->setBindings($bindings);
|
$definition->setBindings($bindings);
|
||||||
$this->expectException(RuntimeException::class);
|
|
||||||
|
|
||||||
$pass = new ResolveBindingsPass();
|
$pass = new ResolveBindingsPass();
|
||||||
$pass->process($container);
|
$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->setBindings($bindings);
|
|
||||||
|
|
||||||
$pass = new ResolveBindingsPass();
|
|
||||||
$pass->process($container);
|
|
||||||
|
|
||||||
$expected = [
|
|
||||||
['setSensitiveClass', [new Reference('foo')]],
|
|
||||||
['setAnotherC', [new Reference('bar')]],
|
|
||||||
];
|
|
||||||
$this->assertEquals($expected, $definition->getMethodCalls());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,9 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter
|
|||||||
*/
|
*/
|
||||||
public function warmUp($cacheDir)
|
public function warmUp($cacheDir)
|
||||||
{
|
{
|
||||||
return $this->translator->warmUp($cacheDir);
|
if ($this->translator instanceof WarmableInterface) {
|
||||||
|
$this->translator->warmUp($cacheDir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,7 +22,9 @@
|
|||||||
"require-dev": {
|
"require-dev": {
|
||||||
"symfony/config": "~2.8|~3.0|~4.0",
|
"symfony/config": "~2.8|~3.0|~4.0",
|
||||||
"symfony/dependency-injection": "~3.4|~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/intl": "^2.8.18|^3.2.5|~4.0",
|
||||||
|
"symfony/var-dumper": "~3.4|~4.0",
|
||||||
"symfony/yaml": "~3.4|~4.0",
|
"symfony/yaml": "~3.4|~4.0",
|
||||||
"symfony/finder": "~2.8|~3.0|~4.0",
|
"symfony/finder": "~2.8|~3.0|~4.0",
|
||||||
"psr/log": "~1.0"
|
"psr/log": "~1.0"
|
||||||
|
Reference in New Issue
Block a user