diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/returns_clone.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/returns_clone.xml new file mode 100644 index 0000000000..142b39d015 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/returns_clone.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/returns_clone.yaml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/returns_clone.yaml new file mode 100644 index 0000000000..2a8651458b --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/returns_clone.yaml @@ -0,0 +1,5 @@ +services: + foo: + calls: + - {method: bar, arguments: [1], returns_clone: true} + - [bar, [2], true] diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index dafa0464ed..7b8800f195 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -901,4 +901,13 @@ class XmlFileLoaderTest extends TestCase $this->assertSame('overridden', $container->get('bar')->quz); } + + public function testReturnsClone() + { + $container = new ContainerBuilder(); + $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); + $loader->load('returns_clone.xml'); + + $this->assertSame([['bar', [], true]], $container->getDefinition('foo')->getMethodCalls()); + } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index d7c99cb4bd..4568f74d0a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -834,4 +834,17 @@ class YamlFileLoaderTest extends TestCase $this->assertInstanceOf(TaggedIteratorArgument::class, $iteratorArgument); $this->assertNull($iteratorArgument->getIndexAttribute()); } + + public function testReturnsClone() + { + $container = new ContainerBuilder(); + $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); + $loader->load('returns_clone.yaml'); + + $expected = [ + ['bar', [1], true], + ['bar', [2], true], + ]; + $this->assertSame($expected, $container->getDefinition('foo')->getMethodCalls()); + } }