function TaggedHandlersPassTest::testserviceIdProcess

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php \Drupal\Tests\Core\DependencyInjection\Compiler\TaggedHandlersPassTest::testserviceIdProcess()
  2. 10 core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php \Drupal\Tests\Core\DependencyInjection\Compiler\TaggedHandlersPassTest::testServiceIdProcess()
  3. 11.x core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php \Drupal\Tests\Core\DependencyInjection\Compiler\TaggedHandlersPassTest::testServiceIdProcess()

Tests one consumer and two handlers with service ID collection.

@covers ::process

File

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

Class

TaggedHandlersPassTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21DependencyInjection%21Compiler%21TaggedHandlersPass.php/class/TaggedHandlersPass/9" title="Collects services to add/inject them into a consumer service." class="local">\Drupal\Core\DependencyInjection\Compiler\TaggedHandlersPass</a> @group DependencyInjection

Namespace

Drupal\Tests\Core\DependencyInjection\Compiler

Code

public function testserviceIdProcess() {
    $container = $this->buildContainer();
    $container->register('consumer_id', __NAMESPACE__ . '\\ValidConsumer')
        ->addTag('service_id_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);
    $arguments = $container->getDefinition('consumer_id')
        ->getArguments();
    $this->assertCount(1, $arguments);
    $this->assertCount(2, $arguments[0]);
}

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