Skip to content

Commit 581f30c

Browse files
[DI] add tests loading calls with returns-clone
1 parent 353d1c8 commit 581f30c

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

Tests/Fixtures/xml/returns_clone.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
5+
6+
<services>
7+
<service id="foo">
8+
<call method="bar" returns-clone="true" />
9+
</service>
10+
</services>
11+
</container>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
services:
2+
foo:
3+
calls:
4+
- {method: bar, arguments: [1], returns_clone: true}
5+
- [bar, [2], true]

Tests/Loader/XmlFileLoaderTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,4 +901,13 @@ public function testOverriddenDefaultsBindings()
901901

902902
$this->assertSame('overridden', $container->get('bar')->quz);
903903
}
904+
905+
public function testReturnsClone()
906+
{
907+
$container = new ContainerBuilder();
908+
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
909+
$loader->load('returns_clone.xml');
910+
911+
$this->assertSame([['bar', [], true]], $container->getDefinition('foo')->getMethodCalls());
912+
}
904913
}

Tests/Loader/YamlFileLoaderTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,4 +834,17 @@ public function testDefaultValueOfTagged()
834834
$this->assertInstanceOf(TaggedIteratorArgument::class, $iteratorArgument);
835835
$this->assertNull($iteratorArgument->getIndexAttribute());
836836
}
837+
838+
public function testReturnsClone()
839+
{
840+
$container = new ContainerBuilder();
841+
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
842+
$loader->load('returns_clone.yaml');
843+
844+
$expected = [
845+
['bar', [1], true],
846+
['bar', [2], true],
847+
];
848+
$this->assertSame($expected, $container->getDefinition('foo')->getMethodCalls());
849+
}
837850
}

0 commit comments

Comments
 (0)