Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
90
vendor/symfony/dependency-injection/Tests/Dumper/GraphvizDumperTest.php
vendored
Normal file
90
vendor/symfony/dependency-injection/Tests/Dumper/GraphvizDumperTest.php
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Dumper;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Dumper\GraphvizDumper;
|
||||
|
||||
class GraphvizDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $fixturesPath;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
self::$fixturesPath = __DIR__.'/../Fixtures/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyDump()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/legacy-container9.php';
|
||||
$dumper = new GraphvizDumper($container);
|
||||
$this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/legacy-services9.dot')), $dumper->dump(), '->dump() dumps services');
|
||||
}
|
||||
|
||||
public function testDump()
|
||||
{
|
||||
$dumper = new GraphvizDumper($container = new ContainerBuilder());
|
||||
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/graphviz/services1.dot', $dumper->dump(), '->dump() dumps an empty container as an empty dot file');
|
||||
|
||||
$container = include self::$fixturesPath.'/containers/container9.php';
|
||||
$dumper = new GraphvizDumper($container);
|
||||
$this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services9.dot')), $dumper->dump(), '->dump() dumps services');
|
||||
|
||||
$container = include self::$fixturesPath.'/containers/container10.php';
|
||||
$dumper = new GraphvizDumper($container);
|
||||
$this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services10.dot')), $dumper->dump(), '->dump() dumps services');
|
||||
|
||||
$container = include self::$fixturesPath.'/containers/container10.php';
|
||||
$dumper = new GraphvizDumper($container);
|
||||
$this->assertEquals($dumper->dump(array(
|
||||
'graph' => array('ratio' => 'normal'),
|
||||
'node' => array('fontsize' => 13, 'fontname' => 'Verdana', 'shape' => 'square'),
|
||||
'edge' => array('fontsize' => 12, 'fontname' => 'Verdana', 'color' => 'white', 'arrowhead' => 'closed', 'arrowsize' => 1),
|
||||
'node.instance' => array('fillcolor' => 'green', 'style' => 'empty'),
|
||||
'node.definition' => array('fillcolor' => 'grey'),
|
||||
'node.missing' => array('fillcolor' => 'red', 'style' => 'empty'),
|
||||
)), str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services10-1.dot')), '->dump() dumps services');
|
||||
}
|
||||
|
||||
public function testDumpWithFrozenContainer()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/container13.php';
|
||||
$dumper = new GraphvizDumper($container);
|
||||
$this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services13.dot')), $dumper->dump(), '->dump() dumps services');
|
||||
}
|
||||
|
||||
public function testDumpWithFrozenCustomClassContainer()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/container14.php';
|
||||
$dumper = new GraphvizDumper($container);
|
||||
$this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services14.dot')), $dumper->dump(), '->dump() dumps services');
|
||||
}
|
||||
|
||||
public function testDumpWithUnresolvedParameter()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/container17.php';
|
||||
$dumper = new GraphvizDumper($container);
|
||||
|
||||
$this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services17.dot')), $dumper->dump(), '->dump() dumps services');
|
||||
}
|
||||
|
||||
public function testDumpWithScopes()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/container18.php';
|
||||
$dumper = new GraphvizDumper($container);
|
||||
$this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services18.dot')), $dumper->dump(), '->dump() dumps services');
|
||||
}
|
||||
}
|
221
vendor/symfony/dependency-injection/Tests/Dumper/PhpDumperTest.php
vendored
Normal file
221
vendor/symfony/dependency-injection/Tests/Dumper/PhpDumperTest.php
vendored
Normal file
|
@ -0,0 +1,221 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Dumper;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
|
||||
class PhpDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $fixturesPath;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
self::$fixturesPath = realpath(__DIR__.'/../Fixtures/');
|
||||
}
|
||||
|
||||
public function testDump()
|
||||
{
|
||||
$dumper = new PhpDumper($container = new ContainerBuilder());
|
||||
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services1.php', $dumper->dump(), '->dump() dumps an empty container as an empty PHP class');
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services1-1.php', $dumper->dump(array('class' => 'Container', 'base_class' => 'AbstractContainer', 'namespace' => 'Symfony\Component\DependencyInjection\Dump')), '->dump() takes a class and a base_class options');
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
new PhpDumper($container);
|
||||
}
|
||||
|
||||
public function testDumpOptimizationString()
|
||||
{
|
||||
$definition = new Definition();
|
||||
$definition->setClass('stdClass');
|
||||
$definition->addArgument(array(
|
||||
'only dot' => '.',
|
||||
'concatenation as value' => '.\'\'.',
|
||||
'concatenation from the start value' => '\'\'.',
|
||||
'.' => 'dot as a key',
|
||||
'.\'\'.' => 'concatenation as a key',
|
||||
'\'\'.' => 'concatenation from the start key',
|
||||
'optimize concatenation' => 'string1%some_string%string2',
|
||||
'optimize concatenation with empty string' => 'string1%empty_value%string2',
|
||||
'optimize concatenation from the start' => '%empty_value%start',
|
||||
'optimize concatenation at the end' => 'end%empty_value%',
|
||||
));
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container->setResourceTracking(false);
|
||||
$container->setDefinition('test', $definition);
|
||||
$container->setParameter('empty_value', '');
|
||||
$container->setParameter('some_string', '-');
|
||||
$container->compile();
|
||||
|
||||
$dumper = new PhpDumper($container);
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services10.php', $dumper->dump(), '->dump() dumps an empty container as an empty PHP class');
|
||||
}
|
||||
|
||||
public function testDumpRelativeDir()
|
||||
{
|
||||
$definition = new Definition();
|
||||
$definition->setClass('stdClass');
|
||||
$definition->addArgument('%foo%');
|
||||
$definition->addArgument(array('%foo%' => '%buz%/'));
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container->setDefinition('test', $definition);
|
||||
$container->setParameter('foo', 'wiz'.dirname(__DIR__));
|
||||
$container->setParameter('bar', __DIR__);
|
||||
$container->setParameter('baz', '%bar%/PhpDumperTest.php');
|
||||
$container->setParameter('buz', dirname(dirname(__DIR__)));
|
||||
$container->compile();
|
||||
|
||||
$dumper = new PhpDumper($container);
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services12.php', $dumper->dump(array('file' => __FILE__)), '->dump() dumps __DIR__ relative strings');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExportParameters()
|
||||
{
|
||||
$dumper = new PhpDumper(new ContainerBuilder(new ParameterBag(array('foo' => new Reference('foo')))));
|
||||
$dumper->dump();
|
||||
}
|
||||
|
||||
public function testAddParameters()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/container8.php';
|
||||
$dumper = new PhpDumper($container);
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services8.php', $dumper->dump(), '->dump() dumps parameters');
|
||||
}
|
||||
|
||||
public function testAddService()
|
||||
{
|
||||
// without compilation
|
||||
$container = include self::$fixturesPath.'/containers/container9.php';
|
||||
$dumper = new PhpDumper($container);
|
||||
$this->assertEquals(str_replace('%path%', str_replace('\\', '\\\\', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR), file_get_contents(self::$fixturesPath.'/php/services9.php')), $dumper->dump(), '->dump() dumps services');
|
||||
|
||||
// with compilation
|
||||
$container = include self::$fixturesPath.'/containers/container9.php';
|
||||
$container->compile();
|
||||
$dumper = new PhpDumper($container);
|
||||
$this->assertEquals(str_replace('%path%', str_replace('\\', '\\\\', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR), file_get_contents(self::$fixturesPath.'/php/services9_compiled.php')), $dumper->dump(), '->dump() dumps services');
|
||||
|
||||
$dumper = new PhpDumper($container = new ContainerBuilder());
|
||||
$container->register('foo', 'FooClass')->addArgument(new \stdClass());
|
||||
try {
|
||||
$dumper->dump();
|
||||
$this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\Symfony\Component\DependencyInjection\Exception\RuntimeException', $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
$this->assertEquals('Unable to dump a service container if a parameter is an object or a resource.', $e->getMessage(), '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacySynchronizedServices()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/container20.php';
|
||||
$dumper = new PhpDumper($container);
|
||||
$this->assertEquals(str_replace('%path%', str_replace('\\', '\\\\', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR), file_get_contents(self::$fixturesPath.'/php/services20.php')), $dumper->dump(), '->dump() dumps services');
|
||||
}
|
||||
|
||||
public function testServicesWithAnonymousFactories()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/container19.php';
|
||||
$dumper = new PhpDumper($container);
|
||||
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services19.php', $dumper->dump(), '->dump() dumps services with anonymous factories');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Service id "bar$" cannot be converted to a valid PHP method name.
|
||||
*/
|
||||
public function testAddServiceInvalidServiceId()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('bar$', 'FooClass');
|
||||
$dumper = new PhpDumper($container);
|
||||
$dumper->dump();
|
||||
}
|
||||
|
||||
public function testAliases()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/container9.php';
|
||||
$container->compile();
|
||||
$dumper = new PhpDumper($container);
|
||||
eval('?>'.$dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Aliases')));
|
||||
|
||||
$container = new \Symfony_DI_PhpDumper_Test_Aliases();
|
||||
$container->set('foo', $foo = new \stdClass());
|
||||
$this->assertSame($foo, $container->get('foo'));
|
||||
$this->assertSame($foo, $container->get('alias_for_foo'));
|
||||
$this->assertSame($foo, $container->get('alias_for_alias'));
|
||||
}
|
||||
|
||||
public function testFrozenContainerWithoutAliases()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->compile();
|
||||
|
||||
$dumper = new PhpDumper($container);
|
||||
eval('?>'.$dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Frozen_No_Aliases')));
|
||||
|
||||
$container = new \Symfony_DI_PhpDumper_Test_Frozen_No_Aliases();
|
||||
$this->assertFalse($container->has('foo'));
|
||||
}
|
||||
|
||||
public function testOverrideServiceWhenUsingADumpedContainer()
|
||||
{
|
||||
require_once self::$fixturesPath.'/php/services9.php';
|
||||
require_once self::$fixturesPath.'/includes/foo.php';
|
||||
|
||||
$container = new \ProjectServiceContainer();
|
||||
$container->set('bar', $bar = new \stdClass());
|
||||
$container->setParameter('foo_bar', 'foo_bar');
|
||||
|
||||
$this->assertEquals($bar, $container->get('bar'), '->set() overrides an already defined service');
|
||||
}
|
||||
|
||||
public function testOverrideServiceWhenUsingADumpedContainerAndServiceIsUsedFromAnotherOne()
|
||||
{
|
||||
require_once self::$fixturesPath.'/php/services9.php';
|
||||
require_once self::$fixturesPath.'/includes/foo.php';
|
||||
require_once self::$fixturesPath.'/includes/classes.php';
|
||||
|
||||
$container = new \ProjectServiceContainer();
|
||||
$container->set('bar', $bar = new \stdClass());
|
||||
|
||||
$this->assertSame($bar, $container->get('foo')->bar, '->set() overrides an already defined service');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
|
||||
*/
|
||||
public function testCircularReference()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('foo', 'stdClass')->addArgument(new Reference('bar'));
|
||||
$container->register('bar', 'stdClass')->setPublic(false)->addMethodCall('setA', array(new Reference('baz')));
|
||||
$container->register('baz', 'stdClass')->addMethodCall('setA', array(new Reference('foo')));
|
||||
$container->compile();
|
||||
|
||||
$dumper = new PhpDumper($container);
|
||||
$dumper->dump();
|
||||
}
|
||||
}
|
184
vendor/symfony/dependency-injection/Tests/Dumper/XmlDumperTest.php
vendored
Normal file
184
vendor/symfony/dependency-injection/Tests/Dumper/XmlDumperTest.php
vendored
Normal file
|
@ -0,0 +1,184 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Dumper;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Dumper\XmlDumper;
|
||||
|
||||
class XmlDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $fixturesPath;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
self::$fixturesPath = realpath(__DIR__.'/../Fixtures/');
|
||||
}
|
||||
|
||||
public function testDump()
|
||||
{
|
||||
$dumper = new XmlDumper(new ContainerBuilder());
|
||||
|
||||
$this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/xml/services1.xml', $dumper->dump(), '->dump() dumps an empty container as an empty XML file');
|
||||
}
|
||||
|
||||
public function testExportParameters()
|
||||
{
|
||||
$container = include self::$fixturesPath.'//containers/container8.php';
|
||||
$dumper = new XmlDumper($container);
|
||||
$this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/xml/services8.xml', $dumper->dump(), '->dump() dumps parameters');
|
||||
}
|
||||
|
||||
public function testAddParameters()
|
||||
{
|
||||
$container = include self::$fixturesPath.'//containers/container8.php';
|
||||
$dumper = new XmlDumper($container);
|
||||
$this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/xml/services8.xml', $dumper->dump(), '->dump() dumps parameters');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyAddService()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/legacy-container9.php';
|
||||
$dumper = new XmlDumper($container);
|
||||
|
||||
$this->assertEquals(str_replace('%path%', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR, file_get_contents(self::$fixturesPath.'/xml/legacy-services9.xml')), $dumper->dump(), '->dump() dumps services');
|
||||
|
||||
$dumper = new XmlDumper($container = new ContainerBuilder());
|
||||
$container->register('foo', 'FooClass')->addArgument(new \stdClass());
|
||||
try {
|
||||
$dumper->dump();
|
||||
$this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\RuntimeException', $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
$this->assertEquals('Unable to dump a service container if a parameter is an object or a resource.', $e->getMessage(), '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
}
|
||||
}
|
||||
|
||||
public function testAddService()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/container9.php';
|
||||
$dumper = new XmlDumper($container);
|
||||
|
||||
$this->assertEquals(str_replace('%path%', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR, file_get_contents(self::$fixturesPath.'/xml/services9.xml')), $dumper->dump(), '->dump() dumps services');
|
||||
|
||||
$dumper = new XmlDumper($container = new ContainerBuilder());
|
||||
$container->register('foo', 'FooClass')->addArgument(new \stdClass());
|
||||
try {
|
||||
$dumper->dump();
|
||||
$this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\RuntimeException', $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
$this->assertEquals('Unable to dump a service container if a parameter is an object or a resource.', $e->getMessage(), '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
}
|
||||
}
|
||||
|
||||
public function testDumpAnonymousServices()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/container11.php';
|
||||
$dumper = new XmlDumper($container);
|
||||
$this->assertEquals('<?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>
|
||||
<service id="foo" class="FooClass">
|
||||
<argument type="service">
|
||||
<service class="BarClass">
|
||||
<argument type="service">
|
||||
<service class="BazClass"/>
|
||||
</argument>
|
||||
</service>
|
||||
</argument>
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
||||
', $dumper->dump());
|
||||
}
|
||||
|
||||
public function testDumpEntities()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/container12.php';
|
||||
$dumper = new XmlDumper($container);
|
||||
$this->assertEquals("<?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>
|
||||
<service id=\"foo\" class=\"FooClass\Foo\">
|
||||
<tag name=\"foo"bar\bar\" foo=\"foo"barřž€\"/>
|
||||
<argument>foo<>&bar</argument>
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
||||
", $dumper->dump());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideDecoratedServicesData
|
||||
*/
|
||||
public function testDumpDecoratedServices($expectedXmlDump, $container)
|
||||
{
|
||||
$dumper = new XmlDumper($container);
|
||||
$this->assertEquals($expectedXmlDump, $dumper->dump());
|
||||
}
|
||||
|
||||
public function provideDecoratedServicesData()
|
||||
{
|
||||
$fixturesPath = realpath(__DIR__.'/../Fixtures/');
|
||||
|
||||
return array(
|
||||
array("<?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>
|
||||
<service id=\"foo\" class=\"FooClass\Foo\" decorates=\"bar\" decoration-inner-name=\"bar.woozy\"/>
|
||||
</services>
|
||||
</container>
|
||||
", include $fixturesPath.'/containers/container15.php'),
|
||||
array("<?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>
|
||||
<service id=\"foo\" class=\"FooClass\Foo\" decorates=\"bar\"/>
|
||||
</services>
|
||||
</container>
|
||||
", include $fixturesPath.'/containers/container16.php'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideCompiledContainerData
|
||||
*/
|
||||
public function testCompiledContainerCanBeDumped($containerFile)
|
||||
{
|
||||
$fixturesPath = __DIR__.'/../Fixtures';
|
||||
$container = require $fixturesPath.'/containers/'.$containerFile.'.php';
|
||||
$container->compile();
|
||||
$dumper = new XmlDumper($container);
|
||||
$dumper->dump();
|
||||
}
|
||||
|
||||
public function provideCompiledContainerData()
|
||||
{
|
||||
return array(
|
||||
array('container8'),
|
||||
array('container9'),
|
||||
array('container11'),
|
||||
array('container12'),
|
||||
array('container14'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testDumpInlinedServices()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/container21.php';
|
||||
$dumper = new XmlDumper($container);
|
||||
|
||||
$this->assertEquals(file_get_contents(self::$fixturesPath.'/xml/services21.xml'), $dumper->dump());
|
||||
}
|
||||
}
|
80
vendor/symfony/dependency-injection/Tests/Dumper/YamlDumperTest.php
vendored
Normal file
80
vendor/symfony/dependency-injection/Tests/Dumper/YamlDumperTest.php
vendored
Normal file
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Dumper;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Dumper\YamlDumper;
|
||||
|
||||
class YamlDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $fixturesPath;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
self::$fixturesPath = realpath(__DIR__.'/../Fixtures/');
|
||||
}
|
||||
|
||||
public function testDump()
|
||||
{
|
||||
$dumper = new YamlDumper($container = new ContainerBuilder());
|
||||
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services1.yml', $dumper->dump(), '->dump() dumps an empty container as an empty YAML file');
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$dumper = new YamlDumper($container);
|
||||
}
|
||||
|
||||
public function testAddParameters()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/container8.php';
|
||||
$dumper = new YamlDumper($container);
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services8.yml', $dumper->dump(), '->dump() dumps parameters');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyAddService()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/legacy-container9.php';
|
||||
$dumper = new YamlDumper($container);
|
||||
|
||||
$this->assertEquals(str_replace('%path%', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR, file_get_contents(self::$fixturesPath.'/yaml/legacy-services9.yml')), $dumper->dump(), '->dump() dumps services');
|
||||
|
||||
$dumper = new YamlDumper($container = new ContainerBuilder());
|
||||
$container->register('foo', 'FooClass')->addArgument(new \stdClass());
|
||||
try {
|
||||
$dumper->dump();
|
||||
$this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\RuntimeException', $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
$this->assertEquals('Unable to dump a service container if a parameter is an object or a resource.', $e->getMessage(), '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
}
|
||||
}
|
||||
|
||||
public function testAddService()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/container9.php';
|
||||
$dumper = new YamlDumper($container);
|
||||
$this->assertEquals(str_replace('%path%', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR, file_get_contents(self::$fixturesPath.'/yaml/services9.yml')), $dumper->dump(), '->dump() dumps services');
|
||||
|
||||
$dumper = new YamlDumper($container = new ContainerBuilder());
|
||||
$container->register('foo', 'FooClass')->addArgument(new \stdClass());
|
||||
try {
|
||||
$dumper->dump();
|
||||
$this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('\RuntimeException', $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
$this->assertEquals('Unable to dump a service container if a parameter is an object or a resource.', $e->getMessage(), '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
|
||||
}
|
||||
}
|
||||
}
|
Reference in a new issue