more tests
This commit is contained in:
parent
35a40ace6f
commit
7e805eae2b
@ -13,8 +13,11 @@ namespace Symfony\Component\DependencyInjection\Tests\Fixtures;
|
|||||||
|
|
||||||
class Bar implements BarInterface
|
class Bar implements BarInterface
|
||||||
{
|
{
|
||||||
|
public $quz;
|
||||||
|
|
||||||
public function __construct($quz = null, \NonExistent $nonExistent = null, BarInterface $decorated = null, array $foo = [])
|
public function __construct($quz = null, \NonExistent $nonExistent = null, BarInterface $decorated = null, array $foo = [])
|
||||||
{
|
{
|
||||||
|
$this->quz = $quz;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function create(\NonExistent $nonExistent = null, $factory = null)
|
public static function create(\NonExistent $nonExistent = null, $factory = null)
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<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">
|
||||||
|
<services>
|
||||||
|
<defaults>
|
||||||
|
<bind key="$quz">value</bind>
|
||||||
|
<bind key="$foo" type="collection">
|
||||||
|
<bind>value</bind>
|
||||||
|
</bind>
|
||||||
|
</defaults>
|
||||||
|
|
||||||
|
<service id="bar" class="Symfony\Component\DependencyInjection\Tests\Fixtures\Bar"/>
|
||||||
|
|
||||||
|
<service id="foo" class="stdClass"/>
|
||||||
|
</services>
|
||||||
|
</container>
|
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<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">
|
||||||
|
<services>
|
||||||
|
<defaults>
|
||||||
|
<bind key="$quz">overridden</bind>
|
||||||
|
</defaults>
|
||||||
|
|
||||||
|
<service id="bar" class="Symfony\Component\DependencyInjection\Tests\Fixtures\Bar"/>
|
||||||
|
</services>
|
||||||
|
</container>
|
@ -8,4 +8,4 @@ services:
|
|||||||
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Bar
|
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Bar
|
||||||
|
|
||||||
foo:
|
foo:
|
||||||
class: Symfony\Component\DependencyInjection\Tests\Fixtures\FactoryDummy
|
class: stdClass
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
services:
|
services:
|
||||||
_defaults:
|
_defaults:
|
||||||
bind:
|
bind:
|
||||||
$quz: ~
|
$quz: overridden
|
||||||
|
|
||||||
bar:
|
bar:
|
||||||
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Bar
|
class: Symfony\Component\DependencyInjection\Tests\Fixtures\Bar
|
||||||
|
@ -17,6 +17,7 @@ use Symfony\Component\Config\Loader\LoaderResolver;
|
|||||||
use Symfony\Component\Config\Resource\FileResource;
|
use Symfony\Component\Config\Resource\FileResource;
|
||||||
use Symfony\Component\Config\Resource\GlobResource;
|
use Symfony\Component\Config\Resource\GlobResource;
|
||||||
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
||||||
|
use Symfony\Component\DependencyInjection\Compiler\ResolveBindingsPass;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
|
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
|
||||||
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
|
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
|
||||||
@ -820,4 +821,20 @@ class XmlFileLoaderTest extends TestCase
|
|||||||
$dump = $dumper->dump();
|
$dump = $dumper->dump();
|
||||||
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_tsantos.php', $dumper->dump());
|
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_tsantos.php', $dumper->dump());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The pass may throw an exception, which will cause the test to fail.
|
||||||
|
*/
|
||||||
|
public function testOverriddenDefaultsBindings()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
|
||||||
|
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
|
||||||
|
$loader->load('defaults_bindings.xml');
|
||||||
|
$loader->load('defaults_bindings2.xml');
|
||||||
|
|
||||||
|
(new ResolveBindingsPass())->process($container);
|
||||||
|
|
||||||
|
$this->assertSame('overridden', $container->get('bar')->quz);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -747,6 +747,6 @@ class YamlFileLoaderTest extends TestCase
|
|||||||
|
|
||||||
(new ResolveBindingsPass())->process($container);
|
(new ResolveBindingsPass())->process($container);
|
||||||
|
|
||||||
$this->assertTrue(true);
|
$this->assertSame('overridden', $container->get('bar')->quz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user