function TourTest::routeProvider

Same name in other branches
  1. 9 core/modules/tour/tests/src/Unit/Entity/TourTest.php \Drupal\Tests\tour\Unit\Entity\TourTest::routeProvider()
  2. 10 core/modules/tour/tests/src/Unit/Entity/TourTest.php \Drupal\Tests\tour\Unit\Entity\TourTest::routeProvider()
  3. 11.x 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 47

Class

TourTest
@coversDefaultClass \Drupal\tour\Entity\Tour @group tour

Namespace

Drupal\Tests\tour\Unit\Entity

Code

public 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.