function TaggedHandlersPassTest::testProcessMissingInterface

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

Tests consumer with missing interface in non-production environment.

@covers ::process

File

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

Class

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

Namespace

Drupal\Tests\Core\DependencyInjection\Compiler

Code

public function testProcessMissingInterface() : void {
  $container = $this->buildContainer();
  $container->register('consumer_id0', __NAMESPACE__ . '\\ValidConsumer')
    ->addTag('service_collector');
  $container->register('consumer_id1', __NAMESPACE__ . '\\InvalidConsumer')
    ->addTag('service_collector');
  $handler_pass = new TaggedHandlersPass();
  $this->expectException(LogicException::class);
  $this->expectExceptionMessage("Service consumer 'consumer_id1' class method Drupal\\Tests\\Core\\DependencyInjection\\Compiler\\InvalidConsumer::addHandler() has to type-hint an interface.");
  $handler_pass->process($container);
}

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