function RouteMatchTestBase::routeMatchProvider

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php \Drupal\Tests\Core\Routing\RouteMatchTestBase::routeMatchProvider()
  2. 10 core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php \Drupal\Tests\Core\Routing\RouteMatchTestBase::routeMatchProvider()
  3. 11.x core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php \Drupal\Tests\Core\Routing\RouteMatchTestBase::routeMatchProvider()

Provide sets of parameters and expected parameters for parameter tests.

File

core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php, line 33

Class

RouteMatchTestBase
Base test class for testing classes implementing the route match interface.

Namespace

Drupal\Tests\Core\Routing

Code

public function routeMatchProvider() {
    $base_data = [
        [
            new Route('/test-route/{param_without_leading_underscore}/{_param_with_leading_underscore}', [
                'default_without_leading_underscore' => NULL,
                '_default_with_leading_underscore' => NULL,
            ]),
            [
                'param_without_leading_underscore' => 'value',
                '_param_with_leading_underscore' => 'value',
                'default_without_leading_underscore' => 'value',
                '_default_with_leading_underscore' => 'value',
                'foo' => 'value',
            ],
            // Parameters should be filtered to only those defined by the route.
            // Specifically:
            // - Path parameters, regardless of name.
            // - Defaults that are not path parameters only if they do not start with
            //   an underscore.
[
                'param_without_leading_underscore' => 'value',
                '_param_with_leading_underscore' => 'value',
                'default_without_leading_underscore' => 'value',
            ],
        ],
    ];
    $data = [];
    foreach ($base_data as $entry) {
        $route = $entry[0];
        $params = $entry[1];
        $expected_params = $entry[2];
        $data[] = [
            $this->getRouteMatch('test_route', $route, $params, $params),
            $route,
            $params,
            $expected_params,
        ];
    }
    return $data;
}

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