You are here

public function TaggedHandlersPassTest::testProcessInterfaceMismatch 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::testProcessInterfaceMismatch()

Tests interface validation in non-production environment.

@covers ::process

File

core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php, line 292
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 testProcessInterfaceMismatch() {
  $container = $this
    ->buildContainer();
  $container
    ->register('consumer_id', __NAMESPACE__ . '\\ValidConsumer')
    ->addTag('service_collector');
  $container
    ->register('handler1', __NAMESPACE__ . '\\InvalidHandler')
    ->addTag('consumer_id');
  $container
    ->register('handler2', __NAMESPACE__ . '\\ValidHandler')
    ->addTag('consumer_id', [
    'priority' => 10,
  ]);
  $handler_pass = new TaggedHandlersPass();
  $this
    ->expectException(LogicException::class);
  $handler_pass
    ->process($container);
}