class PathEncodedTest
Same name in this branch
- main core/tests/Drupal/FunctionalTests/Routing/PathEncodedTest.php \Drupal\FunctionalTests\Routing\PathEncodedTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/FunctionalTests/Routing/PathEncodedTest.php \Drupal\FunctionalTests\Routing\PathEncodedTest
- 10 core/tests/Drupal/FunctionalTests/Routing/PathEncodedTest.php \Drupal\FunctionalTests\Routing\PathEncodedTest
- 9 core/tests/Drupal/FunctionalTests/Routing/PathEncodedTest.php \Drupal\FunctionalTests\Routing\PathEncodedTest
- 8.9.x core/tests/Drupal/FunctionalTests/Routing/PathEncodedTest.php \Drupal\FunctionalTests\Routing\PathEncodedTest
Tests URL generation and routing for route paths with encoded characters.
Attributes
#[Group('path')]
#[Group('routing')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\Tests\BrowserHtmlDebugTrait, \Drupal\Tests\HttpKernelUiHelperTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Routing\PathEncodedTest uses \Drupal\Tests\Traits\Core\PathAliasTestTrait extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of PathEncodedTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Routing/ PathEncodedTest.php, line 16
Namespace
Drupal\KernelTests\Core\RoutingView source
class PathEncodedTest extends KernelTestBase {
use PathAliasTestTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
'path_encoded_test',
'path_alias',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->installEntitySchema('path_alias');
}
/**
* Test PathEncodedTestController.
*/
public function testGetEncoded() : void {
$route_paths = [
'path_encoded_test.colon' => '/hi/llama:party',
'path_encoded_test.at_sign' => '/blog/@Dries',
'path_encoded_test.parentheses' => '/cat(box)',
];
foreach ($route_paths as $route_name => $path) {
$this->drupalGet(Url::fromRoute($route_name));
$this->assertSession()
->pageTextContains('PathEncodedTestController works');
}
}
/**
* Test PathEncodedTestController.
*/
public function testAliasToEncoded() : void {
$route_paths = [
'path_encoded_test.colon' => '/hi/llama:party',
'path_encoded_test.at_sign' => '/blog/@Dries',
'path_encoded_test.parentheses' => '/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->assertMatchesRegularExpression('@/' . rawurlencode($aliases[$route_name]) . '$@', Url::fromRoute($route_name)->toString());
$this->drupalGet(Url::fromRoute($route_name));
$this->assertSession()
->pageTextContains('PathEncodedTestController works');
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.