diff --git a/core/modules/locale/src/Tests/LocalePathTest.php b/core/modules/locale/src/Tests/LocalePathTest.php index 820814e..4545481 100644 --- a/core/modules/locale/src/Tests/LocalePathTest.php +++ b/core/modules/locale/src/Tests/LocalePathTest.php @@ -108,10 +108,10 @@ public function testPathLanguageConfiguration() { ); $this->container->get('path.alias_storage')->save($edit['source'], $edit['alias'], $edit['langcode']); $lookup_path = $this->container->get('path.alias_manager')->getAliasByPath('/node/' . $node->id(), 'en'); - $this->assertEqual('/' . $english_path, $lookup_path, 'English language alias has priority.'); + $this->assertIdentical(strcasecmp('/' . $english_path, $lookup_path), 0, 'English language alias has priority.'); // Same check for language 'xx'. $lookup_path = $this->container->get('path.alias_manager')->getAliasByPath('/node/' . $node->id(), $prefix); - $this->assertEqual('/' . $custom_language_path, $lookup_path, 'Custom language alias has priority.'); + $this->assertIdentical(strcasecmp('/' . $custom_language_path, $lookup_path), 0, 'Custom language alias has priority.'); $this->container->get('path.alias_storage')->delete($edit); // Create language nodes to check priority of aliases. diff --git a/core/modules/path/src/Tests/PathAliasTest.php b/core/modules/path/src/Tests/PathAliasTest.php index e4d07e2..10c0278 100644 --- a/core/modules/path/src/Tests/PathAliasTest.php +++ b/core/modules/path/src/Tests/PathAliasTest.php @@ -7,6 +7,8 @@ namespace Drupal\path\Tests; +use Drupal\Component\Utility\Unicode; + /** * Add, edit, delete, and change alias and verify its consistency in the * database. @@ -124,8 +126,9 @@ function testAdminAlias() { $edit['source'] = '/node/' . $node1->id(); $alias = '/' . $this->randomMachineName(128); $edit['alias'] = $alias; - // The alias is shortened to 50 characters counting the ellipsis. - $truncated_alias = substr($alias, 0, 47); + // The alias is shortened to 50 characters counting the ellipsis, and will + // be lower case. + $truncated_alias = Unicode::strtolower(substr($alias, 0, 47)); $this->drupalPostForm('admin/config/search/path/add', $edit, t('Save')); $this->assertNoText($alias, 'The untruncated alias was not found.'); // The 'truncated' alias will always be found. @@ -152,9 +155,9 @@ function testAdminAlias() { $this->drupalPostForm('admin/config/search/path/add', $edit, t('Save')); // Confirm that the alias with trailing slash is not found. - $this->assertNoText($edit['alias'], 'The absolute alias was not found.'); + $this->assertNoText(Unicode::strtolower($edit['alias']), 'The absolute alias was not found.'); // The alias without trailing flash is found. - $this->assertText(trim($edit['alias'], '/'), 'The alias without trailing slash was found.'); + $this->assertText(trim(Unicode::strtolower($edit['alias']), '/'), 'The alias without trailing slash was found.'); // Update an existing alias to point to a different source. $pid = $this->getPID($node4_alias); @@ -208,7 +211,7 @@ function testNodeAlias() { $this->assertResponse(200); // Confirm the 'canonical' and 'shortlink' URLs. - $elements = $this->xpath("//link[contains(@rel, 'canonical') and contains(@href, '" . $edit['path[0][alias]'] . "')]"); + $elements = $this->xpath("//link[contains(@rel, 'canonical') and contains(@href, '" . Unicode::strtolower($edit['path[0][alias]']) . "')]"); $this->assertTrue(!empty($elements), 'Page contains canonical link URL.'); $elements = $this->xpath("//link[contains(@rel, 'shortlink') and contains(@href, 'node/" . $node1->id() . "')]"); $this->assertTrue(!empty($elements), 'Page contains shortlink URL.'); diff --git a/core/modules/path/src/Tests/PathLanguageTest.php b/core/modules/path/src/Tests/PathLanguageTest.php index 67463f2..7e90c7b 100644 --- a/core/modules/path/src/Tests/PathLanguageTest.php +++ b/core/modules/path/src/Tests/PathLanguageTest.php @@ -7,6 +7,8 @@ namespace Drupal\path\Tests; +use Drupal\Component\Utility\Unicode; + /** * Confirm that paths work with translated nodes. * @@ -125,7 +127,7 @@ function testAliasTranslation() { $languages = $this->container->get('language_manager')->getLanguages(); $url = $english_node_french_translation->url('canonical', array('language' => $languages['fr'])); - $this->assertTrue(strpos($url, $edit['path[0][alias]']), 'URL contains the path alias.'); + $this->assertTrue(stripos($url, $edit['path[0][alias]']), 'URL contains the path alias.'); // Confirm that the alias works even when changing language negotiation // options. Enable User language detection and selection over URL one. @@ -182,10 +184,10 @@ function testAliasTranslation() { // Confirm that the alias works. $french_node_alias = $this->container->get('path.alias_manager')->getAliasByPath('/node/' . $english_node_french_translation->id(), 'fr'); - $this->assertEqual($french_node_alias, '/' . $french_alias, 'Alias works.'); + $this->assertIdentical(Unicode::strcasecmp($french_node_alias, '/' . $french_alias), 0, 'Alias works.'); // Second call should return the same alias. $french_node_alias = $this->container->get('path.alias_manager')->getAliasByPath('/node/' . $english_node_french_translation->id(), 'fr'); - $this->assertEqual($french_node_alias, '/' . $french_alias, 'Alias is the same.'); + $this->assertIdentical(Unicode::strcasecmp($french_node_alias, '/' . $french_alias), 0, 'Alias is the same.'); // Confirm that the alias is removed if the translation is deleted. $english_node->removeTranslation('fr'); diff --git a/core/modules/path/src/Tests/PathTaxonomyTermTest.php b/core/modules/path/src/Tests/PathTaxonomyTermTest.php index 98372df..f2912f7 100644 --- a/core/modules/path/src/Tests/PathTaxonomyTermTest.php +++ b/core/modules/path/src/Tests/PathTaxonomyTermTest.php @@ -7,6 +7,7 @@ namespace Drupal\path\Tests; +use Drupal\Component\Utility\Unicode; use Drupal\taxonomy\Entity\Vocabulary; /** @@ -58,7 +59,7 @@ function testTermAlias() { $this->assertText($description, 'Term can be accessed on URL alias.'); // Confirm the 'canonical' and 'shortlink' URLs. - $elements = $this->xpath("//link[contains(@rel, 'canonical') and contains(@href, '" . $edit['path[0][alias]'] . "')]"); + $elements = $this->xpath("//link[contains(@rel, 'canonical') and contains(@href, '" . Unicode::strtolower($edit['path[0][alias]']) . "')]"); $this->assertTrue(!empty($elements), 'Term page contains canonical link URL.'); $elements = $this->xpath("//link[contains(@rel, 'shortlink') and contains(@href, 'taxonomy/term/" . $tid . "')]"); $this->assertTrue(!empty($elements), 'Term page contains shortlink URL.'); diff --git a/core/modules/simpletest/src/AssertContentTrait.php b/core/modules/simpletest/src/AssertContentTrait.php index c601943..fe196a6 100644 --- a/core/modules/simpletest/src/AssertContentTrait.php +++ b/core/modules/simpletest/src/AssertContentTrait.php @@ -10,6 +10,7 @@ use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\Html; use Drupal\Component\Utility\SafeMarkup; +use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\Xss; use Drupal\Core\Render\RenderContext; use Symfony\Component\CssSelector\CssSelector; @@ -349,7 +350,7 @@ protected function assertNoLink($label, $message = '', $group = 'Other') { * TRUE if the assertion succeeded, FALSE otherwise. */ protected function assertLinkByHref($href, $index = 0, $message = '', $group = 'Other') { - $links = $this->xpath('//a[contains(@href, :href)]', array(':href' => $href)); + $links = $this->xpath('//a[contains(@href, :href)]', array(':href' => Unicode::strtolower($href))); $message = ($message ? $message : SafeMarkup::format('Link containing href %href found.', array('%href' => $href))); return $this->assert(isset($links[$index]), $message, $group); } @@ -373,7 +374,7 @@ protected function assertLinkByHref($href, $index = 0, $message = '', $group = ' * TRUE if the assertion succeeded, FALSE otherwise. */ protected function assertNoLinkByHref($href, $message = '', $group = 'Other') { - $links = $this->xpath('//a[contains(@href, :href)]', array(':href' => $href)); + $links = $this->xpath('//a[contains(@href, :href)]', array(':href' => Unicode::strtolower($href))); $message = ($message ? $message : SafeMarkup::format('No link containing href %href found.', array('%href' => $href))); return $this->assert(empty($links), $message, $group); } diff --git a/core/modules/system/src/Tests/Path/AliasTest.php b/core/modules/system/src/Tests/Path/AliasTest.php index 2ceb4c9..0c6e7dd 100644 --- a/core/modules/system/src/Tests/Path/AliasTest.php +++ b/core/modules/system/src/Tests/Path/AliasTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Path; +use Drupal\Component\Utility\Unicode; use Drupal\Core\Cache\MemoryCounterBackend; use Drupal\Core\Path\AliasStorage; use Drupal\Core\Database\Database; @@ -107,8 +108,8 @@ function testLookupPath() { $aliasStorage->save($path['source'], $path['alias'], $path['langcode']); // Hook that clears cache is not executed with unit tests. \Drupal::service('path.alias_manager')->cacheClear(); - $this->assertEqual($aliasManager->getAliasByPath($path['source']), $path['alias'], 'English alias overrides language-neutral alias.'); - $this->assertEqual($aliasManager->getPathByAlias($path['alias']), $path['source'], 'English source overrides language-neutral source.'); + $this->assertIdentical(Unicode::strcasecmp($aliasManager->getAliasByPath($path['source']), $path['alias']), 0, 'English alias overrides language-neutral alias.'); + $this->assertIdentical(Unicode::strcasecmp($aliasManager->getPathByAlias($path['alias']), $path['source']), 0, 'English source overrides language-neutral source.'); // Create a language-neutral alias for the same path, again. $path = array( @@ -127,7 +128,7 @@ function testLookupPath() { $aliasStorage->save($path['source'], $path['alias'], $path['langcode']); $this->assertEqual($aliasManager->getAliasByPath($path['source']), "/users/Dries", 'English alias still returned after entering a LOLspeak alias.'); // The LOLspeak alias should be returned if we really want LOLspeak. - $this->assertEqual($aliasManager->getAliasByPath($path['source'], 'xx-lolspeak'), '/LOL', 'LOLspeak alias returned if we specify xx-lolspeak to the alias manager.'); + $this->assertIdentical(Unicode::strcasecmp($aliasManager->getAliasByPath($path['source'], 'xx-lolspeak'), '/LOL'), 0, 'LOLspeak alias returned if we specify xx-lolspeak to the alias manager.'); // Create a new alias for this path in English, which should override the // previous alias for "user/1".