function TaggedHandlersPassTest::testProcessRequiredHandlers

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

Tests a required consumer with no handlers.

@covers ::process

File

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

Class

TaggedHandlersPassTest
@coversDefaultClass \Drupal\Core\DependencyInjection\Compiler\TaggedHandlersPass[[api-linebreak]] @group DependencyInjection

Namespace

Drupal\Tests\Core\DependencyInjection\Compiler

Code

public function testProcessRequiredHandlers() : void {
  $container = $this->buildContainer();
  $container->register('consumer_id', __NAMESPACE__ . '\\ValidConsumer')
    ->addTag('service_collector', [
    'required' => TRUE,
  ]);
  $handler_pass = new TaggedHandlersPass();
  $this->expectException(LogicException::class);
  $this->expectExceptionMessage("At least one service tagged with 'consumer_id' is required.");
  $handler_pass->process($container);
}

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