Skip to content

Commit 8b0f531

Browse files
Merge branch '4.3' into 4.4
* 4.3: [FrameworkBundle] Fix wrong returned status code in ConfigDebugCommand [AnnotationCacheWarmer] add RedirectController to annotation cache [DI] add tests loading calls with returns-clone [EventDispatcher] Added tests for aliased events. [DI] Add CSV env var processor tests
2 parents 3edc224 + e1e0762 commit 8b0f531

File tree

6 files changed

+72
-1
lines changed

6 files changed

+72
-1
lines changed

EnvVarProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public function getEnv($prefix, $name, \Closure $getEnv)
236236
}
237237

238238
if ('csv' === $prefix) {
239-
return str_getcsv($env);
239+
return str_getcsv($env, ',', '"', \PHP_VERSION_ID >= 70400 ? '' : '\\');
240240
}
241241

242242
if ('trim' === $prefix) {

Tests/EnvVarProcessorTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,4 +478,37 @@ public function testRequireFile()
478478

479479
$this->assertEquals('foo', $result);
480480
}
481+
482+
/**
483+
* @dataProvider validCsv
484+
*/
485+
public function testGetEnvCsv($value, $processed)
486+
{
487+
$processor = new EnvVarProcessor(new Container());
488+
489+
$result = $processor->getEnv('csv', 'foo', function ($name) use ($value) {
490+
$this->assertSame('foo', $name);
491+
492+
return $value;
493+
});
494+
495+
$this->assertSame($processed, $result);
496+
}
497+
498+
public function validCsv()
499+
{
500+
$complex = <<<'CSV'
501+
,"""","foo""","\""",\,foo\
502+
CSV;
503+
504+
return [
505+
['', [null]],
506+
[',', ['', '']],
507+
['1', ['1']],
508+
['1,2," 3 "', ['1', '2', ' 3 ']],
509+
['\\,\\\\', ['\\', '\\\\']],
510+
[$complex, \PHP_VERSION_ID >= 70400 ? ['', '"', 'foo"', '\\"', '\\', 'foo\\'] : ['', '"', 'foo"', '\\"",\\,foo\\']],
511+
[null, null],
512+
];
513+
}
481514
}

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
@@ -904,6 +904,15 @@ public function testOverriddenDefaultsBindings()
904904
$this->assertSame('overridden', $container->get('bar')->quz);
905905
}
906906

907+
public function testReturnsClone()
908+
{
909+
$container = new ContainerBuilder();
910+
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
911+
$loader->load('returns_clone.xml');
912+
913+
$this->assertSame([['bar', [], true]], $container->getDefinition('foo')->getMethodCalls());
914+
}
915+
907916
public function testSinglyImplementedInterfacesInMultipleResources()
908917
{
909918
$container = new ContainerBuilder();

Tests/Loader/YamlFileLoaderTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,19 @@ public function testDefaultValueOfTagged()
842842
$this->assertNull($iteratorArgument->getIndexAttribute());
843843
}
844844

845+
public function testReturnsClone()
846+
{
847+
$container = new ContainerBuilder();
848+
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
849+
$loader->load('returns_clone.yaml');
850+
851+
$expected = [
852+
['bar', [1], true],
853+
['bar', [2], true],
854+
];
855+
$this->assertSame($expected, $container->getDefinition('foo')->getMethodCalls());
856+
}
857+
845858
public function testSinglyImplementedInterfacesInMultipleResources()
846859
{
847860
$container = new ContainerBuilder();

0 commit comments

Comments
 (0)