function RouterTest::testControllerPlaceholders

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

Confirms that placeholders in paths work correctly.

File

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

Class

RouterTest
Functional class for the full integrated routing system.

Namespace

Drupal\Tests\system\Functional\Routing

Code

public function testControllerPlaceholders() {
    // Test with 0 and a random value.
    $values = [
        "0",
        $this->randomMachineName(),
    ];
    foreach ($values as $value) {
        $this->drupalGet('router_test/test3/' . $value);
        $this->assertSession()
            ->statusCodeEquals(200);
        $this->assertRaw($value, 'The correct string was returned because the route was successful.');
    }
    // Confirm that the page wrapping is being added, so we're not getting a
    // raw body returned.
    $this->assertRaw('</html>', 'Page markup was found.');
    // In some instances, the subrequest handling may get confused and render
    // a page inception style.  This test verifies that is not happening.
    $this->assertSession()
        ->responseNotMatches('#</body>.*</body>#s', 'There was no double-page effect from a misrendered subrequest.');
}

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