function ContextualUnitTest::contextualLinksDataProvider

Same name in other branches
  1. 10 core/modules/contextual/tests/src/Kernel/ContextualUnitTest.php \Drupal\Tests\contextual\Kernel\ContextualUnitTest::contextualLinksDataProvider()
  2. 11.x core/modules/contextual/tests/src/Kernel/ContextualUnitTest.php \Drupal\Tests\contextual\Kernel\ContextualUnitTest::contextualLinksDataProvider()

Provides testcases for both test functions.

Used in testContextualLinksToId() and testContextualIdToLinks().

Return value

array[] Test cases.

File

core/modules/contextual/tests/src/Kernel/ContextualUnitTest.php, line 29

Class

ContextualUnitTest
Tests edge cases for converting between contextual links and IDs.

Namespace

Drupal\Tests\contextual\Kernel

Code

public function contextualLinksDataProvider() : array {
    $tests['one group, one dynamic path argument, no metadata'] = [
        [
            'node' => [
                'route_parameters' => [
                    'node' => '14031991',
                ],
                'metadata' => [
                    'langcode' => 'en',
                ],
            ],
        ],
        'node:node=14031991:langcode=en',
    ];
    $tests['one group, multiple dynamic path arguments, no metadata'] = [
        [
            'foo' => [
                'route_parameters' => [
                    0 => 'bar',
                    'key' => 'baz',
                    1 => 'qux',
                ],
                'metadata' => [
                    'langcode' => 'en',
                ],
            ],
        ],
        'foo:0=bar&key=baz&1=qux:langcode=en',
    ];
    $tests['one group, one dynamic path argument, metadata'] = [
        [
            'views_ui_edit' => [
                'route_parameters' => [
                    'view' => 'frontpage',
                ],
                'metadata' => [
                    'location' => 'page',
                    'display' => 'page_1',
                    'langcode' => 'en',
                ],
            ],
        ],
        'views_ui_edit:view=frontpage:location=page&display=page_1&langcode=en',
    ];
    $tests['multiple groups, multiple dynamic path arguments'] = [
        [
            'node' => [
                'route_parameters' => [
                    'node' => '14031991',
                ],
                'metadata' => [
                    'langcode' => 'en',
                ],
            ],
            'foo' => [
                'route_parameters' => [
                    0 => 'bar',
                    'key' => 'baz',
                    1 => 'qux',
                ],
                'metadata' => [
                    'langcode' => 'en',
                ],
            ],
            'edge' => [
                'route_parameters' => [
                    '20011988',
                ],
                'metadata' => [
                    'langcode' => 'en',
                ],
            ],
        ],
        'node:node=14031991:langcode=en|foo:0=bar&key=baz&1=qux:langcode=en|edge:0=20011988:langcode=en',
    ];
    return $tests;
}

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