public function TaggedHandlersPassTest::testProcessWithExtraArguments in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php \Drupal\Tests\Core\DependencyInjection\Compiler\TaggedHandlersPassTest::testProcessWithExtraArguments()
Tests consumer method with extra parameters.
@covers ::process
File
- core/
tests/ Drupal/ Tests/ Core/ DependencyInjection/ Compiler/ TaggedHandlersPassTest.php, line 317 - Contains \Drupal\Tests\Core\DependencyInjection\Compiler\TaggedHandlersPassTest.
Class
- TaggedHandlersPassTest
- @coversDefaultClass \Drupal\Core\DependencyInjection\Compiler\TaggedHandlersPass @group DependencyInjection
Namespace
Drupal\Tests\Core\DependencyInjection\CompilerCode
public function testProcessWithExtraArguments() {
$container = $this
->buildContainer();
$container
->register('consumer_id', __NAMESPACE__ . '\\ValidConsumerWithExtraArguments')
->addTag('service_collector');
$container
->register('handler1', __NAMESPACE__ . '\\ValidHandler')
->addTag('consumer_id', [
'extra1' => 'extra1',
'extra2' => 'extra2',
]);
$handler_pass = new TaggedHandlersPass();
$handler_pass
->process($container);
$method_calls = $container
->getDefinition('consumer_id')
->getMethodCalls();
$this
->assertCount(4, $method_calls[0][1]);
$this
->assertEquals(new Reference('handler1'), $method_calls[0][1][0]);
$this
->assertEquals(0, $method_calls[0][1][1]);
$this
->assertEquals('extra1', $method_calls[0][1][2]);
$this
->assertEquals('extra2', $method_calls[0][1][3]);
}