CaseInsensitivePathTest.php in Drupal 9
File
core/tests/Drupal/FunctionalTests/Routing/CaseInsensitivePathTest.php
View source
<?php
namespace Drupal\FunctionalTests\Routing;
use Drupal\Tests\BrowserTestBase;
class CaseInsensitivePathTest extends BrowserTestBase {
protected static $modules = [
'system',
'views',
'node',
'system_test',
];
protected $defaultTheme = 'stark';
protected function setUp() : void {
parent::setUp();
\Drupal::state()
->set('system_test.module_hidden', FALSE);
$this
->createContentType([
'type' => 'page',
]);
}
public function testMixedCasePaths() {
$this
->drupalGet('user/login');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextMatches('/Log in/');
$this
->drupalGet('User/Login');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextMatches('/Log in/');
$admin = $this
->drupalCreateUser([
'access administration pages',
'administer nodes',
'access content overview',
]);
$this
->drupalLogin($admin);
$this
->drupalGet('admin/content');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextMatches('/Content/');
$this
->drupalGet('Admin/Content');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextMatches('/Content/');
$this
->drupalGet('admin/content');
$this
->assertSession()
->linkNotExists('FooBarBaz');
$this
->assertSession()
->linkNotExists('foobarbaz');
$node = $this
->createNode([
'title' => 'FooBarBaz',
'type' => 'page',
]);
$this
->drupalGet('admin/content', [
'query' => [
'title' => 'FooBarBaz',
],
]);
$this
->assertSession()
->linkExists('FooBarBaz');
$this
->assertSession()
->linkByHrefExists($node
->toUrl()
->toString());
$this
->drupalGet('Admin/Content', [
'query' => [
'title' => 'FooBarBaz',
],
]);
$this
->assertSession()
->linkExists('FooBarBaz');
$this
->assertSession()
->linkByHrefExists($node
->toUrl()
->toString());
$this
->assertSession()
->fieldValueEquals('edit-title', 'FooBarBaz');
$this
->drupalGet('NOdE/' . $node
->id());
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextMatches('/FooBarBaz/');
}
public function testPathsWithArguments() {
$this
->drupalGet('system-test/echo/foobarbaz');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextMatches('/foobarbaz/');
$this
->assertSession()
->pageTextNotMatches('/FooBarBaz/');
$this
->drupalGet('system-test/echo/FooBarBaz');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextMatches('/FooBarBaz/');
$this
->assertSession()
->pageTextNotMatches('/foobarbaz/');
$this
->drupalGet('/system-test/Ȅchȏ/meΦω/ABc123');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextMatches('/ABc123/');
$this
->drupalGet('/system-test/ȅchȎ/MEΦΩ/ABc123');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextMatches('/ABc123/');
}
}