function TaggedHandlersPassTest::testProcessPriority
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php \Drupal\Tests\Core\DependencyInjection\Compiler\TaggedHandlersPassTest::testProcessPriority()
- 8.9.x core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php \Drupal\Tests\Core\DependencyInjection\Compiler\TaggedHandlersPassTest::testProcessPriority()
- 10 core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/TaggedHandlersPassTest.php \Drupal\Tests\Core\DependencyInjection\Compiler\TaggedHandlersPassTest::testProcessPriority()
Tests handler priority sorting.
@covers ::process
File
-
core/
tests/ Drupal/ Tests/ Core/ DependencyInjection/ Compiler/ TaggedHandlersPassTest.php, line 157
Class
- TaggedHandlersPassTest
- @coversDefaultClass \Drupal\Core\DependencyInjection\Compiler\TaggedHandlersPass @group DependencyInjection
Namespace
Drupal\Tests\Core\DependencyInjection\CompilerCode
public function testProcessPriority() : void {
$container = $this->buildContainer();
$container->register('consumer_id', __NAMESPACE__ . '\\ValidConsumer')
->addTag('service_collector');
$container->register('handler1', __NAMESPACE__ . '\\ValidHandler')
->addTag('consumer_id');
$container->register('handler2', __NAMESPACE__ . '\\ValidHandler')
->addTag('consumer_id', [
'priority' => 10,
]);
$handler_pass = new TaggedHandlersPass();
$handler_pass->process($container);
$method_calls = $container->getDefinition('consumer_id')
->getMethodCalls();
$this->assertCount(2, $method_calls);
$this->assertEquals(new Reference('handler2'), $method_calls[0][1][0]);
$this->assertEquals(10, $method_calls[0][1][1]);
$this->assertEquals(new Reference('handler1'), $method_calls[1][1][0]);
$this->assertEquals(0, $method_calls[1][1][1]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.