.../Drupal/Tests/Component/Utility/HtmlTest.php | 30 +++++++++------------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php b/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php index 1567059..7bac6ba 100644 --- a/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php +++ b/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php @@ -350,29 +350,23 @@ public function providerTestTransformRootRelativeUrlsToAbsolute() { // One random tag name. $tag_name = strtolower($this->randomMachineName()); - // All possible attributes that support URIs. - $attributes = ['href', 'poster', 'src', 'cite', 'data', 'action', 'formaction', 'srcset']; - // A site installed either in the root of a domain or a subdirectory. $base_paths = ['/', '/subdir/' . $this->randomMachineName() . '/']; - foreach ($attributes as $attribute) { - foreach ($base_paths as $base_path) { - // The only attribute that has more than just a URL as its value, is - // 'srcset', so special-case it. - if ($attribute === 'srcset') { - $data += [ - "$tag_name, $attribute, $base_path: root-relative" => ["<$tag_name $attribute=\"http://example.com{$base_path}already-absolute 200w, {$base_path}root-relative 300w\">root-relative test", 'http://example.com', "<$tag_name $attribute=\"http://example.com{$base_path}already-absolute 200w, http://example.com{$base_path}root-relative 300w\">root-relative test"], - "$tag_name, $attribute, $base_path: protocol-relative" => ["<$tag_name $attribute=\"http://example.com{$base_path}already-absolute 200w, //example.com{$base_path}protocol-relative 300w\">protocol-relative test", 'http://example.com', FALSE], - "$tag_name, $attribute, $base_path: absolute" => ["<$tag_name $attribute=\"http://example.com{$base_path}already-absolute 200w, http://example.com{$base_path}absolute 300w\">absolute test", 'http://example.com', FALSE], - ]; - continue; - } + foreach ($base_paths as $base_path) { + // The only attribute that has more than just a URL as its value, is + // 'srcset', so special-case it. + $data += [ + "$tag_name, srcset, $base_path: root-relative" => ["<$tag_name srcset=\"http://example.com{$base_path}already-absolute 200w, {$base_path}root-relative 300w\">root-relative test", 'http://example.com', "<$tag_name srcset=\"http://example.com{$base_path}already-absolute 200w, http://example.com{$base_path}root-relative 300w\">root-relative test"], + "$tag_name, srcset, $base_path: protocol-relative" => ["<$tag_name srcset=\"http://example.com{$base_path}already-absolute 200w, //example.com{$base_path}protocol-relative 300w\">protocol-relative test", 'http://example.com', FALSE], + "$tag_name, srcset, $base_path: absolute" => ["<$tag_name srcset=\"http://example.com{$base_path}already-absolute 200w, http://example.com{$base_path}absolute 300w\">absolute test", 'http://example.com', FALSE], + ]; + foreach (['href', 'poster', 'src', 'cite', 'data', 'action', 'formaction', 'srcset'] as $attribute) { $data += [ - "$tag_name, $attribute, $base_path: root-relative" => ["<$tag_name $attribute=\"{$base_path}root-relative\">root-relative test", 'http://example.com', "<$tag_name $attribute=\"http://example.com{$base_path}root-relative\">root-relative test"], - "$tag_name, $attribute, $base_path: protocol-relative" => ["<$tag_name $attribute=\"//example.com{$base_path}protocol-relative\">protocol-relative test", 'http://example.com', FALSE], - "$tag_name, $attribute, $base_path: absolute" => ["<$tag_name $attribute=\"http://example.com{$base_path}absolute\">absolute test", 'http://example.com', FALSE], + "$tag_name, $attribute, $base_path: root-relative" => ["<$tag_name $attribute=\"http://example.com{$base_path}already-absolute 200w, {$base_path}root-relative 300w\">root-relative test", 'http://example.com', "<$tag_name $attribute=\"http://example.com{$base_path}already-absolute 200w, http://example.com{$base_path}root-relative 300w\">root-relative test"], + "$tag_name, $attribute, $base_path: protocol-relative" => ["<$tag_name $attribute=\"http://example.com{$base_path}already-absolute 200w, //example.com{$base_path}protocol-relative 300w\">protocol-relative test", 'http://example.com', FALSE], + "$tag_name, $attribute, $base_path: absolute" => ["<$tag_name $attribute=\"http://example.com{$base_path}already-absolute 200w, http://example.com{$base_path}absolute 300w\">absolute test", 'http://example.com', FALSE], ]; } }