You are here

public function RouteProviderTest::testCandidateOutlines in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Routing/RouteProviderTest.php \Drupal\system\Tests\Routing\RouteProviderTest::testCandidateOutlines()

Confirms that the correct candidate outlines are generated.

File

core/modules/system/src/Tests/Routing/RouteProviderTest.php, line 115
Contains \Drupal\system\Tests\Routing\RouteProviderTest.

Class

RouteProviderTest
Confirm that the default route provider is working correctly.

Namespace

Drupal\system\Tests\Routing

Code

public function testCandidateOutlines() {
  $connection = Database::getConnection();
  $provider = new TestRouteProvider($connection, $this->state, $this->currentPath, $this->cache, $this->pathProcessor, $this->cacheTagsInvalidator, 'test_routes');
  $parts = array(
    'node',
    '5',
    'edit',
  );
  $candidates = $provider
    ->getCandidateOutlines($parts);
  $candidates = array_flip($candidates);
  $this
    ->assertTrue(count($candidates) == 7, '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.');
  $this
    ->assertTrue(array_key_exists('/node/5', $candidates), 'Fifth candidate found.');
  $this
    ->assertTrue(array_key_exists('/node/%', $candidates), 'Sixth candidate found.');
  $this
    ->assertTrue(array_key_exists('/node', $candidates), 'Seventh candidate found.');
}