function RouteProviderTest::testCandidateOutlines

Same name in other branches
  1. 8.9.x 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()
  3. 11.x 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 129

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.