X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fsymfony%2Fdependency-injection%2FTests%2FCompiler%2FResolveInvalidReferencesPassTest.php;fp=vendor%2Fsymfony%2Fdependency-injection%2FTests%2FCompiler%2FResolveInvalidReferencesPassTest.php;h=8cf4e5186cd1c7f719e68145ac8e094df2cb89c4;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=ad698d2bff48328105ef004c4eccfe9d717ec6fa;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/vendor/symfony/dependency-injection/Tests/Compiler/ResolveInvalidReferencesPassTest.php b/vendor/symfony/dependency-injection/Tests/Compiler/ResolveInvalidReferencesPassTest.php index ad698d2bf..8cf4e5186 100644 --- a/vendor/symfony/dependency-injection/Tests/Compiler/ResolveInvalidReferencesPassTest.php +++ b/vendor/symfony/dependency-injection/Tests/Compiler/ResolveInvalidReferencesPassTest.php @@ -24,59 +24,88 @@ class ResolveInvalidReferencesPassTest extends TestCase $container = new ContainerBuilder(); $def = $container ->register('foo') - ->setArguments(array(new Reference('bar', ContainerInterface::NULL_ON_INVALID_REFERENCE))) + ->setArguments(array( + new Reference('bar', ContainerInterface::NULL_ON_INVALID_REFERENCE), + new Reference('baz', ContainerInterface::IGNORE_ON_INVALID_REFERENCE), + )) ->addMethodCall('foo', array(new Reference('moo', ContainerInterface::IGNORE_ON_INVALID_REFERENCE))) ; $this->process($container); $arguments = $def->getArguments(); - $this->assertNull($arguments[0]); + $this->assertSame(array(null, null), $arguments); $this->assertCount(0, $def->getMethodCalls()); } - public function testProcessIgnoreNonExistentServices() + public function testProcessIgnoreInvalidArgumentInCollectionArgument() { $container = new ContainerBuilder(); + $container->register('baz'); $def = $container ->register('foo') - ->setArguments(array(new Reference('bar'))) + ->setArguments(array( + array( + new Reference('bar', ContainerInterface::IGNORE_ON_INVALID_REFERENCE), + $baz = new Reference('baz', ContainerInterface::IGNORE_ON_INVALID_REFERENCE), + new Reference('moo', ContainerInterface::NULL_ON_INVALID_REFERENCE), + ), + )) ; $this->process($container); $arguments = $def->getArguments(); - $this->assertEquals('bar', (string) $arguments[0]); + $this->assertSame(array($baz, null), $arguments[0]); } - public function testProcessRemovesPropertiesOnInvalid() + public function testProcessKeepMethodCallOnInvalidArgumentInCollectionArgument() { $container = new ContainerBuilder(); + $container->register('baz'); $def = $container ->register('foo') - ->setProperty('foo', new Reference('bar', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)) + ->addMethodCall('foo', array( + array( + new Reference('bar', ContainerInterface::IGNORE_ON_INVALID_REFERENCE), + $baz = new Reference('baz', ContainerInterface::IGNORE_ON_INVALID_REFERENCE), + new Reference('moo', ContainerInterface::NULL_ON_INVALID_REFERENCE), + ), + )) ; $this->process($container); - $this->assertEquals(array(), $def->getProperties()); + $calls = $def->getMethodCalls(); + $this->assertCount(1, $def->getMethodCalls()); + $this->assertSame(array($baz, null), $calls[0][1][0]); } - /** - * @group legacy - */ - public function testStrictFlagIsPreserved() + public function testProcessIgnoreNonExistentServices() { $container = new ContainerBuilder(); - $container->register('bar'); $def = $container ->register('foo') - ->addArgument(new Reference('bar', ContainerInterface::NULL_ON_INVALID_REFERENCE, false)) + ->setArguments(array(new Reference('bar'))) ; $this->process($container); - $this->assertFalse($def->getArgument(0)->isStrict()); + $arguments = $def->getArguments(); + $this->assertEquals('bar', (string) $arguments[0]); + } + + public function testProcessRemovesPropertiesOnInvalid() + { + $container = new ContainerBuilder(); + $def = $container + ->register('foo') + ->setProperty('foo', new Reference('bar', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)) + ; + + $this->process($container); + + $this->assertEquals(array(), $def->getProperties()); } protected function process(ContainerBuilder $container)