From 9a48def0c08fcb624cfe25db668f0eeee8bbd8a9 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 2 Oct 2019 10:03:02 +0200 Subject: [PATCH] [DI] add tests loading calls with returns-clone --- .../Tests/Fixtures/xml/returns_clone.xml | 11 +++++++++++ .../Tests/Fixtures/yaml/returns_clone.yaml | 5 +++++ .../Tests/Loader/XmlFileLoaderTest.php | 9 +++++++++ .../Tests/Loader/YamlFileLoaderTest.php | 13 +++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/returns_clone.xml create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/returns_clone.yaml 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()); + } }