function RouterTest::testRouterMatching

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Routing/RouterTest.php \Drupal\Tests\system\Functional\Routing\RouterTest::testRouterMatching()
  2. 10 core/modules/system/tests/src/Functional/Routing/RouterTest.php \Drupal\Tests\system\Functional\Routing\RouterTest::testRouterMatching()
  3. 11.x core/modules/system/tests/src/Functional/Routing/RouterTest.php \Drupal\Tests\system\Functional\Routing\RouterTest::testRouterMatching()

Tests that a page trying to match a path will succeed.

File

core/modules/system/tests/src/Functional/Routing/RouterTest.php, line 237

Class

RouterTest
Functional class for the full integrated routing system.

Namespace

Drupal\Tests\system\Functional\Routing

Code

public function testRouterMatching() {
    $this->drupalGet('router_test/test14/1');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertText('User route "entity.user.canonical" was matched.');
    // Try to match a route for a non-existent user.
    $this->drupalGet('router_test/test14/2');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertText('Route not matched.');
    // Check that very long paths don't cause an error.
    $path = 'router_test/test1';
    $suffix = '/d/r/u/p/a/l';
    for ($i = 0; $i < 10; $i++) {
        $path .= $suffix;
        $this->drupalGet($path);
        $this->assertSession()
            ->statusCodeEquals(404);
    }
}

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