function RouteTest::providerTestRoute

Same name in other branches
  1. 9 core/modules/migrate/tests/src/Kernel/process/RouteTest.php \Drupal\Tests\migrate\Kernel\process\RouteTest::providerTestRoute()
  2. 8.9.x core/modules/migrate/tests/src/Kernel/process/RouteTest.php \Drupal\Tests\migrate\Kernel\process\RouteTest::providerTestRoute()
  3. 11.x core/modules/migrate/tests/src/Kernel/process/RouteTest.php \Drupal\Tests\migrate\Kernel\process\RouteTest::providerTestRoute()

Data provider for testRoute().

Return value

array An array of arrays, where the first element is the input to the Route process plugin, and the second is the expected results.

File

core/modules/migrate/tests/src/Kernel/process/RouteTest.php, line 54

Class

RouteTest
Tests the route process plugin.

Namespace

Drupal\Tests\migrate\Kernel\process

Code

public static function providerTestRoute() {
    // Internal link tests.
    // Valid link path and options.
    $values[0] = [
        'user/login',
        [
            'attributes' => [
                'title' => 'Test menu link 1',
            ],
        ],
    ];
    $expected[0] = [
        'route_name' => 'user.login',
        'route_parameters' => [],
        'options' => [
            'query' => [],
            'attributes' => [
                'title' => 'Test menu link 1',
            ],
        ],
        'url' => NULL,
    ];
    // Valid link path and empty options.
    $values[1] = [
        'user/login',
        [],
    ];
    $expected[1] = [
        'route_name' => 'user.login',
        'route_parameters' => [],
        'options' => [
            'query' => [],
        ],
        'url' => NULL,
    ];
    // Valid link path and no options.
    $values[2] = 'user/login';
    $expected[2] = [
        'route_name' => 'user.login',
        'route_parameters' => [],
        'options' => [
            'query' => [],
        ],
        'url' => NULL,
    ];
    // Invalid link path.
    $values[3] = 'users';
    $expected[3] = [];
    // Valid link path with parameter.
    $values[4] = [
        'system/timezone/nzdt',
        [
            'attributes' => [
                'title' => 'Show NZDT',
            ],
        ],
    ];
    $expected[4] = [
        'route_name' => 'system.timezone',
        'route_parameters' => [
            'abbreviation' => 'nzdt',
            'offset' => -1,
            'is_daylight_saving_time' => NULL,
        ],
        'options' => [
            'query' => [],
            'attributes' => [
                'title' => 'Show NZDT',
            ],
        ],
        'url' => NULL,
    ];
    // External link tests.
    // Valid external link path and options.
    $values[5] = [
        'https://www.drupal.org',
        [
            'attributes' => [
                'title' => 'Drupal',
            ],
        ],
    ];
    $expected[5] = [
        'route_name' => NULL,
        'route_parameters' => [],
        'options' => [
            'attributes' => [
                'title' => 'Drupal',
            ],
        ],
        'url' => 'https://www.drupal.org',
    ];
    // Valid external link path and options.
    $values[6] = [
        'https://www.drupal.org/user/1/edit?pass-reset-token=QgtDKcRV4e4fjg6v2HTa6CbWx-XzMZ5XBZTufinqsM73qIhscIuU_BjZ6J2tv4dQI6N50ZJOag',
        [
            'attributes' => [
                'title' => 'Drupal password reset',
            ],
        ],
    ];
    $expected[6] = [
        'route_name' => NULL,
        'route_parameters' => [],
        'options' => [
            'attributes' => [
                'title' => 'Drupal password reset',
            ],
        ],
        'url' => 'https://www.drupal.org/user/1/edit?pass-reset-token=QgtDKcRV4e4fjg6v2HTa6CbWx-XzMZ5XBZTufinqsM73qIhscIuU_BjZ6J2tv4dQI6N50ZJOag',
    ];
    return [
        // Test data for internal paths.
        // Test with valid link path and options.
[
            $values[0],
            $expected[0],
        ],
        // Test with valid link path and empty options.
[
            $values[1],
            $expected[1],
        ],
        // Test with valid link path and no options.
[
            $values[2],
            $expected[2],
        ],
        // Test with Invalid link path.
[
            $values[3],
            $expected[3],
        ],
        // Test with Valid link path with query options and parameters.
[
            $values[4],
            $expected[4],
        ],
        // Test data for external paths.
        // Test with external link path and options.
[
            $values[5],
            $expected[5],
        ],
        // Test with valid link path and query options.
[
            $values[6],
            $expected[6],
        ],
    ];
}

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