You are here

public function PathMatcherTest::getMatchPathData in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Path/PathMatcherTest.php \Drupal\Tests\Core\Path\PathMatcherTest::getMatchPathData()
  2. 9 core/tests/Drupal/Tests/Core/Path/PathMatcherTest.php \Drupal\Tests\Core\Path\PathMatcherTest::getMatchPathData()

Provides test path data.

Return value

array A nested array of pattern arrays and path arrays.

File

core/tests/Drupal/Tests/Core/Path/PathMatcherTest.php, line 56

Class

PathMatcherTest
@coversDefaultClass \Drupal\Core\Path\PathMatcher @group Path

Namespace

Drupal\Tests\Core\Path

Code

public function getMatchPathData() {
  return [
    [
      // Single absolute paths.
      '/example/1',
      [
        '/example/1' => TRUE,
        '/example/2' => FALSE,
        '/test' => FALSE,
      ],
    ],
    [
      // Single paths with wildcards.
      '/example/*',
      [
        '/example/1' => TRUE,
        '/example/2' => TRUE,
        '/example/3/edit' => TRUE,
        '/example/' => TRUE,
        '/example' => FALSE,
        '/test' => FALSE,
      ],
    ],
    [
      // Single paths with multiple wildcards.
      '/node/*/revisions/*',
      [
        '/node/1/revisions/3' => TRUE,
        '/node/345/revisions/test' => TRUE,
        '/node/23/edit' => FALSE,
        '/test' => FALSE,
      ],
    ],
    [
      // Single paths with '<front>'.
      "<front>",
      [
        '/dummy' => TRUE,
        "/dummy/" => FALSE,
        "/dummy/edit" => FALSE,
        '/node' => FALSE,
        '' => FALSE,
      ],
    ],
    [
      // Paths with both '<front>' and wildcards (should not work).
      "<front>/*",
      [
        '/dummy' => FALSE,
        '/dummy/' => FALSE,
        '/dummy/edit' => FALSE,
        '/node/12' => FALSE,
        '/' => FALSE,
      ],
    ],
    [
      // Multiple paths with the \n delimiter.
      "/node/*\n/node/*/edit",
      [
        '/node/1' => TRUE,
        '/node/view' => TRUE,
        '/node/32/edit' => TRUE,
        '/node/delete/edit' => TRUE,
        '/node/50/delete' => TRUE,
        '/test/example' => FALSE,
      ],
    ],
    [
      // Multiple paths with the \r delimiter.
      "/user/*\r/example/*",
      [
        '/user/1' => TRUE,
        '/example/1' => TRUE,
        '/user/1/example/1' => TRUE,
        '/user/example' => TRUE,
        '/test/example' => FALSE,
        '/user' => FALSE,
        '/example' => FALSE,
      ],
    ],
    [
      // Multiple paths with the \r\n delimiter.
      "/test\r\n<front>",
      [
        '/test' => TRUE,
        '/dummy' => TRUE,
        '/example' => FALSE,
      ],
    ],
    [
      // Test existing regular expressions (should be escaped).
      '[^/]+?/[0-9]',
      [
        '/test/1' => FALSE,
        '[^/]+?/[0-9]' => TRUE,
      ],
    ],
  ];
}