You are here

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

Tests consumer method with extra parameters and no priority.

@covers ::process

File

core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php, line 347
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 testProcessNoPriorityAndExtraArguments() {
  $container = $this
    ->buildContainer();
  $container
    ->register('consumer_id', __NAMESPACE__ . '\\ValidConsumerWithExtraArguments')
    ->addTag('service_collector', [
    'call' => 'addNoPriority',
  ]);
  $container
    ->register('handler1', __NAMESPACE__ . '\\ValidHandler')
    ->addTag('consumer_id', [
    'extra' => 'extra',
  ]);
  $handler_pass = new TaggedHandlersPass();
  $handler_pass
    ->process($container);
  $method_calls = $container
    ->getDefinition('consumer_id')
    ->getMethodCalls();
  $this
    ->assertCount(2, $method_calls[0][1]);
  $this
    ->assertEquals(new Reference('handler1'), $method_calls[0][1][0]);
  $this
    ->assertEquals('extra', $method_calls[0][1][1]);
}