function TaggedHandlersPassTest::testProcess

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php \Drupal\Tests\Core\DependencyInjection\Compiler\TaggedHandlersPassTest::testProcess()
  2. 10 core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php \Drupal\Tests\Core\DependencyInjection\Compiler\TaggedHandlersPassTest::testProcess()
  3. 11.x core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php \Drupal\Tests\Core\DependencyInjection\Compiler\TaggedHandlersPassTest::testProcess()

Tests one consumer and two handlers.

@covers ::process

File

core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php, line 109

Class

TaggedHandlersPassTest
@coversDefaultClass \Drupal\Core\DependencyInjection\Compiler\TaggedHandlersPass @group DependencyInjection

Namespace

Drupal\Tests\Core\DependencyInjection\Compiler

Code

public function testProcess() {
    $container = $this->buildContainer();
    $container->register('consumer_id', __NAMESPACE__ . '\\ValidConsumer')
        ->addTag('service_collector');
    $container->register('handler1', __NAMESPACE__ . '\\ValidHandler')
        ->addTag('consumer_id');
    $container->register('handler2', __NAMESPACE__ . '\\ValidHandler')
        ->addTag('consumer_id');
    $handler_pass = new TaggedHandlersPass();
    $handler_pass->process($container);
    $method_calls = $container->getDefinition('consumer_id')
        ->getMethodCalls();
    $this->assertCount(2, $method_calls);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.