You are here

public function RouterTest::testRouterMatching in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Routing/RouterTest.php \Drupal\Tests\system\Functional\Routing\RouterTest::testRouterMatching()
  2. 9 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 244

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
    ->assertSession()
    ->pageTextContains('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
    ->assertSession()
    ->pageTextContains('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);
  }
}