function TaggedHandlersPassTest::testProcessWithIdAndExtraArguments

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

Tests consumer method with priority, id and extra parameters.

@covers ::process

File

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

Class

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

Namespace

Drupal\Tests\Core\DependencyInjection\Compiler

Code

public function testProcessWithIdAndExtraArguments() : void {
  $container = $this->buildContainer();
  $container->register('consumer_id', __NAMESPACE__ . '\\ValidConsumerWithExtraArguments')
    ->addTag('service_collector', [
    'call' => 'addWithId',
  ]);
  $container->register('handler1', __NAMESPACE__ . '\\ValidHandler')
    ->addTag('consumer_id', [
    'extra1' => 'extra1',
  ]);
  $handler_pass = new TaggedHandlersPass();
  $handler_pass->process($container);
  $method_calls = $container->getDefinition('consumer_id')
    ->getMethodCalls();
  $this->assertCount(5, $method_calls[0][1]);
  $this->assertEquals(new Reference('handler1'), $method_calls[0][1][0]);
  $this->assertEquals('handler1', $method_calls[0][1][1]);
  $this->assertEquals(0, $method_calls[0][1][2]);
  $this->assertEquals('extra1', $method_calls[0][1][3]);
  $this->assertNull($method_calls[0][1][4]);
}

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