minor #33801 [DI] add tests loading calls with returns-clone (nicolas-grekas)

This PR was merged into the 4.3 branch.

Discussion
----------

[DI] add tests loading calls with returns-clone

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Commits
-------

9a48def0c0 [DI] add tests loading calls with returns-clone
This commit is contained in:
Nicolas Grekas 2019-10-02 14:55:34 +02:00
commit badb656f62
4 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,11 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="foo">
<call method="bar" returns-clone="true" />
</service>
</services>
</container>

View File

@ -0,0 +1,5 @@
services:
foo:
calls:
- {method: bar, arguments: [1], returns_clone: true}
- [bar, [2], true]

View File

@ -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());
}
}

View File

@ -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());
}
}