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