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
116
vendor/symfony/dependency-injection/Tests/Compiler/IntegrationTest.php
vendored
Normal file
116
vendor/symfony/dependency-injection/Tests/Compiler/IntegrationTest.php
vendored
Normal file
|
@ -0,0 +1,116 @@
|
|||
<?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\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Alias;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
/**
|
||||
* This class tests the integration of the different compiler passes.
|
||||
*/
|
||||
class IntegrationTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* This tests that dependencies are correctly processed.
|
||||
*
|
||||
* We're checking that:
|
||||
*
|
||||
* * A is public, B/C are private
|
||||
* * A -> C
|
||||
* * B -> C
|
||||
*/
|
||||
public function testProcessRemovesAndInlinesRecursively()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->setResourceTracking(false);
|
||||
|
||||
$a = $container
|
||||
->register('a', '\stdClass')
|
||||
->addArgument(new Reference('c'))
|
||||
;
|
||||
|
||||
$b = $container
|
||||
->register('b', '\stdClass')
|
||||
->addArgument(new Reference('c'))
|
||||
->setPublic(false)
|
||||
;
|
||||
|
||||
$c = $container
|
||||
->register('c', '\stdClass')
|
||||
->setPublic(false)
|
||||
;
|
||||
|
||||
$container->compile();
|
||||
|
||||
$this->assertTrue($container->hasDefinition('a'));
|
||||
$arguments = $a->getArguments();
|
||||
$this->assertSame($c, $arguments[0]);
|
||||
$this->assertFalse($container->hasDefinition('b'));
|
||||
$this->assertFalse($container->hasDefinition('c'));
|
||||
}
|
||||
|
||||
public function testProcessInlinesReferencesToAliases()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->setResourceTracking(false);
|
||||
|
||||
$a = $container
|
||||
->register('a', '\stdClass')
|
||||
->addArgument(new Reference('b'))
|
||||
;
|
||||
|
||||
$container->setAlias('b', new Alias('c', false));
|
||||
|
||||
$c = $container
|
||||
->register('c', '\stdClass')
|
||||
->setPublic(false)
|
||||
;
|
||||
|
||||
$container->compile();
|
||||
|
||||
$this->assertTrue($container->hasDefinition('a'));
|
||||
$arguments = $a->getArguments();
|
||||
$this->assertSame($c, $arguments[0]);
|
||||
$this->assertFalse($container->hasAlias('b'));
|
||||
$this->assertFalse($container->hasDefinition('c'));
|
||||
}
|
||||
|
||||
public function testProcessInlinesWhenThereAreMultipleReferencesButFromTheSameDefinition()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->setResourceTracking(false);
|
||||
|
||||
$container
|
||||
->register('a', '\stdClass')
|
||||
->addArgument(new Reference('b'))
|
||||
->addMethodCall('setC', array(new Reference('c')))
|
||||
;
|
||||
|
||||
$container
|
||||
->register('b', '\stdClass')
|
||||
->addArgument(new Reference('c'))
|
||||
->setPublic(false)
|
||||
;
|
||||
|
||||
$container
|
||||
->register('c', '\stdClass')
|
||||
->setPublic(false)
|
||||
;
|
||||
|
||||
$container->compile();
|
||||
|
||||
$this->assertTrue($container->hasDefinition('a'));
|
||||
$this->assertFalse($container->hasDefinition('b'));
|
||||
$this->assertFalse($container->hasDefinition('c'), 'Service C was not inlined.');
|
||||
}
|
||||
}
|
Reference in a new issue