public function PathEncodedTest::testAliasToEncoded in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/FunctionalTests/Routing/PathEncodedTest.php \Drupal\FunctionalTests\Routing\PathEncodedTest::testAliasToEncoded()
- 10 core/tests/Drupal/FunctionalTests/Routing/PathEncodedTest.php \Drupal\FunctionalTests\Routing\PathEncodedTest::testAliasToEncoded()
File
- core/
tests/ Drupal/ FunctionalTests/ Routing/ PathEncodedTest.php, line 41
Class
- PathEncodedTest
- Tests url generation and routing for route paths with encoded characters.
Namespace
Drupal\FunctionalTests\RoutingCode
public function testAliasToEncoded() {
$route_paths = [
'path_encoded_test.colon' => '/hi/llamma:party',
'path_encoded_test.atsign' => '/bloggy/@Dries',
'path_encoded_test.parens' => '/cat(box)',
];
$aliases = [];
foreach ($route_paths as $route_name => $path) {
$aliases[$route_name] = $this
->randomMachineName();
$this
->createPathAlias($path, '/' . $aliases[$route_name]);
}
foreach ($route_paths as $route_name => $path) {
// The alias may be only a suffix of the generated path when the test is
// run with Drupal installed in a subdirectory.
$this
->assertRegExp('@/' . rawurlencode($aliases[$route_name]) . '$@', Url::fromRoute($route_name)
->toString());
$this
->drupalGet(Url::fromRoute($route_name));
$this
->assertSession()
->pageTextContains('PathEncodedTestController works');
}
}