public function PathMatcherTest::testCandidateOutlines

Confirms that the correct candidate outlines are generated.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Routing/PathMatcherTest.php, line 57
Definition of Drupal\system\Tests\Routing\PartialMatcherTest.

Class

PathMatcherTest
Basic tests for the UrlMatcherDumper.

Namespace

Drupal\system\Tests\Routing

Code

public function testCandidateOutlines() {
  $connection = Database::getConnection();
  $matcher = new PathMatcher($connection);
  $parts = array(
    'node',
    '5',
    'edit',
  );
  $candidates = $matcher
    ->getCandidateOutlines($parts);
  $candidates = array_flip($candidates);
  $this
    ->assertTrue(count($candidates) == 4, 'Correct number of candidates found');
  $this
    ->assertTrue(array_key_exists('/node/5/edit', $candidates), 'First candidate found.');
  $this
    ->assertTrue(array_key_exists('/node/5/%', $candidates), 'Second candidate found.');
  $this
    ->assertTrue(array_key_exists('/node/%/edit', $candidates), 'Third candidate found.');
  $this
    ->assertTrue(array_key_exists('/node/%/%', $candidates), 'Fourth candidate found.');
}