You are here

public function RouteProviderTest::testCandidateOutlines in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php \Drupal\KernelTests\Core\Routing\RouteProviderTest::testCandidateOutlines()
  2. 10 core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php \Drupal\KernelTests\Core\Routing\RouteProviderTest::testCandidateOutlines()

Confirms that the correct candidate outlines are generated.

File

core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php, line 123
Contains \Drupal\KernelTests\Core\Routing\RouteProviderTest.

Class

RouteProviderTest
Confirm that the default route provider is working correctly.

Namespace

Drupal\KernelTests\Core\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 = [
    'node',
    '5',
    'edit',
  ];
  $candidates = $provider
    ->getCandidateOutlines($parts);
  $candidates = array_flip($candidates);
  $this
    ->assertCount(7, $candidates, 'Correct number of candidates found');
  $this
    ->assertArrayHasKey('/node/5/edit', $candidates);
  $this
    ->assertArrayHasKey('/node/5/%', $candidates);
  $this
    ->assertArrayHasKey('/node/%/edit', $candidates);
  $this
    ->assertArrayHasKey('/node/%/%', $candidates);
  $this
    ->assertArrayHasKey('/node/5', $candidates);
  $this
    ->assertArrayHasKey('/node/%', $candidates);
  $this
    ->assertArrayHasKey('/node', $candidates);
}