You are here

public function FieldPluginBaseTest::testGetRenderTokensWithArguments in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest::testGetRenderTokensWithArguments()
  2. 10 core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest::testGetRenderTokensWithArguments()

@covers ::getRenderTokens

File

core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php, line 701
Contains \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest.

Class

FieldPluginBaseTest
@coversDefaultClass \Drupal\views\Plugin\views\field\FieldPluginBase @group views

Namespace

Drupal\Tests\views\Unit\Plugin\field

Code

public function testGetRenderTokensWithArguments() {
  $field = $this
    ->setupTestField([
    'id' => 'id',
  ]);
  $field->view->args = [
    'argument value',
  ];
  $field->view->build_info['substitutions']['{{ arguments.name }}'] = 'argument value';
  $argument = $this
    ->getMockBuilder('\\Drupal\\views\\Plugin\\views\\argument\\ArgumentPluginBase')
    ->disableOriginalConstructor()
    ->getMock();
  $field->last_render = 'last rendered output';
  $this->display
    ->expects($this
    ->any())
    ->method('getHandlers')
    ->willReturnMap([
    [
      'argument',
      [
        'name' => $argument,
      ],
    ],
    [
      'field',
      [
        'id' => $field,
      ],
    ],
  ]);
  $expected = [
    '{{ id }}' => 'last rendered output',
    '{{ arguments.name }}' => 'argument value',
    '{{ raw_arguments.name }}' => 'argument value',
  ];
  $this
    ->assertEquals($expected, $field
    ->getRenderTokens([]));
}