You are here

class IntegrationTest in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/dependency-injection/Tests/Compiler/IntegrationTest.php \Symfony\Component\DependencyInjection\Tests\Compiler\IntegrationTest
  2. 8 core/modules/aggregator/src/Tests/Views/IntegrationTest.php \Drupal\aggregator\Tests\Views\IntegrationTest
  3. 8 core/modules/statistics/src/Tests/Views/IntegrationTest.php \Drupal\statistics\Tests\Views\IntegrationTest
Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/Tests/Compiler/IntegrationTest.php \Symfony\Component\DependencyInjection\Tests\Compiler\IntegrationTest

This class tests the integration of the different compiler passes.

Hierarchy

  • class \Symfony\Component\DependencyInjection\Tests\Compiler\IntegrationTest extends \Symfony\Component\DependencyInjection\Tests\Compiler\PHPUnit_Framework_TestCase

Expanded class hierarchy of IntegrationTest

File

vendor/symfony/dependency-injection/Tests/Compiler/IntegrationTest.php, line 21

Namespace

Symfony\Component\DependencyInjection\Tests\Compiler
View source
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.');
  }

}

Members