function TaggedHandlersPassTest::testProcessWithDifferentArgumentsOrderAndDefaultValue

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

Tests consumer method with priority and extra parameters in different order.

@covers ::process

File

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

Class

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

Namespace

Drupal\Tests\Core\DependencyInjection\Compiler

Code

public function testProcessWithDifferentArgumentsOrderAndDefaultValue() {
  $container = $this->buildContainer();
  $container->register('consumer_id', __NAMESPACE__ . '\\ValidConsumerWithExtraArguments')
    ->addTag('service_collector', [
    'call' => 'addWithDifferentOrder',
  ]);
  $container->register('handler1', __NAMESPACE__ . '\\ValidHandler')
    ->addTag('consumer_id', [
    'priority' => 0,
    'extra1' => 'extra1',
    'extra3' => 'extra3',
  ]);
  $handler_pass = new TaggedHandlersPass();
  $handler_pass->process($container);
  $method_calls = $container->getDefinition('consumer_id')
    ->getMethodCalls();
  $this->assertCount(5, $method_calls[0][1]);
  $expected = [
    new Reference('handler1'),
    'extra1',
    0,
    'default2',
    'extra3',
  ];
  $this->assertEquals($expected, array_values($method_calls[0][1]));
}

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