You are here

public function TourTest::routeProvider in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/tour/tests/src/Unit/Entity/TourTest.php \Drupal\Tests\tour\Unit\Entity\TourTest::routeProvider()
  2. 9 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,
    ],
  ];
}