diff --git a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php index f2e1386..ed29ebe 100644 --- a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php +++ b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php @@ -313,6 +313,21 @@ public function configureTitle($foo) { } /** + * Simple argument echo. + * + * @param string $text + * Any string for the {text} slug. + * + * @return array + * A render array. + */ + public function simpleEcho($text) { + return [ + '#plain_text' => $text, + ]; + } + + /** * Shows permission-dependent content. * * @return array diff --git a/core/modules/system/tests/modules/system_test/system_test.routing.yml b/core/modules/system/tests/modules/system_test/system_test.routing.yml index f35f546..eac36c6 100644 --- a/core/modules/system/tests/modules/system_test/system_test.routing.yml +++ b/core/modules/system/tests/modules/system_test/system_test.routing.yml @@ -182,3 +182,10 @@ system_test.header: _controller: '\Drupal\system_test\Controller\SystemTestController::getTestHeader' requirements: _access: 'TRUE' + +system_test.echo: + path: '/system-test/echo/{text}' + defaults: + _controller: '\Drupal\system_test\Controller\SystemTestController::simpleEcho' + requirements: + _access: 'TRUE' diff --git a/core/tests/Drupal/FunctionalTests/Routing/CaseInsensitivePathTest.php b/core/tests/Drupal/FunctionalTests/Routing/CaseInsensitivePathTest.php index 83c58b5..906ffef 100644 --- a/core/tests/Drupal/FunctionalTests/Routing/CaseInsensitivePathTest.php +++ b/core/tests/Drupal/FunctionalTests/Routing/CaseInsensitivePathTest.php @@ -5,7 +5,7 @@ use Drupal\Tests\BrowserTestBase; /** - * Tests url generation and routing for route paths with encoded characters. + * Tests incoming path case insensitivity. * * @group routing */ @@ -14,8 +14,19 @@ class CaseInsensitivePathTest extends BrowserTestBase { /** * {@inheritdoc} */ - public static $modules = ['system', 'views', 'node']; + public static $modules = ['system', 'views', 'node', 'system_test']; + /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + \Drupal::state()->set('system_test.module_hidden', FALSE); + } + + /** + * Tests paths defined by routes from standard modules. + */ public function testInternalPath() { $this->drupalGet('user/login'); $this->assertEquals($this->getSession()->getStatusCode(), 200); @@ -23,14 +34,70 @@ public function testInternalPath() { $this->assertEquals($this->getSession()->getStatusCode(), 200); } + /** + * Tests paths defined by routes from the Views module. + */ public function testViewsPath() { $admin = $this->drupalCreateUser(['access administration pages', 'administer nodes', 'access content overview']); $this->drupalLogin($admin); $this->drupalGet('admin/content'); - $this->assertEquals($this->getSession()->getStatusCode(), 200); + $this->assertEquals(200, $this->getSession()->getStatusCode()); $this->drupalGet('Admin/Content'); - $this->assertEquals($this->getSession()->getStatusCode(), 200); + $this->assertEquals(200, $this->getSession()->getStatusCode()); + } + + /** + * Tests paths with query arguments. + */ + public function testPathsWithQuery() { + $admin = $this->drupalCreateUser(['access administration pages', 'administer nodes', 'access content overview']); + $this->drupalLogin($admin); + + // Make sure our node title doesn't exist. + $this->drupalGet('admin/content'); + $this->assertSession()->linkNotExists('FooBarBaz'); + $this->assertSession()->linkNotExists('foobarbaz'); + + // Create a node, and make sure it shows up on admin/content. + $node = $this->createNode([ + 'title' => 'FooBarBaz', + 'type' => 'page', + ]); + + $this->drupalGet('admin/content', [ + 'query' => [ + 'title' => 'FooBarBaz' + ] + ]); + + $this->assertSession()->linkExists('FooBarBaz'); + $this->assertSession()->linkByHrefExists($node->toUrl()->toString()); + + // Make sure the path is case insensitive, and query case is preserved. + + $this->drupalGet('Admin/Content', [ + 'query' => [ + 'title' => 'FooBarBaz' + ] + ]); + + $this->assertSession()->linkExists('FooBarBaz'); + $this->assertSession()->linkByHrefExists($node->toUrl()->toString()); + $this->assertSession()->fieldValueEquals('edit-title', 'FooBarBaz'); + } + + /** + * Tests paths with slugs. + */ + public function testPathsWithArguments() { + $this->drupalGet('system-test/echo/foobarbaz'); + $this->assertSession()->responseMatches('/foobarbaz/'); + $this->assertSession()->responseNotMatches('/FooBarBaz/'); + + $this->drupalGet('system-test/echo/FooBarBaz'); + $this->assertSession()->responseMatches('/FooBarBaz/'); + $this->assertSession()->responseNotMatches('/foobarbaz/'); } }