Fix deprecation on 4.3
This commit is contained in:
parent
b406466221
commit
8fd16a6bee
|
@ -30,6 +30,9 @@ matrix:
|
|||
env: deps=high
|
||||
- php: 7.3
|
||||
env: deps=low
|
||||
- php: 7.4snapshot
|
||||
allow_failures:
|
||||
- php: 7.4snapshot
|
||||
fast_finish: true
|
||||
|
||||
cache:
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
<?php
|
||||
|
||||
class SunnyInterface_1eff735 implements \ProxyManager\Proxy\VirtualProxyInterface, \Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper\DummyInterface, \Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper\SunnyInterface
|
||||
class SunnyInterface_%s implements \ProxyManager\Proxy\VirtualProxyInterface, \Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper\DummyInterface, \Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper\SunnyInterface
|
||||
{
|
||||
|
||||
private $valueHolder1eff735 = null;
|
||||
private $valueHolder%s = null;
|
||||
|
||||
private $initializer1eff735 = null;
|
||||
private $initializer%s = null;
|
||||
|
||||
private static $publicProperties1eff735 = [
|
||||
|
||||
private static $publicProperties%s = [
|
||||
%S
|
||||
];
|
||||
|
||||
public function dummy()
|
||||
{
|
||||
$this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, 'dummy', array(), $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
|
||||
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, 'dummy', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
|
||||
|
||||
if ($this->valueHolder1eff735 === $returnValue = $this->valueHolder1eff735->dummy()) {
|
||||
if ($this->valueHolder%s === $returnValue = $this->valueHolder%s->dummy()) {
|
||||
$returnValue = $this;
|
||||
}
|
||||
|
||||
|
@ -24,9 +24,9 @@ class SunnyInterface_1eff735 implements \ProxyManager\Proxy\VirtualProxyInterfac
|
|||
|
||||
public function & dummyRef()
|
||||
{
|
||||
$this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, 'dummyRef', array(), $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
|
||||
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, 'dummyRef', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
|
||||
|
||||
if ($this->valueHolder1eff735 === $returnValue = &$this->valueHolder1eff735->dummyRef()) {
|
||||
if ($this->valueHolder%s === $returnValue = &$this->valueHolder%s->dummyRef()) {
|
||||
$returnValue = $this;
|
||||
}
|
||||
|
||||
|
@ -35,9 +35,9 @@ class SunnyInterface_1eff735 implements \ProxyManager\Proxy\VirtualProxyInterfac
|
|||
|
||||
public function sunny()
|
||||
{
|
||||
$this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, 'sunny', array(), $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
|
||||
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, 'sunny', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
|
||||
|
||||
if ($this->valueHolder1eff735 === $returnValue = $this->valueHolder1eff735->sunny()) {
|
||||
if ($this->valueHolder%s === $returnValue = $this->valueHolder%s->sunny()) {
|
||||
$returnValue = $this;
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,9 @@ class SunnyInterface_1eff735 implements \ProxyManager\Proxy\VirtualProxyInterfac
|
|||
static $reflection;
|
||||
|
||||
$reflection = $reflection ?? new \ReflectionClass(__CLASS__);
|
||||
$instance = $reflection->newInstanceWithoutConstructor();
|
||||
$instance%w= $reflection->newInstanceWithoutConstructor();
|
||||
|
||||
$instance->initializer1eff735 = $initializer;
|
||||
$instance->initializer%s = $initializer;
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
@ -60,21 +60,21 @@ class SunnyInterface_1eff735 implements \ProxyManager\Proxy\VirtualProxyInterfac
|
|||
{
|
||||
static $reflection;
|
||||
|
||||
if (! $this->valueHolder1eff735) {
|
||||
if (! $this->valueHolder%s) {
|
||||
$reflection = $reflection ?? new \ReflectionClass(__CLASS__);
|
||||
$this->valueHolder1eff735 = $reflection->newInstanceWithoutConstructor();
|
||||
$this->valueHolder%s = $reflection->newInstanceWithoutConstructor();
|
||||
}
|
||||
}
|
||||
|
||||
public function & __get($name)
|
||||
{
|
||||
$this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, '__get', ['name' => $name], $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
|
||||
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__get', ['name' => $name], $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
|
||||
|
||||
if (isset(self::$publicProperties1eff735[$name])) {
|
||||
return $this->valueHolder1eff735->$name;
|
||||
if (isset(self::$publicProperties%s[$name])) {
|
||||
return $this->valueHolder%s->$name;
|
||||
}
|
||||
|
||||
$targetObject = $this->valueHolder1eff735;
|
||||
$targetObject = $this->valueHolder%s;
|
||||
|
||||
$backtrace = debug_backtrace(false);
|
||||
trigger_error(
|
||||
|
@ -92,27 +92,27 @@ class SunnyInterface_1eff735 implements \ProxyManager\Proxy\VirtualProxyInterfac
|
|||
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, '__set', array('name' => $name, 'value' => $value), $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
|
||||
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__set', array('name' => $name, 'value' => $value), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
|
||||
|
||||
$targetObject = $this->valueHolder1eff735;
|
||||
$targetObject = $this->valueHolder%s;
|
||||
|
||||
return $targetObject->$name = $value;
|
||||
}
|
||||
|
||||
public function __isset($name)
|
||||
{
|
||||
$this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, '__isset', array('name' => $name), $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
|
||||
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__isset', array('name' => $name), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
|
||||
|
||||
$targetObject = $this->valueHolder1eff735;
|
||||
$targetObject = $this->valueHolder%s;
|
||||
|
||||
return isset($targetObject->$name);
|
||||
}
|
||||
|
||||
public function __unset($name)
|
||||
{
|
||||
$this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, '__unset', array('name' => $name), $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
|
||||
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__unset', array('name' => $name), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
|
||||
|
||||
$targetObject = $this->valueHolder1eff735;
|
||||
$targetObject = $this->valueHolder%s;
|
||||
|
||||
unset($targetObject->$name);
|
||||
return;
|
||||
|
@ -120,45 +120,45 @@ return;
|
|||
|
||||
public function __clone()
|
||||
{
|
||||
$this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, '__clone', array(), $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
|
||||
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__clone', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
|
||||
|
||||
$this->valueHolder1eff735 = clone $this->valueHolder1eff735;
|
||||
$this->valueHolder%s = clone $this->valueHolder%s;
|
||||
}
|
||||
|
||||
public function __sleep()
|
||||
{
|
||||
$this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, '__sleep', array(), $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
|
||||
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__sleep', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
|
||||
|
||||
return array('valueHolder1eff735');
|
||||
return array('valueHolder%s');
|
||||
}
|
||||
|
||||
public function __wakeup()
|
||||
{
|
||||
}
|
||||
|
||||
public function setProxyInitializer(\Closure $initializer = null)
|
||||
public function setProxyInitializer(\Closure $initializer = null)%S
|
||||
{
|
||||
$this->initializer1eff735 = $initializer;
|
||||
$this->initializer%s = $initializer;
|
||||
}
|
||||
|
||||
public function getProxyInitializer()
|
||||
public function getProxyInitializer()%S
|
||||
{
|
||||
return $this->initializer1eff735;
|
||||
return $this->initializer%s;
|
||||
}
|
||||
|
||||
public function initializeProxy() : bool
|
||||
{
|
||||
return $this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, 'initializeProxy', array(), $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
|
||||
return $this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, 'initializeProxy', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
|
||||
}
|
||||
|
||||
public function isProxyInitialized() : bool
|
||||
{
|
||||
return null !== $this->valueHolder1eff735;
|
||||
return null !== $this->valueHolder%s;
|
||||
}
|
||||
|
||||
public function getWrappedValueHolderValue()
|
||||
public function getWrappedValueHolderValue()%S
|
||||
{
|
||||
return $this->valueHolder1eff735;
|
||||
return $this->valueHolder%s;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -168,12 +168,12 @@ return new class
|
|||
EOPHP;
|
||||
|
||||
$implem = preg_replace('#\n /\*\*.*?\*/#s', '', $implem);
|
||||
$implem = str_replace('getWrappedValueHolderValue() : ?object', 'getWrappedValueHolderValue()', $implem);
|
||||
$implem = str_replace("array(\n \n );", "[\n \n ];", $implem);
|
||||
$this->assertStringEqualsFile(__DIR__.'/Fixtures/proxy-implem.php', $implem);
|
||||
|
||||
$this->assertStringMatchesFormatFile(__DIR__.'/Fixtures/proxy-implem.php', $implem);
|
||||
$this->assertStringEqualsFile(__DIR__.'/Fixtures/proxy-factory.php', $factory);
|
||||
|
||||
require_once __DIR__.'/Fixtures/proxy-implem.php';
|
||||
eval(preg_replace('/^<\?php/', '', $implem));
|
||||
$factory = require __DIR__.'/Fixtures/proxy-factory.php';
|
||||
|
||||
$foo = $factory->getFooService();
|
||||
|
|
|
@ -57,8 +57,8 @@ class ContainerDebugCommandTest extends AbstractWebTestCase
|
|||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(['command' => 'debug:container', '--show-hidden' => true]);
|
||||
$this->assertNotContains('public', $tester->getDisplay());
|
||||
$this->assertNotContains('private_alias', $tester->getDisplay());
|
||||
$this->assertStringNotContainsString('public', $tester->getDisplay());
|
||||
$this->assertStringNotContainsString('private_alias', $tester->getDisplay());
|
||||
|
||||
$tester->run(['command' => 'debug:container']);
|
||||
$this->assertStringContainsString('public', $tester->getDisplay());
|
||||
|
@ -77,7 +77,7 @@ class ContainerDebugCommandTest extends AbstractWebTestCase
|
|||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(['command' => 'debug:container', 'name' => $validServiceId]);
|
||||
$this->assertNotContains('No services found', $tester->getDisplay());
|
||||
$this->assertStringNotContainsString('No services found', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testDescribeEnvVars()
|
||||
|
|
|
@ -227,7 +227,7 @@ class UserPasswordEncoderCommandTest extends AbstractWebTestCase
|
|||
'user-class' => 'Custom\Class\Sodium\User',
|
||||
], ['interactive' => false]);
|
||||
|
||||
$this->assertNotContains(' Generated salt ', $this->passwordEncoderCommandTester->getDisplay());
|
||||
$this->assertStringNotContainsString(' Generated salt ', $this->passwordEncoderCommandTester->getDisplay());
|
||||
}
|
||||
|
||||
public function testEncodePasswordNoConfigForGivenUserClass()
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace Symfony\Component\Cache\Tests\Adapter;
|
|||
|
||||
use Cache\IntegrationTests\CachePoolTest;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use PHPUnit\Framework\Warning;
|
||||
use Psr\Cache\CacheItemInterface;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\CacheItem;
|
||||
|
@ -120,7 +121,7 @@ abstract class AdapterTestCase extends CachePoolTest
|
|||
CacheItem::METADATA_EXPIRY => 9.5 + time(),
|
||||
CacheItem::METADATA_CTIME => 1000,
|
||||
];
|
||||
$this->assertEquals($expected, $item->getMetadata(), 'Item metadata should embed expiry and ctime.', .6);
|
||||
$this->assertEqualsWithDelta($expected, $item->getMetadata(), .6, 'Item metadata should embed expiry and ctime.');
|
||||
}
|
||||
|
||||
public function testDefaultLifeTime()
|
||||
|
@ -252,6 +253,15 @@ abstract class AdapterTestCase extends CachePoolTest
|
|||
$this->assertFalse($this->isPruned($cache, 'foo'));
|
||||
$this->assertTrue($this->isPruned($cache, 'qux'));
|
||||
}
|
||||
|
||||
public function testSavingObject()
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78351.');
|
||||
}
|
||||
|
||||
parent::testSavingObject();
|
||||
}
|
||||
}
|
||||
|
||||
class NotUnserializable
|
||||
|
|
|
@ -14,26 +14,25 @@ namespace Symfony\Component\Config\Tests\Definition\Builder;
|
|||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition;
|
||||
|
||||
class NodeDefinitionTest extends TestCase
|
||||
{
|
||||
public function testDefaultPathSeparatorIsDot()
|
||||
{
|
||||
$node = $this->getMockForAbstractClass(NodeDefinition::class, ['foo']);
|
||||
|
||||
$this->assertAttributeSame('.', 'pathSeparator', $node);
|
||||
}
|
||||
|
||||
public function testSetPathSeparatorChangesChildren()
|
||||
{
|
||||
$node = new ArrayNodeDefinition('foo');
|
||||
$scalar = new ScalarNodeDefinition('bar');
|
||||
$node->append($scalar);
|
||||
$parentNode = new ArrayNodeDefinition('name');
|
||||
$childNode = $this->createMock(NodeDefinition::class);
|
||||
|
||||
$node->setPathSeparator('/');
|
||||
$childNode
|
||||
->expects($this->once())
|
||||
->method('setPathSeparator')
|
||||
->with('/');
|
||||
$childNode
|
||||
->expects($this->once())
|
||||
->method('setParent')
|
||||
->with($parentNode)
|
||||
->willReturn($childNode);
|
||||
$parentNode->append($childNode);
|
||||
|
||||
$this->assertAttributeSame('/', 'pathSeparator', $node);
|
||||
$this->assertAttributeSame('/', 'pathSeparator', $scalar);
|
||||
$parentNode->setPathSeparator('/');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,8 +53,6 @@ class AutowirePassTest extends TestCase
|
|||
|
||||
public function testProcessNotExistingActionParam()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "Symfony\Component\DependencyInjection\Tests\CompilerEslaAction": argument "$notExisting" of method "Symfony\Component\DependencyInjection\Tests\Compiler\ElsaAction::__construct()" has type "Symfony\Component\DependencyInjection\Tests\Compiler\NotExisting" but this class was not found.');
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$container->register(Foo::class);
|
||||
|
@ -62,7 +60,12 @@ class AutowirePassTest extends TestCase
|
|||
$barDefinition->setAutowired(true);
|
||||
|
||||
(new ResolveClassPass())->process($container);
|
||||
(new AutowirePass())->process($container);
|
||||
try {
|
||||
(new AutowirePass())->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "Symfony\Component\DependencyInjection\Tests\CompilerEslaAction": argument "$notExisting" of method "Symfony\Component\DependencyInjection\Tests\Compiler\ElsaAction::__construct()" has type "Symfony\Component\DependencyInjection\Tests\Compiler\NotExisting" but this class was not found.', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testProcessVariadic()
|
||||
|
@ -81,8 +84,6 @@ class AutowirePassTest extends TestCase
|
|||
|
||||
public function testProcessAutowireParent()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "c": argument "$a" of method "Symfony\Component\DependencyInjection\Tests\Compiler\C::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\A" but no such service exists. You should maybe alias this class to the existing "Symfony\Component\DependencyInjection\Tests\Compiler\B" service.');
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$container->register(B::class);
|
||||
|
@ -90,16 +91,16 @@ class AutowirePassTest extends TestCase
|
|||
$cDefinition->setAutowired(true);
|
||||
|
||||
(new ResolveClassPass())->process($container);
|
||||
(new AutowirePass())->process($container);
|
||||
|
||||
$this->assertCount(1, $container->getDefinition('c')->getArguments());
|
||||
$this->assertEquals(B::class, (string) $container->getDefinition('c')->getArgument(0));
|
||||
try {
|
||||
(new AutowirePass())->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "c": argument "$a" of method "Symfony\Component\DependencyInjection\Tests\Compiler\C::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\A" but no such service exists. You should maybe alias this class to the existing "Symfony\Component\DependencyInjection\Tests\Compiler\B" service.', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testProcessAutowireInterface()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "g": argument "$d" of method "Symfony\Component\DependencyInjection\Tests\Compiler\G::__construct()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\DInterface" but no such service exists. You should maybe alias this interface to the existing "Symfony\Component\DependencyInjection\Tests\Compiler\F" service.');
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$container->register(F::class);
|
||||
|
@ -107,12 +108,12 @@ class AutowirePassTest extends TestCase
|
|||
$gDefinition->setAutowired(true);
|
||||
|
||||
(new ResolveClassPass())->process($container);
|
||||
(new AutowirePass())->process($container);
|
||||
|
||||
$this->assertCount(3, $container->getDefinition('g')->getArguments());
|
||||
$this->assertEquals(F::class, (string) $container->getDefinition('g')->getArgument(0));
|
||||
$this->assertEquals(F::class, (string) $container->getDefinition('g')->getArgument(1));
|
||||
$this->assertEquals(F::class, (string) $container->getDefinition('g')->getArgument(2));
|
||||
try {
|
||||
(new AutowirePass())->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "g": argument "$d" of method "Symfony\Component\DependencyInjection\Tests\Compiler\G::__construct()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\DInterface" but no such service exists. You should maybe alias this interface to the existing "Symfony\Component\DependencyInjection\Tests\Compiler\F" service.', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testCompleteExistingDefinition()
|
||||
|
@ -151,20 +152,21 @@ class AutowirePassTest extends TestCase
|
|||
|
||||
public function testPrivateConstructorThrowsAutowireException()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Invalid service "private_service": constructor of class "Symfony\Component\DependencyInjection\Tests\Compiler\PrivateConstructor" must be public.');
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$container->autowire('private_service', __NAMESPACE__.'\PrivateConstructor');
|
||||
|
||||
$pass = new AutowirePass(true);
|
||||
$pass->process($container);
|
||||
try {
|
||||
$pass->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Invalid service "private_service": constructor of class "Symfony\Component\DependencyInjection\Tests\Compiler\PrivateConstructor" must be public.', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testTypeCollision()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "a": argument "$collision" of method "Symfony\Component\DependencyInjection\Tests\Compiler\CannotBeAutowired::__construct()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\CollisionInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "c1", "c2", "c3".');
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$container->register('c1', __NAMESPACE__.'\CollisionA');
|
||||
|
@ -174,13 +176,16 @@ class AutowirePassTest extends TestCase
|
|||
$aDefinition->setAutowired(true);
|
||||
|
||||
$pass = new AutowirePass();
|
||||
$pass->process($container);
|
||||
try {
|
||||
$pass->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "a": argument "$collision" of method "Symfony\Component\DependencyInjection\Tests\Compiler\CannotBeAutowired::__construct()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\CollisionInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "c1", "c2", "c3".', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testTypeNotGuessable()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "a": argument "$k" of method "Symfony\Component\DependencyInjection\Tests\Compiler\NotGuessableArgument::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\Foo" but no such service exists. You should maybe alias this class to one of these existing services: "a1", "a2".');
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$container->register('a1', __NAMESPACE__.'\Foo');
|
||||
|
@ -189,13 +194,16 @@ class AutowirePassTest extends TestCase
|
|||
$aDefinition->setAutowired(true);
|
||||
|
||||
$pass = new AutowirePass();
|
||||
$pass->process($container);
|
||||
try {
|
||||
$pass->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "a": argument "$k" of method "Symfony\Component\DependencyInjection\Tests\Compiler\NotGuessableArgument::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\Foo" but no such service exists. You should maybe alias this class to one of these existing services: "a1", "a2".', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testTypeNotGuessableWithSubclass()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "a": argument "$k" of method "Symfony\Component\DependencyInjection\Tests\Compiler\NotGuessableArgumentForSubclass::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\A" but no such service exists. You should maybe alias this class to one of these existing services: "a1", "a2".');
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$container->register('a1', __NAMESPACE__.'\B');
|
||||
|
@ -204,20 +212,28 @@ class AutowirePassTest extends TestCase
|
|||
$aDefinition->setAutowired(true);
|
||||
|
||||
$pass = new AutowirePass();
|
||||
$pass->process($container);
|
||||
try {
|
||||
$pass->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "a": argument "$k" of method "Symfony\Component\DependencyInjection\Tests\Compiler\NotGuessableArgumentForSubclass::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\A" but no such service exists. You should maybe alias this class to one of these existing services: "a1", "a2".', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testTypeNotGuessableNoServicesFound()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "a": argument "$collision" of method "Symfony\Component\DependencyInjection\Tests\Compiler\CannotBeAutowired::__construct()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\CollisionInterface" but no such service exists.');
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$aDefinition = $container->register('a', __NAMESPACE__.'\CannotBeAutowired');
|
||||
$aDefinition->setAutowired(true);
|
||||
|
||||
$pass = new AutowirePass();
|
||||
$pass->process($container);
|
||||
try {
|
||||
$pass->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "a": argument "$collision" of method "Symfony\Component\DependencyInjection\Tests\Compiler\CannotBeAutowired::__construct()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\CollisionInterface" but no such service exists. Did you create a class that implements this interface?', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testTypeNotGuessableWithTypeSet()
|
||||
|
@ -256,15 +272,18 @@ class AutowirePassTest extends TestCase
|
|||
|
||||
public function testServicesAreNotAutoCreated()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "coop_tilleuls": argument "$j" of method "Symfony\Component\DependencyInjection\Tests\Compiler\LesTilleuls::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas" but no such service exists.');
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$coopTilleulsDefinition = $container->register('coop_tilleuls', __NAMESPACE__.'\LesTilleuls');
|
||||
$coopTilleulsDefinition->setAutowired(true);
|
||||
|
||||
$pass = new AutowirePass();
|
||||
$pass->process($container);
|
||||
try {
|
||||
$pass->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "coop_tilleuls": argument "$j" of method "Symfony\Component\DependencyInjection\Tests\Compiler\LesTilleuls::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas" but no such service exists.', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testResolveParameter()
|
||||
|
@ -315,8 +334,6 @@ class AutowirePassTest extends TestCase
|
|||
|
||||
public function testClassNotFoundThrowsException()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "a": argument "$r" of method "Symfony\Component\DependencyInjection\Tests\Compiler\BadTypeHintedArgument::__construct()" has type "Symfony\Component\DependencyInjection\Tests\Compiler\NotARealClass" but this class was not found.');
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$aDefinition = $container->register('a', __NAMESPACE__.'\BadTypeHintedArgument');
|
||||
|
@ -325,13 +342,16 @@ class AutowirePassTest extends TestCase
|
|||
$container->register(Dunglas::class, Dunglas::class);
|
||||
|
||||
$pass = new AutowirePass();
|
||||
$pass->process($container);
|
||||
try {
|
||||
$pass->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "a": argument "$r" of method "Symfony\Component\DependencyInjection\Tests\Compiler\BadTypeHintedArgument::__construct()" has type "Symfony\Component\DependencyInjection\Tests\Compiler\NotARealClass" but this class was not found.', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testParentClassNotFoundThrowsException()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "a": argument "$r" of method "Symfony\Component\DependencyInjection\Tests\Compiler\BadParentTypeHintedArgument::__construct()" has type "Symfony\Component\DependencyInjection\Tests\Compiler\OptionalServiceClass" but this class is missing a parent class (Class Symfony\Bug\NotExistClass not found).');
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78351.');
|
||||
}
|
||||
|
@ -344,13 +364,16 @@ class AutowirePassTest extends TestCase
|
|||
$container->register(Dunglas::class, Dunglas::class);
|
||||
|
||||
$pass = new AutowirePass();
|
||||
$pass->process($container);
|
||||
try {
|
||||
$pass->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "a": argument "$r" of method "Symfony\Component\DependencyInjection\Tests\Compiler\BadParentTypeHintedArgument::__construct()" has type "Symfony\Component\DependencyInjection\Tests\Compiler\OptionalServiceClass" but this class is missing a parent class (Class Symfony\Bug\NotExistClass not found).', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testDontUseAbstractServices()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "bar": argument "$foo" of method "Symfony\Component\DependencyInjection\Tests\Compiler\Bar::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\Foo" but this service is abstract. You should maybe alias this class to the existing "foo" service.');
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$container->register(Foo::class)->setAbstract(true);
|
||||
|
@ -358,7 +381,12 @@ class AutowirePassTest extends TestCase
|
|||
$container->register('bar', __NAMESPACE__.'\Bar')->setAutowired(true);
|
||||
|
||||
(new ResolveClassPass())->process($container);
|
||||
(new AutowirePass())->process($container);
|
||||
try {
|
||||
(new AutowirePass())->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "bar": argument "$foo" of method "Symfony\Component\DependencyInjection\Tests\Compiler\Bar::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\Foo" but this service is abstract. You should maybe alias this class to the existing "foo" service.', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testSomeSpecificArgumentsAreSet()
|
||||
|
@ -394,8 +422,6 @@ class AutowirePassTest extends TestCase
|
|||
|
||||
public function testScalarArgsCannotBeAutowired()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "arg_no_type_hint": argument "$bar" of method "Symfony\Component\DependencyInjection\Tests\Compiler\MultipleArguments::__construct()" is type-hinted "array", you should configure its value explicitly.');
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$container->register(A::class);
|
||||
|
@ -405,13 +431,16 @@ class AutowirePassTest extends TestCase
|
|||
->setAutowired(true);
|
||||
|
||||
(new ResolveClassPass())->process($container);
|
||||
(new AutowirePass())->process($container);
|
||||
try {
|
||||
(new AutowirePass())->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "arg_no_type_hint": argument "$bar" of method "Symfony\Component\DependencyInjection\Tests\Compiler\MultipleArguments::__construct()" is type-hinted "array", you should configure its value explicitly.', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testNoTypeArgsCannotBeAutowired()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "arg_no_type_hint": argument "$foo" of method "Symfony\Component\DependencyInjection\Tests\Compiler\MultipleArguments::__construct()" has no type-hint, you should configure its value explicitly.');
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$container->register(A::class);
|
||||
|
@ -420,7 +449,12 @@ class AutowirePassTest extends TestCase
|
|||
->setAutowired(true);
|
||||
|
||||
(new ResolveClassPass())->process($container);
|
||||
(new AutowirePass())->process($container);
|
||||
try {
|
||||
(new AutowirePass())->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "arg_no_type_hint": argument "$foo" of method "Symfony\Component\DependencyInjection\Tests\Compiler\MultipleArguments::__construct()" has no type-hint, you should configure its value explicitly.', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testOptionalScalarNotReallyOptionalUsesDefaultValue()
|
||||
|
@ -544,7 +578,7 @@ class AutowirePassTest extends TestCase
|
|||
*/
|
||||
public function testWithNonExistingSetterAndAutowiring()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
|
||||
$this->expectException(RuntimeException::class);
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$definition = $container->register(CaseSensitiveClass::class, CaseSensitiveClass::class)->setAutowired(true);
|
||||
|
@ -629,17 +663,14 @@ class AutowirePassTest extends TestCase
|
|||
|
||||
try {
|
||||
$pass->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "setter_injection_collision": argument "$collision" of method "Symfony\Component\DependencyInjection\Tests\Compiler\SetterInjectionCollision::setMultipleInstancesForOneArg()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\CollisionInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "c1", "c2".', (string) $e->getMessage());
|
||||
}
|
||||
|
||||
$this->assertNotNull($e);
|
||||
$this->assertSame('Cannot autowire service "setter_injection_collision": argument "$collision" of method "Symfony\Component\DependencyInjection\Tests\Compiler\SetterInjectionCollision::setMultipleInstancesForOneArg()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\CollisionInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "c1", "c2".', (string) $e->getMessage());
|
||||
}
|
||||
|
||||
public function testInterfaceWithNoImplementationSuggestToWriteOne()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "my_service": argument "$i" of method "Symfony\Component\DependencyInjection\Tests\Compiler\K::__construct()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\IInterface" but no such service exists. Did you create a class that implements this interface?');
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$aDefinition = $container->register('my_service', K::class);
|
||||
|
@ -648,20 +679,28 @@ class AutowirePassTest extends TestCase
|
|||
(new AutowireRequiredMethodsPass())->process($container);
|
||||
|
||||
$pass = new AutowirePass();
|
||||
$pass->process($container);
|
||||
try {
|
||||
$pass->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "my_service": argument "$i" of method "Symfony\Component\DependencyInjection\Tests\Compiler\K::__construct()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\IInterface" but no such service exists. Did you create a class that implements this interface?', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testProcessDoesNotTriggerDeprecations()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "bar": argument "$foo" of method "Symfony\Component\DependencyInjection\Tests\Compiler\Bar::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\Foo" but no such service exists. You should maybe alias this class to the existing "foo" service.');
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('deprecated', 'Symfony\Component\DependencyInjection\Tests\Fixtures\DeprecatedClass')->setDeprecated(true);
|
||||
$container->register('foo', __NAMESPACE__.'\Foo');
|
||||
$container->register('bar', __NAMESPACE__.'\Bar')->setAutowired(true);
|
||||
|
||||
$pass = new AutowirePass();
|
||||
$pass->process($container);
|
||||
try {
|
||||
$pass->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "bar": argument "$foo" of method "Symfony\Component\DependencyInjection\Tests\Compiler\Bar::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\Foo" but no such service exists. You should maybe alias this class to the existing "foo" service.', (string) $e->getMessage());
|
||||
}
|
||||
|
||||
$this->assertTrue($container->hasDefinition('deprecated'));
|
||||
$this->assertTrue($container->hasDefinition('foo'));
|
||||
|
@ -704,7 +743,6 @@ class AutowirePassTest extends TestCase
|
|||
*/
|
||||
public function testNotWireableCalls($method, $expectedMsg)
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$foo = $container->register('foo', NotWireable::class)->setAutowired(true)
|
||||
|
@ -718,12 +756,14 @@ class AutowirePassTest extends TestCase
|
|||
$foo->addMethodCall($method, []);
|
||||
}
|
||||
|
||||
$this->expectException(RuntimeException::class);
|
||||
$this->expectExceptionMessage($expectedMsg);
|
||||
|
||||
(new ResolveClassPass())->process($container);
|
||||
(new AutowireRequiredMethodsPass())->process($container);
|
||||
(new AutowirePass())->process($container);
|
||||
try {
|
||||
(new AutowirePass())->process($container);
|
||||
$this->fail('AutowirePass should throw a RuntimeException.');
|
||||
} catch (RuntimeException $e) {
|
||||
$this->assertSame($expectedMsg, (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function provideNotWireableCalls()
|
||||
|
@ -737,8 +777,6 @@ class AutowirePassTest extends TestCase
|
|||
|
||||
public function testSuggestRegisteredServicesWithSimilarCase()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "foo": argument "$sam" of method "Symfony\Component\DependencyInjection\Tests\Compiler\NotWireable::setNotAutowireableBecauseOfATypo()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\lesTilleuls" but no such service exists. Did you mean "Symfony\Component\DependencyInjection\Tests\Compiler\LesTilleuls"?');
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$container->register(LesTilleuls::class, LesTilleuls::class);
|
||||
|
@ -748,13 +786,16 @@ class AutowirePassTest extends TestCase
|
|||
|
||||
(new ResolveClassPass())->process($container);
|
||||
(new AutowireRequiredMethodsPass())->process($container);
|
||||
(new AutowirePass())->process($container);
|
||||
try {
|
||||
(new AutowirePass())->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "foo": argument "$sam" of method "Symfony\Component\DependencyInjection\Tests\Compiler\NotWireable::setNotAutowireableBecauseOfATypo()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\lesTilleuls" but no such service exists. Did you mean "Symfony\Component\DependencyInjection\Tests\Compiler\LesTilleuls"?', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testByIdAlternative()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "j": argument "$i" of method "Symfony\Component\DependencyInjection\Tests\Compiler\J::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\I" but no such service exists. Try changing the type-hint to "Symfony\Component\DependencyInjection\Tests\Compiler\IInterface" instead.');
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$container->setAlias(IInterface::class, 'i');
|
||||
|
@ -763,13 +804,16 @@ class AutowirePassTest extends TestCase
|
|||
->setAutowired(true);
|
||||
|
||||
$pass = new AutowirePass();
|
||||
$pass->process($container);
|
||||
try {
|
||||
$pass->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "j": argument "$i" of method "Symfony\Component\DependencyInjection\Tests\Compiler\J::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\I" but no such service exists. Try changing the type-hint to "Symfony\Component\DependencyInjection\Tests\Compiler\IInterface" instead.', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testExceptionWhenAliasExists()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "j": argument "$i" of method "Symfony\Component\DependencyInjection\Tests\Compiler\J::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\I" but no such service exists. Try changing the type-hint to "Symfony\Component\DependencyInjection\Tests\Compiler\IInterface" instead.');
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
// multiple I services... but there *is* IInterface available
|
||||
|
@ -781,13 +825,16 @@ class AutowirePassTest extends TestCase
|
|||
->setAutowired(true);
|
||||
|
||||
$pass = new AutowirePass();
|
||||
$pass->process($container);
|
||||
try {
|
||||
$pass->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "j": argument "$i" of method "Symfony\Component\DependencyInjection\Tests\Compiler\J::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\I" but no such service exists. Try changing the type-hint to "Symfony\Component\DependencyInjection\Tests\Compiler\IInterface" instead.', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testExceptionWhenAliasDoesNotExist()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "j": argument "$i" of method "Symfony\Component\DependencyInjection\Tests\Compiler\J::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\I" but no such service exists. You should maybe alias this class to one of these existing services: "i", "i2".');
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78351.');
|
||||
}
|
||||
|
@ -802,7 +849,12 @@ class AutowirePassTest extends TestCase
|
|||
->setAutowired(true);
|
||||
|
||||
$pass = new AutowirePass();
|
||||
$pass->process($container);
|
||||
try {
|
||||
$pass->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "j": argument "$i" of method "Symfony\Component\DependencyInjection\Tests\Compiler\J::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\I" but no such service exists. You should maybe alias this class to one of these existing services: "i", "i2".', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testInlineServicesAreNotCandidates()
|
||||
|
@ -878,8 +930,6 @@ class AutowirePassTest extends TestCase
|
|||
|
||||
public function testDoNotAutowireDecoratorWhenSeveralArgumentOfTheType()
|
||||
{
|
||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
|
||||
$this->expectExceptionMessage('Cannot autowire service "Symfony\Component\DependencyInjection\Tests\Compiler\NonAutowirableDecorator": argument "$decorated1" of method "__construct()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\DecoratorInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "Symfony\Component\DependencyInjection\Tests\Compiler\NonAutowirableDecorator", "Symfony\Component\DependencyInjection\Tests\Compiler\NonAutowirableDecorator.inner".');
|
||||
$container = new ContainerBuilder();
|
||||
$container->register(LoggerInterface::class, NullLogger::class);
|
||||
$container->register(Decorated::class, Decorated::class);
|
||||
|
@ -890,7 +940,12 @@ class AutowirePassTest extends TestCase
|
|||
;
|
||||
|
||||
(new DecoratorServicePass())->process($container);
|
||||
(new AutowirePass())->process($container);
|
||||
try {
|
||||
(new AutowirePass())->process($container);
|
||||
$this->fail('AutowirePass should have thrown an exception');
|
||||
} catch (AutowiringFailedException $e) {
|
||||
$this->assertSame('Cannot autowire service "Symfony\Component\DependencyInjection\Tests\Compiler\NonAutowirableDecorator": argument "$decorated1" of method "__construct()" references interface "Symfony\Component\DependencyInjection\Tests\Compiler\DecoratorInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "Symfony\Component\DependencyInjection\Tests\Compiler\NonAutowirableDecorator", "Symfony\Component\DependencyInjection\Tests\Compiler\NonAutowirableDecorator.inner".', (string) $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testErroredServiceLocator()
|
||||
|
|
|
@ -142,6 +142,10 @@ class FileLoaderTest extends TestCase
|
|||
|
||||
public function testRegisterClassesWithExcludeAsArray()
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78351.');
|
||||
}
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container->setParameter('sub_dir', 'Sub');
|
||||
$loader = new TestFileLoader($container, new FileLocator(self::$fixturesPath.'/Fixtures'));
|
||||
|
|
|
@ -51,11 +51,11 @@ class CountryTypeTest extends BaseTypeTest
|
|||
->createView()->vars['choices'];
|
||||
|
||||
// Don't check objects for identity
|
||||
$this->assertContains(new ChoiceView('DE', 'DE', 'Німеччина'), $choices, '', false, false);
|
||||
$this->assertContains(new ChoiceView('GB', 'GB', 'Велика Британія'), $choices, '', false, false);
|
||||
$this->assertContains(new ChoiceView('US', 'US', 'Сполучені Штати'), $choices, '', false, false);
|
||||
$this->assertContains(new ChoiceView('FR', 'FR', 'Франція'), $choices, '', false, false);
|
||||
$this->assertContains(new ChoiceView('MY', 'MY', 'Малайзія'), $choices, '', false, false);
|
||||
$this->assertContainsEquals(new ChoiceView('DE', 'DE', 'Німеччина'), $choices);
|
||||
$this->assertContainsEquals(new ChoiceView('GB', 'GB', 'Велика Британія'), $choices);
|
||||
$this->assertContainsEquals(new ChoiceView('US', 'US', 'Сполучені Штати'), $choices);
|
||||
$this->assertContainsEquals(new ChoiceView('FR', 'FR', 'Франція'), $choices);
|
||||
$this->assertContainsEquals(new ChoiceView('MY', 'MY', 'Малайзія'), $choices);
|
||||
}
|
||||
|
||||
public function testUnknownCountryIsNotIncluded()
|
||||
|
|
|
@ -48,9 +48,9 @@ class CurrencyTypeTest extends BaseTypeTest
|
|||
->createView()->vars['choices'];
|
||||
|
||||
// Don't check objects for identity
|
||||
$this->assertContains(new ChoiceView('EUR', 'EUR', 'євро'), $choices, '', false, false);
|
||||
$this->assertContains(new ChoiceView('USD', 'USD', 'долар США'), $choices, '', false, false);
|
||||
$this->assertContains(new ChoiceView('SIT', 'SIT', 'словенський толар'), $choices, '', false, false);
|
||||
$this->assertContainsEquals(new ChoiceView('EUR', 'EUR', 'євро'), $choices);
|
||||
$this->assertContainsEquals(new ChoiceView('USD', 'USD', 'долар США'), $choices);
|
||||
$this->assertContainsEquals(new ChoiceView('SIT', 'SIT', 'словенський толар'), $choices);
|
||||
}
|
||||
|
||||
public function testSubmitNull($expected = null, $norm = null, $view = null)
|
||||
|
|
|
@ -50,10 +50,10 @@ class LanguageTypeTest extends BaseTypeTest
|
|||
->createView()->vars['choices'];
|
||||
|
||||
// Don't check objects for identity
|
||||
$this->assertContains(new ChoiceView('en', 'en', 'англійська'), $choices, '', false, false);
|
||||
$this->assertContains(new ChoiceView('en_US', 'en_US', 'англійська (США)'), $choices, '', false, false);
|
||||
$this->assertContains(new ChoiceView('fr', 'fr', 'французька'), $choices, '', false, false);
|
||||
$this->assertContains(new ChoiceView('my', 'my', 'бірманська'), $choices, '', false, false);
|
||||
$this->assertContainsEquals(new ChoiceView('en', 'en', 'англійська'), $choices);
|
||||
$this->assertContainsEquals(new ChoiceView('en_US', 'en_US', 'англійська (США)'), $choices);
|
||||
$this->assertContainsEquals(new ChoiceView('fr', 'fr', 'французька'), $choices);
|
||||
$this->assertContainsEquals(new ChoiceView('my', 'my', 'бірманська'), $choices);
|
||||
}
|
||||
|
||||
public function testMultipleLanguagesIsNotIncluded()
|
||||
|
|
|
@ -48,9 +48,9 @@ class LocaleTypeTest extends BaseTypeTest
|
|||
->createView()->vars['choices'];
|
||||
|
||||
// Don't check objects for identity
|
||||
$this->assertContains(new ChoiceView('en', 'en', 'англійська'), $choices, '', false, false);
|
||||
$this->assertContains(new ChoiceView('en_GB', 'en_GB', 'англійська (Велика Британія)'), $choices, '', false, false);
|
||||
$this->assertContains(new ChoiceView('zh_Hant_MO', 'zh_Hant_MO', 'китайська (традиційна, Макао, О.А.Р Китаю)'), $choices, '', false, false);
|
||||
$this->assertContainsEquals(new ChoiceView('en', 'en', 'англійська'), $choices);
|
||||
$this->assertContainsEquals(new ChoiceView('en_GB', 'en_GB', 'англійська (Велика Британія)'), $choices);
|
||||
$this->assertContainsEquals(new ChoiceView('zh_Hant_MO', 'zh_Hant_MO', 'китайська (традиційна, Макао, О.А.Р Китаю)'), $choices);
|
||||
}
|
||||
|
||||
public function testSubmitNull($expected = null, $norm = null, $view = null)
|
||||
|
|
|
@ -31,19 +31,19 @@ class AbstractTransportTest extends TestCase
|
|||
|
||||
$start = time();
|
||||
$transport->send($message, $envelope);
|
||||
$this->assertEquals(0, time() - $start, '', 1);
|
||||
$this->assertEqualsWithDelta(0, time() - $start, 1);
|
||||
$transport->send($message, $envelope);
|
||||
$this->assertEquals(5, time() - $start, '', 1);
|
||||
$this->assertEqualsWithDelta(5, time() - $start, 1);
|
||||
$transport->send($message, $envelope);
|
||||
$this->assertEquals(10, time() - $start, '', 1);
|
||||
$this->assertEqualsWithDelta(10, time() - $start, 1);
|
||||
$transport->send($message, $envelope);
|
||||
$this->assertEquals(15, time() - $start, '', 1);
|
||||
$this->assertEqualsWithDelta(15, time() - $start, 1);
|
||||
|
||||
$start = time();
|
||||
$transport->setMaxPerSecond(-3);
|
||||
$transport->send($message, $envelope);
|
||||
$this->assertEquals(0, time() - $start, '', 1);
|
||||
$this->assertEqualsWithDelta(0, time() - $start, 1);
|
||||
$transport->send($message, $envelope);
|
||||
$this->assertEquals(0, time() - $start, '', 1);
|
||||
$this->assertEqualsWithDelta(0, time() - $start, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class HandlersLocatorTest extends TestCase
|
|||
{
|
||||
public function testItYieldsHandlerDescriptors()
|
||||
{
|
||||
$handler = $this->createPartialMock(\stdClass::class, ['__invoke']);
|
||||
$handler = $this->createPartialMock(HandlersLocatorTestCallable::class, ['__invoke']);
|
||||
$locator = new HandlersLocator([
|
||||
DummyMessage::class => [$handler],
|
||||
]);
|
||||
|
@ -32,13 +32,13 @@ class HandlersLocatorTest extends TestCase
|
|||
|
||||
public function testItReturnsOnlyHandlersMatchingTransport()
|
||||
{
|
||||
$firstHandler = $this->createPartialMock(\stdClass::class, ['__invoke']);
|
||||
$secondHandler = $this->createPartialMock(\stdClass::class, ['__invoke']);
|
||||
$firstHandler = $this->createPartialMock(HandlersLocatorTestCallable::class, ['__invoke']);
|
||||
$secondHandler = $this->createPartialMock(HandlersLocatorTestCallable::class, ['__invoke']);
|
||||
|
||||
$locator = new HandlersLocator([
|
||||
DummyMessage::class => [
|
||||
$first = new HandlerDescriptor($firstHandler, ['alias' => 'one']),
|
||||
new HandlerDescriptor($this->createPartialMock(\stdClass::class, ['__invoke']), ['from_transport' => 'ignored', 'alias' => 'two']),
|
||||
new HandlerDescriptor($this->createPartialMock(HandlersLocatorTestCallable::class, ['__invoke']), ['from_transport' => 'ignored', 'alias' => 'two']),
|
||||
$second = new HandlerDescriptor($secondHandler, ['from_transport' => 'transportName', 'alias' => 'three']),
|
||||
],
|
||||
]);
|
||||
|
@ -51,3 +51,10 @@ class HandlersLocatorTest extends TestCase
|
|||
)));
|
||||
}
|
||||
}
|
||||
|
||||
class HandlersLocatorTestCallable
|
||||
{
|
||||
public function __invoke()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class ActivationMiddlewareTest extends MiddlewareTestCase
|
|||
$message = new DummyMessage('Hello');
|
||||
$envelope = new Envelope($message);
|
||||
|
||||
$activated = $this->createPartialMock(\stdClass::class, ['__invoke']);
|
||||
$activated = $this->createPartialMock(ActivationMiddlewareTestCallable::class, ['__invoke']);
|
||||
$activated->expects($this->once())->method('__invoke')->with($envelope)->willReturn(true);
|
||||
|
||||
$stack = $this->getStackMock(false);
|
||||
|
@ -68,3 +68,10 @@ class ActivationMiddlewareTest extends MiddlewareTestCase
|
|||
$decorator->handle($envelope, $this->getStackMock());
|
||||
}
|
||||
}
|
||||
|
||||
class ActivationMiddlewareTestCallable
|
||||
{
|
||||
public function __invoke()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class HandleMessageMiddlewareTest extends MiddlewareTestCase
|
|||
$message = new DummyMessage('Hey');
|
||||
$envelope = new Envelope($message);
|
||||
|
||||
$handler = $this->createPartialMock(\stdClass::class, ['__invoke']);
|
||||
$handler = $this->createPartialMock(HandleMessageMiddlewareTestCallable::class, ['__invoke']);
|
||||
|
||||
$middleware = new HandleMessageMiddleware(new HandlersLocator([
|
||||
DummyMessage::class => [$handler],
|
||||
|
@ -62,15 +62,15 @@ class HandleMessageMiddlewareTest extends MiddlewareTestCase
|
|||
|
||||
public function itAddsHandledStampsProvider()
|
||||
{
|
||||
$first = $this->createPartialMock(\stdClass::class, ['__invoke']);
|
||||
$first = $this->createPartialMock(HandleMessageMiddlewareTestCallable::class, ['__invoke']);
|
||||
$first->method('__invoke')->willReturn('first result');
|
||||
$firstClass = \get_class($first);
|
||||
|
||||
$second = $this->createPartialMock(\stdClass::class, ['__invoke']);
|
||||
$second = $this->createPartialMock(HandleMessageMiddlewareTestCallable::class, ['__invoke']);
|
||||
$second->method('__invoke')->willReturn(null);
|
||||
$secondClass = \get_class($second);
|
||||
|
||||
$failing = $this->createPartialMock(\stdClass::class, ['__invoke']);
|
||||
$failing = $this->createPartialMock(HandleMessageMiddlewareTestCallable::class, ['__invoke']);
|
||||
$failing->method('__invoke')->will($this->throwException(new \Exception('handler failed.')));
|
||||
|
||||
yield 'A stamp is added' => [
|
||||
|
@ -129,3 +129,10 @@ class HandleMessageMiddlewareTest extends MiddlewareTestCase
|
|||
$this->assertInstanceOf(Envelope::class, $middleware->handle(new Envelope(new DummyMessage('Hey')), new StackMiddleware()));
|
||||
}
|
||||
}
|
||||
|
||||
class HandleMessageMiddlewareTestCallable
|
||||
{
|
||||
public function __invoke()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class DoctrineSenderTest extends TestCase
|
|||
$encoded = ['body' => '...', 'headers' => ['type' => DummyMessage::class]];
|
||||
|
||||
$connection = $this->createMock(Connection::class);
|
||||
$connection->expects($this->once())->method('send')->with($encoded['body'], $encoded['headers'])->willReturn(15);
|
||||
$connection->expects($this->once())->method('send')->with($encoded['body'], $encoded['headers'])->willReturn('15');
|
||||
|
||||
$serializer = $this->createMock(SerializerInterface::class);
|
||||
$serializer->method('encode')->with($envelope)->willReturnOnConsecutiveCalls($encoded);
|
||||
|
|
|
@ -27,7 +27,7 @@ class PhpSerializerTest extends TestCase
|
|||
$envelope = new Envelope(new DummyMessage('Hello'));
|
||||
|
||||
$encoded = $serializer->encode($envelope);
|
||||
$this->assertNotContains("\0", $encoded['body'], 'Does not contain the binary characters');
|
||||
$this->assertStringNotContainsString("\0", $encoded['body'], 'Does not contain the binary characters');
|
||||
$this->assertEquals($envelope, $serializer->decode($encoded));
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ class PhpSerializerTest extends TestCase
|
|||
]);
|
||||
|
||||
$encoded = $serializer->encode($envelope);
|
||||
$this->assertNotContains('DummyPhpSerializerNonSendableStamp', $encoded['body']);
|
||||
$this->assertStringNotContainsString('DummyPhpSerializerNonSendableStamp', $encoded['body']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ class SerializerTest extends TestCase
|
|||
]);
|
||||
|
||||
$encoded = $serializer->encode($envelope);
|
||||
$this->assertNotContains('DummySymfonySerializerNonSendableStamp', print_r($encoded['headers'], true));
|
||||
$this->assertStringNotContainsString('DummySymfonySerializerNonSendableStamp', print_r($encoded['headers'], true));
|
||||
}
|
||||
}
|
||||
class DummySymfonySerializerNonSendableStamp implements NonSendableStampInterface
|
||||
|
|
|
@ -58,7 +58,7 @@ class SyncTransport implements TransportInterface
|
|||
{
|
||||
/** @var SentStamp|null $sentStamp */
|
||||
$sentStamp = $envelope->last(SentStamp::class);
|
||||
$alias = null === $sentStamp ? 'sync' : $sentStamp->getSenderAlias() ?: $sentStamp->getSenderClass();
|
||||
$alias = null === $sentStamp ? 'sync' : ($sentStamp->getSenderAlias() ?: $sentStamp->getSenderClass());
|
||||
|
||||
$envelope = $envelope->with(new ReceivedStamp($alias));
|
||||
|
||||
|
|
|
@ -466,6 +466,8 @@ Symfony\Component\VarDumper\Cloner\Data Object
|
|||
[position] => 1
|
||||
[attr] => Array
|
||||
(
|
||||
[file] => %s
|
||||
[line] => 5
|
||||
)
|
||||
|
||||
)
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
namespace Symfony\Component\VarExporter\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Warning;
|
||||
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
|
||||
use Symfony\Component\VarExporter\Internal\Registry;
|
||||
use Symfony\Component\VarExporter\VarExporter;
|
||||
|
@ -75,6 +76,13 @@ class VarExporterTest extends TestCase
|
|||
*/
|
||||
public function testExport(string $testName, $value, bool $staticValueExpected = false)
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70400 && 'datetime' === $testName) {
|
||||
throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78383.');
|
||||
}
|
||||
if (\PHP_VERSION_ID >= 70400 && \in_array($testName, ['spl-object-storage', 'array-object-custom', 'array-iterator', 'array-object', 'final-array-iterator'])) {
|
||||
throw new Warning('PHP 7.4 breaks this test.');
|
||||
}
|
||||
|
||||
$dumpedValue = $this->getDump($value);
|
||||
$isStaticValue = true;
|
||||
$marshalledValue = VarExporter::export($value, $isStaticValue);
|
||||
|
|
Reference in New Issue