function TourTest::routeProvider

Same name and namespace in other branches
  1. 9 core/modules/tour/tests/src/Unit/Entity/TourTest.php \Drupal\Tests\tour\Unit\Entity\TourTest::routeProvider()
  2. 8.9.x core/modules/tour/tests/src/Unit/Entity/TourTest.php \Drupal\Tests\tour\Unit\Entity\TourTest::routeProvider()
  3. 10 core/modules/tour/tests/src/Unit/Entity/TourTest.php \Drupal\Tests\tour\Unit\Entity\TourTest::routeProvider()

Provides sample routes for testing.

File

core/modules/tour/tests/src/Unit/Entity/TourTest.php, line 51

Class

TourTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21tour%21src%21Entity%21Tour.php/class/Tour/11.x" title="Defines the configured tour entity." class="local">\Drupal\tour\Entity\Tour</a>

Namespace

Drupal\Tests\tour\Unit\Entity

Code

public static function routeProvider() {
    return [
        // Simple match.
[
            [
                [
                    'route_name' => 'some.route',
                ],
            ],
            'some.route',
            [],
            TRUE,
        ],
        // Simple non-match.
[
            [
                [
                    'route_name' => 'another.route',
                ],
            ],
            'some.route',
            [],
            FALSE,
        ],
        // Empty params.
[
            [
                [
                    'route_name' => 'some.route',
                    'route_params' => [
                        'foo' => 'bar',
                    ],
                ],
            ],
            'some.route',
            [],
            FALSE,
        ],
        // Match on params.
[
            [
                [
                    'route_name' => 'some.route',
                    'route_params' => [
                        'foo' => 'bar',
                    ],
                ],
            ],
            'some.route',
            [
                'foo' => 'bar',
            ],
            TRUE,
        ],
        // Non-matching params.
[
            [
                [
                    'route_name' => 'some.route',
                    'route_params' => [
                        'foo' => 'bar',
                    ],
                ],
            ],
            'some.route',
            [
                'bar' => 'foo',
            ],
            FALSE,
        ],
        // One matching, one not.
[
            [
                [
                    'route_name' => 'some.route',
                    'route_params' => [
                        'foo' => 'bar',
                    ],
                ],
                [
                    'route_name' => 'some.route',
                    'route_params' => [
                        'bar' => 'foo',
                    ],
                ],
            ],
            'some.route',
            [
                'bar' => 'foo',
            ],
            TRUE,
        ],
        // One matching, one not.
[
            [
                [
                    'route_name' => 'some.route',
                    'route_params' => [
                        'foo' => 'bar',
                    ],
                ],
                [
                    'route_name' => 'some.route',
                    'route_params' => [
                        'foo' => 'baz',
                    ],
                ],
            ],
            'some.route',
            [
                'foo' => 'baz',
            ],
            TRUE,
        ],
    ];
}

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