You are here

public function TaggedHandlersPassTest::testProcessWithDifferentArgumentsOrderAndDefaultValue in Drupal 8

Same name and namespace in other branches
  1. 9 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()

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
Contains \Drupal\Tests\Core\DependencyInjection\Compiler\TaggedHandlersPassTest.

Class

TaggedHandlersPassTest
@coversDefaultClass \Drupal\Core\DependencyInjection\Compiler\TaggedHandlersPass @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]));
}