function FieldPluginBaseTest::providerTestGetRenderTokensWithQuery

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

Data provider for ::testGetRenderTokensWithQuery().

Return value

array Test data.

File

core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php, line 742

Class

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

Namespace

Drupal\Tests\views\Unit\Plugin\field

Code

public static function providerTestGetRenderTokensWithQuery() : array {
    $data = [];
    // No query parameters.
    $data[] = [
        [],
        [
            '{{ id }}' => 'last rendered output',
        ],
    ];
    // Invalid query parameters.
    $data[] = [
        [
            '&invalid' => [
                'a' => 1,
                'b' => [
                    1,
                    2,
                ],
                1 => 2,
            ],
            'invalid.entry' => 'ignore me',
        ],
        [
            '{{ id }}' => 'last rendered output',
        ],
    ];
    // Process only valid query parameters.
    $data[] = [
        [
            'foo' => [
                'a' => 'value',
                'b' => 'value',
                'c.d' => 'invalid argument',
                '&invalid' => 'invalid argument',
            ],
            'bar' => [
                'a' => 'value',
                'b' => [
                    'c' => 'value',
                ],
            ],
        ],
        [
            '{{ id }}' => 'last rendered output',
            '{{ arguments.foo.a }}' => 'value',
            '{{ arguments.foo.b }}' => 'value',
            '{{ arguments.bar.a }}' => 'value',
            '{{ arguments.bar.b.c }}' => 'value',
        ],
    ];
    // Supports numeric keys.
    $data[] = [
        [
            'multiple' => [
                1,
                2,
                3,
            ],
            1 => '',
            3 => '& encoded_value',
        ],
        [
            '{{ id }}' => 'last rendered output',
            '{{ arguments.multiple.0 }}' => '1',
            '{{ arguments.multiple.1 }}' => '2',
            '{{ arguments.multiple.2 }}' => '3',
            '{{ arguments.1 }}' => '',
            '{{ arguments.3 }}' => '& encoded_value',
        ],
    ];
    return $data;
}

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