8000 more tests · symfony/symfony@5cf6a3f · GitHub
[go: up one dir, main page]

Skip to content

Commit 5cf6a3f

Browse files
renanbrnicolas-grekas
renanbr
authored andcommitted
more tests
1 parent 35a40ac commit 5cf6a3f

File tree

6 files changed

+47
-2
lines changed

6 files changed

+47
-2
lines changed

src/Symfony/Component/DependencyInjection/Tests/Fixtures/Bar.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313

1414
class Bar implements BarInterface
1515
{
16+
public $quz;
17+
1618
public function __construct($quz = null, \NonExistent $nonExistent = null, BarInterface $decorated = null, array $foo = [])
1719
{
20+
$this->quz = $quz;
1821
}
1922

2023
public static function create(\NonExistent $nonExistent = null, $factory = null)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<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 http://symfony.com/schema/dic/services/services-1.0.xsd">
3+
<services>
4+
<defaults>
5+
<bind key="$quz">value</bind>
6+
<bind key="$foo" type="collection">
7+
<bind>value</bind>
8+
</bind>
9+
</defaults>
10+
11+
<service id="bar" class="Symfony\Component\DependencyInjection\Tests\Fixtures\Bar"/>
12+
13+
<service id="foo" class="Symfony\Component\DependencyInjection\Tests\Fixtures\FactoryDummy"/>
14+
</services>
15+
</container>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<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 http://symfony.com/schema/dic/services/services-1.0.xsd">
3+
<services>
4+
<defaults>
5+
<bind key="$quz">overridden</bind>
6+
</defaults>
7+
8+
<service id="bar" class="Symfony\Component\DependencyInjection\Tests\Fixtures\Bar"/>
9+
</services>
10+
</container>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
services:
22
_defaults:
33
bind:
4-
$quz: ~
4+
$quz: overridden
55

66
bar:
77
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Bar

src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Config\Resource\FileResource;
1818
use Symfony\Component\Config\Resource\GlobResource;
1919
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
20+
use Symfony\Component\DependencyInjection\Compiler\ResolveBindingsPass;
2021
use Symfony\Component\DependencyInjection\ContainerBuilder;
2122
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
2223
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
@@ -820,4 +821,20 @@ public function testTsantosContainer()
820821
$dump = $dumper->dump();
821822
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_tsantos.php', $dumper->dump());
822823
}
824+
825+
/**
826+
* The pass may throw an exception, which will cause the test to fail.
827+
*/
828+
public function testOverriddenDefaultsBindings()
829+
{
830+
$container = new ContainerBuilder();
831+
832+
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
833+
$loader->load('defaults_bindings.xml');
834+
$loader->load('defaults_bindings2.xml');
835+
836+
(new ResolveBindingsPass())->process($container);
837+
838+
$this->assertSame('overridden', $container->get('bar')->quz);
839+
}
823840
}

src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,6 @@ public function testOverriddenDefaultsBindings()
747747

748748
(new ResolveBindingsPass())->process($container);
749749

750-
$this->assertTrue(true);
750+
$this->assertSame('overridden', $container->get('bar')->quz);
751751
}
752752
}

0 commit comments

Comments
 (0)
0