You are here

public function TaggedHandlersPassTest::testProcessMissingInterface in Drupal 8

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()

Tests consumer with missing interface in non-production environment.

@covers ::process

File

core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php, line 89
Contains \Drupal\Tests\Core\DependencyInjection\Compiler\TaggedHandlersPassTest.

Class

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

Namespace

Drupal\Tests\Core\DependencyInjection\Compiler

Code

public function testProcessMissingInterface() {
  $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);
}