diff --git a/core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php b/core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php index 80c3d2de08c3632cd91dcd0961b44f4e91f631d1..0ae2104b6ed75ef09ed489bf4decd9e2380b3251 100644 --- a/core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php +++ b/core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php @@ -63,7 +63,8 @@ public function testHtmlResponse(array $attachments): void { // attachments, because it doesn't know (nor should it) how to handle them. $html_response_attachments_processor = $this->prophesize(AttachmentsResponseProcessorInterface::class); $html_response_attachments_processor->processAttachments(Argument::that(function ($response) { - return $response instanceof HtmlResponse && empty(array_intersect(['big_pipe_placeholders', 'big_pipe_nojs_placeholders'], array_keys($response->getAttachments()))); + return $response instanceof HtmlResponse + && empty(array_intersect(['big_pipe_placeholders', 'big_pipe_nojs_placeholders'], array_keys($response->getAttachments()))); })) ->will(function ($args) { /** @var \Symfony\Component\HttpFoundation\Response|\Drupal\Core\Render\AttachmentsInterface $response */ @@ -95,7 +96,16 @@ public static function attachmentsProvider() { 'libraries + drupalSettings' => [['library' => ['core/drupal'], 'drupalSettings' => ['foo' => 'bar']]], ]; - $official_attachment_types = ['html_head', 'feed', 'html_head_link', 'http_header', 'library', 'placeholders', 'drupalSettings', 'html_response_attachment_placeholders']; + $official_attachment_types = [ + 'html_head', + 'feed', + 'html_head_link', + 'http_header', + 'library', + 'placeholders', + 'drupalSettings', + 'html_response_attachment_placeholders', + ]; $official_attachments_with_random_values = []; foreach ($official_attachment_types as $type) { $official_attachments_with_random_values[$type] = Random::machineName(); diff --git a/core/modules/big_pipe/tests/src/Unit/Render/Placeholder/BigPipeStrategyTest.php b/core/modules/big_pipe/tests/src/Unit/Render/Placeholder/BigPipeStrategyTest.php index f69b82d2096ff9562e8d446398ae106adeecccf2..ff26e04dd3567e74f773bbcba811748a9d5d0975 100644 --- a/core/modules/big_pipe/tests/src/Unit/Render/Placeholder/BigPipeStrategyTest.php +++ b/core/modules/big_pipe/tests/src/Unit/Render/Placeholder/BigPipeStrategyTest.php @@ -79,36 +79,102 @@ public static function placeholdersProvider() { ]; return [ - '_no_big_pipe absent, no session, no-JS cookie absent' => [$placeholders, 'GET', FALSE, FALSE, FALSE, []], - '_no_big_pipe absent, no session, no-JS cookie present' => [$placeholders, 'GET', FALSE, FALSE, TRUE, []], - '_no_big_pipe present, no session, no-JS cookie absent' => [$placeholders, 'GET', TRUE, FALSE, FALSE, []], - '_no_big_pipe present, no session, no-JS cookie present' => [$placeholders, 'GET', TRUE, FALSE, TRUE, []], - '_no_big_pipe present, session, no-JS cookie absent' => [$placeholders, 'GET', TRUE, TRUE, FALSE, []], - '_no_big_pipe present, session, no-JS cookie present' => [$placeholders, 'GET', TRUE, TRUE, TRUE, []], + '_no_big_pipe absent, no session, no-JS cookie absent' => [ + $placeholders, + 'GET', + FALSE, + FALSE, + FALSE, + [], + ], + '_no_big_pipe absent, no session, no-JS cookie present' => [ + $placeholders, + 'GET', + FALSE, + FALSE, + TRUE, + [], + ], + '_no_big_pipe present, no session, no-JS cookie absent' => [ + $placeholders, + 'GET', + TRUE, + FALSE, + FALSE, + [], + ], + '_no_big_pipe present, no session, no-JS cookie present' => [ + $placeholders, + 'GET', + TRUE, + FALSE, + TRUE, + [], + ], + '_no_big_pipe present, session, no-JS cookie absent' => [ + $placeholders, + 'GET', + TRUE, + TRUE, + FALSE, + [], + ], + '_no_big_pipe present, session, no-JS cookie present' => [ + $placeholders, + 'GET', + TRUE, + TRUE, + TRUE, + [], + ], '_no_big_pipe absent, session, no-JS cookie absent: (JS-powered) BigPipe placeholder used for HTML placeholders' => [ - $placeholders, 'GET', FALSE, TRUE, FALSE, [ - $cases['html']->placeholder => $cases['html']->bigPipePlaceholderRenderArray, - $cases['html_attribute_value']->placeholder => $cases['html_attribute_value']->bigPipeNoJsPlaceholderRenderArray, - $cases['html_attribute_value_subset']->placeholder => $cases['html_attribute_value_subset']->bigPipeNoJsPlaceholderRenderArray, - $cases['edge_case__invalid_html']->placeholder => $cases['edge_case__invalid_html']->bigPipeNoJsPlaceholderRenderArray, + $placeholders, + 'GET', + FALSE, + TRUE, + FALSE, + [ + $cases['html']->placeholder => $cases['html']->bigPipePlaceholderRenderArray, + $cases['html_attribute_value']->placeholder => $cases['html_attribute_value']->bigPipeNoJsPlaceholderRenderArray, + $cases['html_attribute_value_subset']->placeholder => $cases['html_attribute_value_subset']->bigPipeNoJsPlaceholderRenderArray, + $cases['edge_case__invalid_html']->placeholder => $cases['edge_case__invalid_html']->bigPipeNoJsPlaceholderRenderArray, $cases['edge_case__html_non_lazy_builder']->placeholder => $cases['edge_case__html_non_lazy_builder']->bigPipePlaceholderRenderArray, - $cases['exception__lazy_builder']->placeholder => $cases['exception__lazy_builder']->bigPipePlaceholderRenderArray, - $cases['exception__embedded_response']->placeholder => $cases['exception__embedded_response']->bigPipePlaceholderRenderArray, + $cases['exception__lazy_builder']->placeholder => $cases['exception__lazy_builder']->bigPipePlaceholderRenderArray, + $cases['exception__embedded_response']->placeholder => $cases['exception__embedded_response']->bigPipePlaceholderRenderArray, ], ], - '_no_big_pipe absent, session, no-JS cookie absent: (JS-powered) BigPipe placeholder used for HTML placeholders — but unsafe method' => [$placeholders, 'POST', FALSE, TRUE, FALSE, []], + '_no_big_pipe absent, session, no-JS cookie absent: (JS-powered) BigPipe placeholder used for HTML placeholders — but unsafe method' => [ + $placeholders, + 'POST', + FALSE, + TRUE, + FALSE, + [], + ], '_no_big_pipe absent, session, no-JS cookie present: no-JS BigPipe placeholder used for HTML placeholders' => [ - $placeholders, 'GET', FALSE, TRUE, TRUE, [ - $cases['html']->placeholder => $cases['html']->bigPipeNoJsPlaceholderRenderArray, - $cases['html_attribute_value']->placeholder => $cases['html_attribute_value']->bigPipeNoJsPlaceholderRenderArray, - $cases['html_attribute_value_subset']->placeholder => $cases['html_attribute_value_subset']->bigPipeNoJsPlaceholderRenderArray, - $cases['edge_case__invalid_html']->placeholder => $cases['edge_case__invalid_html']->bigPipeNoJsPlaceholderRenderArray, + $placeholders, + 'GET', + FALSE, + TRUE, + TRUE, + [ + $cases['html']->placeholder => $cases['html']->bigPipeNoJsPlaceholderRenderArray, + $cases['html_attribute_value']->placeholder => $cases['html_attribute_value']->bigPipeNoJsPlaceholderRenderArray, + $cases['html_attribute_value_subset']->placeholder => $cases['html_attribute_value_subset']->bigPipeNoJsPlaceholderRenderArray, + $cases['edge_case__invalid_html']->placeholder => $cases['edge_case__invalid_html']->bigPipeNoJsPlaceholderRenderArray, $cases['edge_case__html_non_lazy_builder']->placeholder => $cases['edge_case__html_non_lazy_builder']->bigPipeNoJsPlaceholderRenderArray, - $cases['exception__lazy_builder']->placeholder => $cases['exception__lazy_builder']->bigPipeNoJsPlaceholderRenderArray, - $cases['exception__embedded_response']->placeholder => $cases['exception__embedded_response']->bigPipeNoJsPlaceholderRenderArray, + $cases['exception__lazy_builder']->placeholder => $cases['exception__lazy_builder']->bigPipeNoJsPlaceholderRenderArray, + $cases['exception__embedded_response']->placeholder => $cases['exception__embedded_response']->bigPipeNoJsPlaceholderRenderArray, ], ], - '_no_big_pipe absent, session, no-JS cookie present: no-JS BigPipe placeholder used for HTML placeholders — but unsafe method' => [$placeholders, 'POST', FALSE, TRUE, TRUE, []], + '_no_big_pipe absent, session, no-JS cookie present: no-JS BigPipe placeholder used for HTML placeholders — but unsafe method' => [ + $placeholders, + 'POST', + FALSE, + TRUE, + TRUE, + [], + ], ]; } diff --git a/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php b/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php index 50f34b4f6538b462c59595b61ed839cf6e522cf8..131b81e8311b0be7b2cd23b2144e5435b55419b7 100644 --- a/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php +++ b/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php @@ -85,8 +85,26 @@ public function testBlockAdminDisplay($route, $expected): void { */ public static function providerTestBlockAdminDisplay() { return [ - ['block.admin_display', [['block.admin_display'], ['block.admin_display_theme:test_b', 'block.admin_display_theme:test_c']]], - ['block.admin_display_theme', [['block.admin_display'], ['block.admin_display_theme:test_b', 'block.admin_display_theme:test_c']]], + [ + 'block.admin_display', + [ + ['block.admin_display'], + [ + 'block.admin_display_theme:test_b', + 'block.admin_display_theme:test_c', + ], + ], + ], + [ + 'block.admin_display_theme', + [ + ['block.admin_display'], + [ + 'block.admin_display_theme:test_b', + 'block.admin_display_theme:test_c', + ], + ], + ], ]; } diff --git a/core/modules/ckeditor5/tests/src/Unit/HTMLRestrictionsTest.php b/core/modules/ckeditor5/tests/src/Unit/HTMLRestrictionsTest.php index 4c4bf6fda2f9014206a0cc934ba459c339edc5e2..49621be87fd7bc8617ea65cf3945ef3cc96743d7 100644 --- a/core/modules/ckeditor5/tests/src/Unit/HTMLRestrictionsTest.php +++ b/core/modules/ckeditor5/tests/src/Unit/HTMLRestrictionsTest.php @@ -674,7 +674,15 @@ public static function providerRepresentations(): \Generator { ]; yield '$text-container wildcard' => [ - new HTMLRestrictions(['$text-container' => ['class' => TRUE, 'data-llama' => TRUE], 'div' => FALSE, 'span' => FALSE, 'p' => ['id' => TRUE]]), + new HTMLRestrictions([ + '$text-container' => [ + 'class' => TRUE, + 'data-llama' => TRUE, + ], + 'div' => FALSE, + 'span' => FALSE, + 'p' => ['id' => TRUE], + ]), ['<$text-container class data-llama>', '<div>', '<span>', '<p id>'], '<div class data-llama> <span> <p id class data-llama>', [ @@ -707,7 +715,14 @@ public static function providerRepresentations(): \Generator { ]; yield 'realistic' => [ - new HTMLRestrictions(['a' => ['href' => TRUE, 'hreflang' => ['en' => TRUE, 'fr' => TRUE]], 'p' => ['data-*' => TRUE, 'class' => ['block' => TRUE]], 'br' => FALSE]), + new HTMLRestrictions([ + 'a' => [ + 'href' => TRUE, + 'hreflang' => ['en' => TRUE, 'fr' => TRUE], + ], + 'p' => ['data-*' => TRUE, 'class' => ['block' => TRUE]], + 'br' => FALSE, + ]), ['<a href hreflang="en fr">', '<p data-* class="block">', '<br>'], '<a href hreflang="en fr"> <p data-* class="block"> <br>', [ @@ -1207,28 +1222,60 @@ public static function providerOperands(): \Generator { 'b' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE]]]), 'expected_diff' => 'a', 'expected_intersection' => HTMLRestrictions::emptySet(), - 'expected_union' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]], '$text-container' => ['class' => ['text-align-center' => TRUE]]]), + 'expected_union' => new HTMLRestrictions([ + 'p' => [ + 'class' => [ + 'text-align-center' => TRUE, + 'text-align-justify' => TRUE, + ], + ], + '$text-container' => ['class' => ['text-align-center' => TRUE]], + ]), ]; yield 'wildcard + matching tag: attribute value intersection — without possible resolving — vice versa' => [ 'a' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE]]]), 'b' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]]]), 'expected_diff' => 'a', 'expected_intersection' => HTMLRestrictions::emptySet(), - 'expected_union' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]], '$text-container' => ['class' => ['text-align-center' => TRUE]]]), + 'expected_union' => new HTMLRestrictions([ + 'p' => [ + 'class' => [ + 'text-align-center' => TRUE, + 'text-align-justify' => TRUE, + ], + ], + '$text-container' => ['class' => ['text-align-center' => TRUE]], + ]), ]; yield 'wildcard + matching tag: attribute value intersection — WITH possible resolving' => [ 'a' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]]]), 'b' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE]], 'p' => FALSE]), 'expected_diff' => new HTMLRestrictions(['p' => ['class' => ['text-align-justify' => TRUE]]]), 'expected_intersection' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE]]]), - 'expected_union' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]], '$text-container' => ['class' => ['text-align-center' => TRUE]]]), + 'expected_union' => new HTMLRestrictions([ + 'p' => [ + 'class' => [ + 'text-align-center' => TRUE, + 'text-align-justify' => TRUE, + ], + ], + '$text-container' => ['class' => ['text-align-center' => TRUE]], + ]), ]; yield 'wildcard + matching tag: attribute value intersection — WITH possible resolving — vice versa' => [ 'a' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE]], 'p' => FALSE]), 'b' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]]]), 'expected_diff' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE]]]), 'expected_intersection' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE]]]), - 'expected_union' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]], '$text-container' => ['class' => ['text-align-center' => TRUE]]]), + 'expected_union' => new HTMLRestrictions([ + 'p' => [ + 'class' => [ + 'text-align-center' => TRUE, + 'text-align-justify' => TRUE, + ], + ], + '$text-container' => ['class' => ['text-align-center' => TRUE]], + ]), ]; yield 'wildcard + matching tag: on both sides' => [ 'a' => new HTMLRestrictions(['$text-container' => ['class' => TRUE, 'foo' => TRUE], 'p' => FALSE]), @@ -1249,14 +1296,20 @@ public static function providerOperands(): \Generator { 'b' => new HTMLRestrictions(['$text-container' => ['class' => ['foo' => TRUE, 'bar' => TRUE]]]), 'expected_diff' => 'a', 'expected_intersection' => HTMLRestrictions::emptySet(), - 'expected_union' => new HTMLRestrictions(['p' => TRUE, '$text-container' => ['class' => ['foo' => TRUE, 'bar' => TRUE]]]), + 'expected_union' => new HTMLRestrictions([ + 'p' => TRUE, + '$text-container' => ['class' => ['foo' => TRUE, 'bar' => TRUE]], + ]), ]; yield 'wildcard + matching tag: wildcard resolves into matching tag, but matching tag already supports all attributes — vice versa' => [ 'a' => new HTMLRestrictions(['$text-container' => ['class' => ['foo' => TRUE, 'bar' => TRUE]]]), 'b' => new HTMLRestrictions(['p' => TRUE]), 'expected_diff' => 'a', 'expected_intersection' => HTMLRestrictions::emptySet(), - 'expected_union' => new HTMLRestrictions(['p' => TRUE, '$text-container' => ['class' => ['foo' => TRUE, 'bar' => TRUE]]]), + 'expected_union' => new HTMLRestrictions([ + 'p' => TRUE, + '$text-container' => ['class' => ['foo' => TRUE, 'bar' => TRUE]], + ]), ]; // Wildcard tag + non-matching tag cases. @@ -1289,32 +1342,92 @@ public static function providerOperands(): \Generator { 'expected_union' => new HTMLRestrictions(['span' => ['class' => TRUE], '$text-container' => ['class' => TRUE]]), ]; yield 'wildcard + non-matching tag: attribute value diff — without possible resolving' => [ - 'a' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]]]), + 'a' => new HTMLRestrictions([ + 'span' => [ + 'class' => [ + 'vertical-align-top' => TRUE, + 'vertical-align-bottom' => TRUE, + ], + ], + ]), 'b' => new HTMLRestrictions(['$text-container' => ['class' => ['vertical-align-top' => TRUE]]]), 'expected_diff' => 'a', 'expected_intersection' => HTMLRestrictions::emptySet(), - 'expected_union' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]], '$text-container' => ['class' => ['vertical-align-top' => TRUE]]]), + 'expected_union' => new HTMLRestrictions([ + 'span' => [ + 'class' => [ + 'vertical-align-top' => TRUE, + 'vertical-align-bottom' => TRUE, + ], + ], + '$text-container' => ['class' => ['vertical-align-top' => TRUE]], + ]), ]; yield 'wildcard + non-matching tag: attribute value diff — without possible resolving — vice versa' => [ 'a' => new HTMLRestrictions(['$text-container' => ['class' => ['vertical-align-top' => TRUE]]]), - 'b' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]]]), + 'b' => new HTMLRestrictions([ + 'span' => [ + 'class' => [ + 'vertical-align-top' => TRUE, + 'vertical-align-bottom' => TRUE, + ], + ], + ]), 'expected_diff' => 'a', 'expected_intersection' => HTMLRestrictions::emptySet(), - 'expected_union' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]], '$text-container' => ['class' => ['vertical-align-top' => TRUE]]]), + 'expected_union' => new HTMLRestrictions([ + 'span' => [ + 'class' => [ + 'vertical-align-top' => TRUE, + 'vertical-align-bottom' => TRUE, + ], + ], + '$text-container' => ['class' => ['vertical-align-top' => TRUE]], + ]), ]; yield 'wildcard + non-matching tag: attribute value diff — WITH possible resolving' => [ - 'a' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]]]), + 'a' => new HTMLRestrictions([ + 'span' => [ + 'class' => [ + 'vertical-align-top' => TRUE, + 'vertical-align-bottom' => TRUE, + ], + ], + ]), 'b' => new HTMLRestrictions(['$text-container' => ['class' => ['vertical-align-top' => TRUE]], 'span' => FALSE]), 'expected_diff' => 'a', 'expected_intersection' => new HTMLRestrictions(['span' => FALSE]), - 'expected_union' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]], '$text-container' => ['class' => ['vertical-align-top' => TRUE]]]), + 'expected_union' => new HTMLRestrictions([ + 'span' => [ + 'class' => [ + 'vertical-align-top' => TRUE, + 'vertical-align-bottom' => TRUE, + ], + ], + '$text-container' => ['class' => ['vertical-align-top' => TRUE]], + ]), ]; yield 'wildcard + non-matching tag: attribute value diff — WITH possible resolving — vice versa' => [ 'a' => new HTMLRestrictions(['$text-container' => ['class' => ['vertical-align-top' => TRUE]], 'span' => FALSE]), - 'b' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]]]), + 'b' => new HTMLRestrictions([ + 'span' => [ + 'class' => [ + 'vertical-align-top' => TRUE, + 'vertical-align-bottom' => TRUE, + ], + ], + ]), 'expected_diff' => new HTMLRestrictions(['$text-container' => ['class' => ['vertical-align-top' => TRUE]]]), 'expected_intersection' => new HTMLRestrictions(['span' => FALSE]), - 'expected_union' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]], '$text-container' => ['class' => ['vertical-align-top' => TRUE]]]), + 'expected_union' => new HTMLRestrictions([ + 'span' => [ + 'class' => [ + 'vertical-align-top' => TRUE, + 'vertical-align-bottom' => TRUE, + ], + ], + '$text-container' => ['class' => ['vertical-align-top' => TRUE]], + ]), ]; // Wildcard tag + wildcard tag cases. @@ -1333,7 +1446,14 @@ public static function providerOperands(): \Generator { 'expected_union' => 'b', ]; yield 'wildcard + wildcard tag: attribute values' => [ - 'a' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]]]), + 'a' => new HTMLRestrictions([ + '$text-container' => [ + 'class' => [ + 'text-align-center' => TRUE, + 'text-align-justify' => TRUE, + ], + ], + ]), 'b' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE]]]), 'expected_diff' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-justify' => TRUE]]]), 'expected_intersection' => 'b', @@ -1341,7 +1461,14 @@ public static function providerOperands(): \Generator { ]; yield 'wildcard + wildcard tag: attribute values — vice versa' => [ 'a' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE]]]), - 'b' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]]]), + 'b' => new HTMLRestrictions([ + '$text-container' => [ + 'class' => [ + 'text-align-center' => TRUE, + 'text-align-justify' => TRUE, + ], + ], + ]), 'expected_diff' => HTMLRestrictions::emptySet(), 'expected_intersection' => 'a', 'expected_union' => 'b', @@ -1371,17 +1498,39 @@ public static function providerOperands(): \Generator { 'expected_union' => 'a', ]; yield "concrete attrs + wildcard $wildcard_location attr that covers a subset" => [ - 'a' => new HTMLRestrictions(['img' => ['data-entity-bundle-type' => TRUE, 'data-entity-type' => TRUE, 'class' => TRUE]]), + 'a' => new HTMLRestrictions([ + 'img' => [ + 'data-entity-bundle-type' => TRUE, + 'data-entity-type' => TRUE, + 'class' => TRUE, + ], + ]), 'b' => new HTMLRestrictions(['img' => [$wildcard_attr_name => TRUE]]), 'expected_diff' => new HTMLRestrictions(['img' => ['class' => TRUE]]), - 'expected_intersection' => new HTMLRestrictions(['img' => ['data-entity-bundle-type' => TRUE, 'data-entity-type' => TRUE]]), + 'expected_intersection' => new HTMLRestrictions([ + 'img' => [ + 'data-entity-bundle-type' => TRUE, + 'data-entity-type' => TRUE, + ], + ]), 'expected_union' => new HTMLRestrictions(['img' => [$wildcard_attr_name => TRUE, 'class' => TRUE]]), ]; yield "concrete attrs + wildcard $wildcard_location attr that covers a subset — vice versa" => [ 'a' => new HTMLRestrictions(['img' => [$wildcard_attr_name => TRUE]]), - 'b' => new HTMLRestrictions(['img' => ['data-entity-bundle-type' => TRUE, 'data-entity-type' => TRUE, 'class' => TRUE]]), + 'b' => new HTMLRestrictions([ + 'img' => [ + 'data-entity-bundle-type' => TRUE, + 'data-entity-type' => TRUE, + 'class' => TRUE, + ], + ]), 'expected_diff' => 'a', - 'expected_intersection' => new HTMLRestrictions(['img' => ['data-entity-bundle-type' => TRUE, 'data-entity-type' => TRUE]]), + 'expected_intersection' => new HTMLRestrictions([ + 'img' => [ + 'data-entity-bundle-type' => TRUE, + 'data-entity-type' => TRUE, + ], + ]), 'expected_union' => new HTMLRestrictions(['img' => [$wildcard_attr_name => TRUE, 'class' => TRUE]]), ]; yield "wildcard $wildcard_location attr + wildcard $wildcard_location attr" => [ @@ -1433,14 +1582,26 @@ public static function providerOperands(): \Generator { 'a' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE]]]), 'b' => new HTMLRestrictions(['*' => ['bar' => TRUE, 'dir' => TRUE, 'foo' => FALSE]]), 'expected_diff' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE]]), - 'expected_intersection' => new HTMLRestrictions(['*' => ['bar' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE], 'foo' => FALSE]]), + 'expected_intersection' => new HTMLRestrictions([ + '*' => [ + 'bar' => FALSE, + 'dir' => ['ltr' => TRUE, 'rtl' => TRUE], + 'foo' => FALSE, + ], + ]), 'expected_union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => TRUE, 'dir' => TRUE]]), ]; yield 'global attribute tag + global attribute tag: overlap in attributes, different attribute value restrictions — vice versa' => [ 'a' => new HTMLRestrictions(['*' => ['bar' => TRUE, 'dir' => TRUE, 'foo' => FALSE]]), 'b' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE]]]), 'expected_diff' => 'a', - 'expected_intersection' => new HTMLRestrictions(['*' => ['bar' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE], 'foo' => FALSE]]), + 'expected_intersection' => new HTMLRestrictions([ + '*' => [ + 'bar' => FALSE, + 'dir' => ['ltr' => TRUE, 'rtl' => TRUE], + 'foo' => FALSE, + ], + ]), 'expected_union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => TRUE, 'dir' => TRUE]]), ]; @@ -1480,14 +1641,26 @@ public static function providerOperands(): \Generator { 'b' => new HTMLRestrictions(['$text-container' => ['class' => TRUE]]), 'expected_diff' => 'a', 'expected_intersection' => HTMLRestrictions::emptySet(), - 'expected_union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE], '$text-container' => ['class' => TRUE]]), + 'expected_union' => new HTMLRestrictions([ + '*' => [ + 'foo' => TRUE, + 'bar' => FALSE, + ], + '$text-container' => ['class' => TRUE], + ]), ]; yield 'global attribute tag + wildcard tag — vice versa' => [ 'a' => new HTMLRestrictions(['$text-container' => ['class' => TRUE]]), 'b' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE]]), 'expected_diff' => 'a', 'expected_intersection' => HTMLRestrictions::emptySet(), - 'expected_union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE], '$text-container' => ['class' => TRUE]]), + 'expected_union' => new HTMLRestrictions([ + '*' => [ + 'foo' => TRUE, + 'bar' => FALSE, + ], + '$text-container' => ['class' => TRUE], + ]), ]; } @@ -1531,7 +1704,11 @@ public static function providerSubsets(): \Generator { ]; yield 'with wildcards' => [ - new HTMLRestrictions(['div' => FALSE, '$text-container' => ['data-llama' => TRUE], '*' => ['on*' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE]]]), + new HTMLRestrictions([ + 'div' => FALSE, + '$text-container' => ['data-llama' => TRUE], + '*' => ['on*' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE]], + ]), new HTMLRestrictions(['$text-container' => ['data-llama' => TRUE]]), new HTMLRestrictions(['div' => FALSE, '*' => ['on*' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE]]]), new HTMLRestrictions(['div' => FALSE]), @@ -1539,7 +1716,10 @@ public static function providerSubsets(): \Generator { ]; yield 'wildcards and global attribute tag' => [ - new HTMLRestrictions(['$text-container' => ['data-llama' => TRUE], '*' => ['on*' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE]]]), + new HTMLRestrictions([ + '$text-container' => ['data-llama' => TRUE], + '*' => ['on*' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE]], + ]), new HTMLRestrictions(['$text-container' => ['data-llama' => TRUE]]), new HTMLRestrictions(['*' => ['on*' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE]]]), new HTMLRestrictions([]), diff --git a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php index 2fea7255687cdf809ca41b118ff018ff1e7deca9..d00c44595dac226e345e0e2e50dc873baf2272cc 100644 --- a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php +++ b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php @@ -239,7 +239,13 @@ public static function getLinkCombinations() { } else { // On a separate page. - $expected['comment-add']['url'] = Url::fromRoute('comment.reply', ['entity_type' => 'node', 'entity' => 1, 'field_name' => 'comment']); + $expected['comment-add']['url'] = Url::fromRoute( + 'comment.reply', + [ + 'entity_type' => 'node', + 'entity' => 1, + 'field_name' => 'comment', + ]); } } } diff --git a/core/modules/config/tests/src/Unit/Menu/ConfigLocalTasksTest.php b/core/modules/config/tests/src/Unit/Menu/ConfigLocalTasksTest.php index 99248e5f72bf974087b9cae0c58412ab16e32a52..8e725407d19eae647430ed3b26562a7447a7e3f2 100644 --- a/core/modules/config/tests/src/Unit/Menu/ConfigLocalTasksTest.php +++ b/core/modules/config/tests/src/Unit/Menu/ConfigLocalTasksTest.php @@ -36,10 +36,30 @@ public function testConfigAdminLocalTasks($route, $expected): void { public static function getConfigAdminRoutes() { return [ ['config.sync', [['config.sync', 'config.import', 'config.export']]], - ['config.import_full', [['config.sync', 'config.import', 'config.export'], ['config.import_full', 'config.import_single']]], - ['config.import_single', [['config.sync', 'config.import', 'config.export'], ['config.import_full', 'config.import_single']]], - ['config.export_full', [['config.sync', 'config.import', 'config.export'], ['config.export_full', 'config.export_single']]], - ['config.export_single', [['config.sync', 'config.import', 'config.export'], ['config.export_full', 'config.export_single']]], + ['config.import_full', + [ + ['config.sync', 'config.import', 'config.export'], + ['config.import_full', 'config.import_single'], + ], + ], + ['config.import_single', + [ + ['config.sync', 'config.import', 'config.export'], + ['config.import_full', 'config.import_single'], + ], + ], + ['config.export_full', + [ + ['config.sync', 'config.import', 'config.export'], + ['config.export_full', 'config.export_single'], + ], + ], + ['config.export_single', + [ + ['config.sync', 'config.import', 'config.export'], + ['config.export_full', 'config.export_single'], + ], + ], ]; } diff --git a/core/modules/content_moderation/tests/src/Unit/LatestRevisionCheckTest.php b/core/modules/content_moderation/tests/src/Unit/LatestRevisionCheckTest.php index 41b469683ca707424275a5a29cdf9c6771a0988e..a8f603a0e5c289fd554ea0f4a49374f5f45772b6 100644 --- a/core/modules/content_moderation/tests/src/Unit/LatestRevisionCheckTest.php +++ b/core/modules/content_moderation/tests/src/Unit/LatestRevisionCheckTest.php @@ -108,27 +108,97 @@ public function testLatestAccessPermissions($entity_class, $entity_type, $has_pe public static function accessSituationProvider() { return [ // Node with global permissions and latest version. - [Node::class, 'node', TRUE, ['view latest version', 'view any unpublished content'], FALSE, AccessResultAllowed::class], + [ + Node::class, + 'node', + TRUE, + ['view latest version', 'view any unpublished content'], + FALSE, + AccessResultAllowed::class, + ], // Node with global permissions and no latest version. - [Node::class, 'node', FALSE, ['view latest version', 'view any unpublished content'], FALSE, AccessResultForbidden::class], + [ + Node::class, + 'node', + FALSE, + ['view latest version', 'view any unpublished content'], + FALSE, + AccessResultForbidden::class, + ], // Node with own content permissions and latest version. - [Node::class, 'node', TRUE, ['view latest version', 'view own unpublished content'], TRUE, AccessResultAllowed::class], + [ + Node::class, + 'node', + TRUE, + ['view latest version', 'view own unpublished content'], + TRUE, + AccessResultAllowed::class, + ], // Node with own content permissions and no latest version. - [Node::class, 'node', FALSE, ['view latest version', 'view own unpublished content'], FALSE, AccessResultForbidden::class], + [ + Node::class, + 'node', + FALSE, + ['view latest version', 'view own unpublished content'], + FALSE, + AccessResultForbidden::class, + ], // Node with own content permissions and latest version, but no perms to // view latest version. - [Node::class, 'node', TRUE, ['view own unpublished content'], TRUE, AccessResultNeutral::class], + [ + Node::class, + 'node', + TRUE, + ['view own unpublished content'], + TRUE, + AccessResultNeutral::class, + ], // Node with own content permissions and no latest version, but no perms // to view latest version. - [Node::class, 'node', TRUE, ['view own unpublished content'], FALSE, AccessResultNeutral::class], + [ + Node::class, + 'node', + TRUE, + ['view own unpublished content'], + FALSE, + AccessResultNeutral::class, + ], // Block with pending revision, and permissions to view any. - [BlockContent::class, 'block_content', TRUE, ['view latest version', 'view any unpublished content'], FALSE, AccessResultAllowed::class], + [ + BlockContent::class, + 'block_content', + TRUE, + ['view latest version', 'view any unpublished content'], + FALSE, + AccessResultAllowed::class, + ], // Block with no pending revision. - [BlockContent::class, 'block_content', FALSE, ['view latest version', 'view any unpublished content'], FALSE, AccessResultForbidden::class], + [ + BlockContent::class, + 'block_content', + FALSE, + ['view latest version', 'view any unpublished content'], + FALSE, + AccessResultForbidden::class, + ], // Block with pending revision, but no permission to view any. - [BlockContent::class, 'block_content', TRUE, ['view latest version', 'view own unpublished content'], FALSE, AccessResultNeutral::class], + [ + BlockContent::class, + 'block_content', + TRUE, + ['view latest version', 'view own unpublished content'], + FALSE, + AccessResultNeutral::class, + ], // Block with no pending revision. - [BlockContent::class, 'block_content', FALSE, ['view latest version', 'view own unpublished content'], FALSE, AccessResultForbidden::class], + [ + BlockContent::class, + 'block_content', + FALSE, + ['view latest version', 'view own unpublished content'], + FALSE, + AccessResultForbidden::class, + ], ]; } diff --git a/core/modules/editor/tests/src/Unit/EditorXssFilter/StandardTest.php b/core/modules/editor/tests/src/Unit/EditorXssFilter/StandardTest.php index 5dff58ea9bef685cb339e48c9f84d2450c599001..eb5ce5deb9f9741bdd77cd07329cc09790713bf7 100644 --- a/core/modules/editor/tests/src/Unit/EditorXssFilter/StandardTest.php +++ b/core/modules/editor/tests/src/Unit/EditorXssFilter/StandardTest.php @@ -60,10 +60,22 @@ protected function setUp(): void { */ public static function providerTestFilterXss() { $data = []; - $data[] = ['<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>', '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>']; - $data[] = ['<p style="color:red">Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>', '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>']; - $data[] = ['<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown><script>alert("evil");</script>', '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>alert("evil");']; - $data[] = ['<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown><a href="javascript:alert(1)">test</a>', '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown><a href="alert(1)">test</a>']; + $data[] = [ + '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>', + '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>', + ]; + $data[] = [ + '<p style="color:red">Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>', + '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>', + ]; + $data[] = [ + '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown><script>alert("evil");</script>', + '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown>alert("evil");', + ]; + $data[] = [ + '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown><a href="javascript:alert(1)">test</a>', + '<p>Hello, world!</p><unknown>Pink Fairy Armadillo</unknown><a href="alert(1)">test</a>', + ]; // All cases listed on // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet @@ -74,7 +86,10 @@ public static function providerTestFilterXss() { // Image XSS using the JavaScript directive. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Image_XSS_using_the_JavaScript_directive - $data[] = ['<IMG SRC="javascript:alert(\'XSS\');">', '<IMG src="alert('XSS');">']; + $data[] = [ + '<IMG SRC="javascript:alert(\'XSS\');">', + '<IMG src="alert('XSS');">', + ]; // No quotes and no semicolon. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#No_quotes_and_no_semicolon @@ -94,16 +109,28 @@ public static function providerTestFilterXss() { // Malformed A tags. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Malformed_A_tags - $data[] = ['<a onmouseover="alert(document.cookie)">xxs link</a>', '<a>xxs link</a>']; - $data[] = ['<a onmouseover=alert(document.cookie)>xxs link</a>', '<a>xxs link</a>']; + $data[] = [ + '<a onmouseover="alert(document.cookie)">xxs link</a>', + '<a>xxs link</a>', + ]; + $data[] = [ + '<a onmouseover=alert(document.cookie)>xxs link</a>', + '<a>xxs link</a>', + ]; // Malformed IMG tags. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Malformed_IMG_tags - $data[] = ['<IMG """><SCRIPT>alert("XSS")</SCRIPT>">', '<IMG>alert("XSS")">']; + $data[] = [ + '<IMG """><SCRIPT>alert("XSS")</SCRIPT>">', + '<IMG>alert("XSS")">', + ]; // fromCharCode. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#fromCharCode - $data[] = ['<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>', '<IMG src="alert(String.fromCharCode(88,83,83))">']; + $data[] = [ + '<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>', + '<IMG src="alert(String.fromCharCode(88,83,83))">', + ]; // Default SRC tag to get past filters that check SRC domain. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Default_SRC_tag_to_get_past_filters_that_check_SRC_domain @@ -119,31 +146,52 @@ public static function providerTestFilterXss() { // Decimal HTML character references. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Decimal_HTML_character_references - $data[] = ['<IMG SRC=javascript:alert('XSS')>', '<IMG src="alert('XSS')">']; + $data[] = [ + '<IMG SRC=javascript:alert('XSS')>', + '<IMG src="alert('XSS')">', + ]; // Decimal HTML character references without trailing semicolons. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Decimal_HTML_character_references_without_trailing_semicolons - $data[] = ['<IMG SRC=javascript:alert('XSS')>', '<IMG src="&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041">']; + $data[] = [ + '<IMG SRC=javascript:alert('XSS')>', + '<IMG src="&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041">', + ]; // Hexadecimal HTML character references without trailing semicolons. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Hexadecimal_HTML_character_references_without_trailing_semicolons - $data[] = ['<IMG SRC=javascript:alert('XSS')>', '<IMG src="&#x6A&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A&#x61&#x6C&#x65&#x72&#x74&#x28&#x27&#x58&#x53&#x53&#x27&#x29">']; + $data[] = [ + '<IMG SRC=javascript:alert('XSS')>', + '<IMG src="&#x6A&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A&#x61&#x6C&#x65&#x72&#x74&#x28&#x27&#x58&#x53&#x53&#x27&#x29">', + ]; // Embedded tab. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Embedded_tab - $data[] = ['<IMG SRC="jav ascript:alert(\'XSS\');">', '<IMG src="alert('XSS');">']; + $data[] = [ + '<IMG SRC="jav ascript:alert(\'XSS\');">', + '<IMG src="alert('XSS');">', + ]; // Embedded Encoded tab. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Embedded_Encoded_tab - $data[] = ['<IMG SRC="jav	ascript:alert(\'XSS\');">', '<IMG src="alert('XSS');">']; + $data[] = [ + '<IMG SRC="jav	ascript:alert(\'XSS\');">', + '<IMG src="alert('XSS');">', + ]; // Embedded newline to break up XSS. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Embedded_newline_to_break_up_XSS - $data[] = ['<IMG SRC="jav
ascript:alert(\'XSS\');">', '<IMG src="alert('XSS');">']; + $data[] = [ + '<IMG SRC="jav
ascript:alert(\'XSS\');">', + '<IMG src="alert('XSS');">', + ]; // Embedded carriage return to break up XSS. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Embedded_carriage_return_to_break_up_XSS - $data[] = ['<IMG SRC="jav
ascript:alert(\'XSS\');">', '<IMG src="alert('XSS');">']; + $data[] = [ + '<IMG SRC="jav
ascript:alert(\'XSS\');">', + '<IMG src="alert('XSS');">', + ]; // Null breaks up JavaScript directive. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Null_breaks_up_JavaScript_directive @@ -169,7 +217,10 @@ public static function providerTestFilterXss() { // Half open HTML/JavaScript XSS vector. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Half_open_HTML.2FJavaScript_XSS_vector - $data[] = ['<IMG SRC="javascript:alert(\'XSS\')"', '<IMG src="alert('XSS')">']; + $data[] = [ + '<IMG SRC="javascript:alert(\'XSS\')"', + '<IMG src="alert('XSS')">', + ]; // Double open angle brackets. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Double_open_angle_brackets @@ -184,31 +235,52 @@ public static function providerTestFilterXss() { // End title tag. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#End_title_tag - $data[] = ['</TITLE><SCRIPT>alert("XSS");</SCRIPT>', '</TITLE>alert("XSS");']; + $data[] = [ + '</TITLE><SCRIPT>alert("XSS");</SCRIPT>', + '</TITLE>alert("XSS");', + ]; // INPUT image. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#INPUT_image - $data[] = ['<INPUT TYPE="IMAGE" SRC="javascript:alert(\'XSS\');">', '<INPUT type="IMAGE" src="alert('XSS');">']; + $data[] = [ + '<INPUT TYPE="IMAGE" SRC="javascript:alert(\'XSS\');">', + '<INPUT type="IMAGE" src="alert('XSS');">', + ]; // BODY image. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#BODY_image - $data[] = ['<BODY BACKGROUND="javascript:alert(\'XSS\')">', '<BODY background="alert('XSS')">']; + $data[] = [ + '<BODY BACKGROUND="javascript:alert(\'XSS\')">', + '<BODY background="alert('XSS')">', + ]; // IMG Dynsrc. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#IMG_Dynsrc - $data[] = ['<IMG DYNSRC="javascript:alert(\'XSS\')">', '<IMG dynsrc="alert('XSS')">']; + $data[] = [ + '<IMG DYNSRC="javascript:alert(\'XSS\')">', + '<IMG dynsrc="alert('XSS')">', + ]; // IMG lowsrc. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#IMG_lowsrc - $data[] = ['<IMG LOWSRC="javascript:alert(\'XSS\')">', '<IMG lowsrc="alert('XSS')">']; + $data[] = [ + '<IMG LOWSRC="javascript:alert(\'XSS\')">', + '<IMG lowsrc="alert('XSS')">', + ]; // List-style-image. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#List-style-image - $data[] = ['<STYLE>li {list-style-image: url("javascript:alert(\'XSS\')");}</STYLE><UL><LI>XSS</br>', 'li {list-style-image: url("javascript:alert(\'XSS\')");}<UL><LI>XSS</br>']; + $data[] = [ + '<STYLE>li {list-style-image: url("javascript:alert(\'XSS\')");}</STYLE><UL><LI>XSS</br>', + 'li {list-style-image: url("javascript:alert(\'XSS\')");}<UL><LI>XSS</br>', + ]; // VBscript in an image. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#VBscript_in_an_image - $data[] = ['<IMG SRC=\'vbscript:msgbox("XSS")\'>', '<IMG src=\'msgbox("XSS")\'>']; + $data[] = [ + '<IMG SRC=\'vbscript:msgbox("XSS")\'>', + '<IMG src=\'msgbox("XSS")\'>', + ]; // Livescript (older versions of Netscape only). // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Livescript_.28older_versions_of_Netscape_only.29 @@ -331,7 +403,10 @@ public static function providerTestFilterXss() { // BGSOUND. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#BGSOUND - $data[] = ['<BGSOUND SRC="javascript:alert(\'XSS\');">', '<BGSOUND src="alert('XSS');">']; + $data[] = [ + '<BGSOUND SRC="javascript:alert(\'XSS\');">', + '<BGSOUND src="alert('XSS');">', + ]; // & JavaScript includes. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#.26_JavaScript_includes @@ -343,23 +418,38 @@ public static function providerTestFilterXss() { // Remote style sheet. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Remote_style_sheet - $data[] = ['<LINK REL="stylesheet" HREF="http://ha.ckers.org/xss.css">', '']; + $data[] = [ + '<LINK REL="stylesheet" HREF="http://ha.ckers.org/xss.css">', + '', + ]; // Remote style sheet part 2. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Remote_style_sheet_part_2 - $data[] = ['<STYLE>@import\'http://ha.ckers.org/xss.css\';</STYLE>', '@import\'http://ha.ckers.org/xss.css\';']; + $data[] = [ + '<STYLE>@import\'http://ha.ckers.org/xss.css\';</STYLE>', + '@import\'http://ha.ckers.org/xss.css\';', + ]; // Remote style sheet part 3. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Remote_style_sheet_part_3 - $data[] = ['<META HTTP-EQUIV="Link" Content="<http://ha.ckers.org/xss.css>; REL=stylesheet">', '<META http-equiv="Link">; REL=stylesheet">']; + $data[] = [ + '<META HTTP-EQUIV="Link" Content="<http://ha.ckers.org/xss.css>; REL=stylesheet">', + '<META http-equiv="Link">; REL=stylesheet">', + ]; // Remote style sheet part 4. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Remote_style_sheet_part_4 - $data[] = ['<STYLE>BODY{-moz-binding:url("http://ha.ckers.org/xssmoz.xml#xss")}</STYLE>', 'BODY{-moz-binding:url("http://ha.ckers.org/xssmoz.xml#xss")}']; + $data[] = [ + '<STYLE>BODY{-moz-binding:url("http://ha.ckers.org/xssmoz.xml#xss")}</STYLE>', + 'BODY{-moz-binding:url("http://ha.ckers.org/xssmoz.xml#xss")}', + ]; // STYLE tags with broken up JavaScript for XSS. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#STYLE_tags_with_broken_up_JavaScript_for_XSS - $data[] = ['<STYLE>@im\port\'\ja\vasc\ript:alert("XSS")\';</STYLE>', '@im\port\'\ja\vasc\ript:alert("XSS")\';']; + $data[] = [ + '<STYLE>@im\port\'\ja\vasc\ript:alert("XSS")\';</STYLE>', + '@im\port\'\ja\vasc\ript:alert("XSS")\';', + ]; // STYLE attribute using a comment to break up expression. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#STYLE_attribute_using_a_comment_to_break_up_expression @@ -375,15 +465,24 @@ public static function providerTestFilterXss() { // STYLE tag (Older versions of Netscape only). // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#STYLE_tag_.28Older_versions_of_Netscape_only.29 - $data[] = ['<STYLE TYPE="text/javascript">alert(\'XSS\');</STYLE>', 'alert(\'XSS\');']; + $data[] = [ + '<STYLE TYPE="text/javascript">alert(\'XSS\');</STYLE>', + 'alert(\'XSS\');', + ]; // STYLE tag using background-image. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#STYLE_tag_using_background-image - $data[] = ['<STYLE>.XSS{background-image:url("javascript:alert(\'XSS\')");}</STYLE><A CLASS=XSS></A>', '.XSS{background-image:url("javascript:alert(\'XSS\')");}<A class="XSS"></A>']; + $data[] = [ + '<STYLE>.XSS{background-image:url("javascript:alert(\'XSS\')");}</STYLE><A CLASS=XSS></A>', + '.XSS{background-image:url("javascript:alert(\'XSS\')");}<A class="XSS"></A>', + ]; // STYLE tag using background. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#STYLE_tag_using_background - $data[] = ['<STYLE type="text/css">BODY{background:url("javascript:alert(\'XSS\')")}</STYLE>', 'BODY{background:url("javascript:alert(\'XSS\')")}']; + $data[] = [ + '<STYLE type="text/css">BODY{background:url("javascript:alert(\'XSS\')")}</STYLE>', + 'BODY{background:url("javascript:alert(\'XSS\')")}', + ]; // Anonymous HTML with STYLE attribute. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Anonymous_HTML_with_STYLE_attribute @@ -399,47 +498,80 @@ public static function providerTestFilterXss() { // META. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#META - $data[] = ['<META HTTP-EQUIV="refresh" CONTENT="0;url=javascript:alert(\'XSS\');">', '<META http-equiv="refresh" content="alert('XSS');">']; + $data[] = [ + '<META HTTP-EQUIV="refresh" CONTENT="0;url=javascript:alert(\'XSS\');">', + '<META http-equiv="refresh" content="alert('XSS');">', + ]; // META using data. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#META_using_data - $data[] = ['<META HTTP-EQUIV="refresh" CONTENT="0;url=data:text/html base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">', '<META http-equiv="refresh" content="text/html base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">']; + $data[] = [ + '<META HTTP-EQUIV="refresh" CONTENT="0;url=data:text/html base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">', + '<META http-equiv="refresh" content="text/html base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">', + ]; // META with additional URL parameter // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#META - $data[] = ['<META HTTP-EQUIV="refresh" CONTENT="0; URL=http://;URL=javascript:alert(\'XSS\');">', '<META http-equiv="refresh" content="//;URL=javascript:alert('XSS');">']; + $data[] = [ + '<META HTTP-EQUIV="refresh" CONTENT="0; URL=http://;URL=javascript:alert(\'XSS\');">', + '<META http-equiv="refresh" content="//;URL=javascript:alert('XSS');">', + ]; // IFRAME. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#IFRAME - $data[] = ['<IFRAME SRC="javascript:alert(\'XSS\');"></IFRAME>', '<IFRAME src="alert('XSS');"></IFRAME>']; + $data[] = [ + '<IFRAME SRC="javascript:alert(\'XSS\');"></IFRAME>', + '<IFRAME src="alert('XSS');"></IFRAME>', + ]; // IFRAME Event based. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#IFRAME_Event_based - $data[] = ['<IFRAME SRC=# onmouseover="alert(document.cookie)"></IFRAME>', '<IFRAME src="#"></IFRAME>']; + $data[] = [ + '<IFRAME SRC=# onmouseover="alert(document.cookie)"></IFRAME>', + '<IFRAME src="#"></IFRAME>', + ]; // FRAME. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#FRAME - $data[] = ['<FRAMESET><FRAME SRC="javascript:alert(\'XSS\');"></FRAMESET>', '<FRAMESET><FRAME src="alert('XSS');"></FRAMESET>']; + $data[] = [ + '<FRAMESET><FRAME SRC="javascript:alert(\'XSS\');"></FRAMESET>', + '<FRAMESET><FRAME src="alert('XSS');"></FRAMESET>', + ]; // TABLE. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#TABLE - $data[] = ['<TABLE BACKGROUND="javascript:alert(\'XSS\')">', '<TABLE background="alert('XSS')">']; + $data[] = [ + '<TABLE BACKGROUND="javascript:alert(\'XSS\')">', + '<TABLE background="alert('XSS')">', + ]; // TD. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#TD - $data[] = ['<TABLE><TD BACKGROUND="javascript:alert(\'XSS\')">', '<TABLE><TD background="alert('XSS')">']; + $data[] = [ + '<TABLE><TD BACKGROUND="javascript:alert(\'XSS\')">', + '<TABLE><TD background="alert('XSS')">', + ]; // DIV background-image. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#DIV_background-image - $data[] = ['<DIV STYLE="background-image: url(javascript:alert(\'XSS\'))">', '<DIV>']; + $data[] = [ + '<DIV STYLE="background-image: url(javascript:alert(\'XSS\'))">', + '<DIV>', + ]; // DIV background-image with unicoded XSS exploit. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#DIV_background-image_with_unicoded_XSS_exploit - $data[] = ['<DIV STYLE="background-image:\0075\0072\006C\0028\'\006a\0061\0076\0061\0073\0063\0072\0069\0070\0074\003a\0061\006c\0065\0072\0074\0028.1027\0058.1053\0053\0027\0029\'\0029">', '<DIV>']; + $data[] = [ + '<DIV STYLE="background-image:\0075\0072\006C\0028\'\006a\0061\0076\0061\0073\0063\0072\0069\0070\0074\003a\0061\006c\0065\0072\0074\0028.1027\0058.1053\0053\0027\0029\'\0029">', + '<DIV>', + ]; // DIV background-image plus extra characters. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#DIV_background-image_plus_extra_characters - $data[] = ['<DIV STYLE="background-image: url(javascript:alert(\'XSS\'))">', '<DIV>']; + $data[] = [ + '<DIV STYLE="background-image: url(javascript:alert(\'XSS\'))">', + '<DIV>', + ]; // DIV expression. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#DIV_expression @@ -447,7 +579,8 @@ public static function providerTestFilterXss() { // Downlevel-Hidden block. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Downlevel-Hidden_block - $data[] = ['<!--[if gte IE 4]> + $data[] = [ + '<!--[if gte IE 4]> <SCRIPT>alert(\'XSS\');</SCRIPT> <![endif]-->', "\n alert('XSS');\n ", @@ -455,24 +588,39 @@ public static function providerTestFilterXss() { // BASE tag. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#BASE_tag - $data[] = ['<BASE HREF="javascript:alert(\'XSS\');//">', '<BASE href="alert('XSS');//">']; + $data[] = [ + '<BASE HREF="javascript:alert(\'XSS\');//">', + '<BASE href="alert('XSS');//">', + ]; // OBJECT tag. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#OBJECT_tag - $data[] = ['<OBJECT TYPE="text/x-scriptlet" DATA="http://ha.ckers.org/scriptlet.html"></OBJECT>', '']; + $data[] = [ + '<OBJECT TYPE="text/x-scriptlet" DATA="http://ha.ckers.org/scriptlet.html"></OBJECT>', + '', + ]; // Using an EMBED tag you can embed a Flash movie that contains XSS. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Using_an_EMBED_tag_you_can_embed_a_Flash_movie_that_contains_XSS - $data[] = ['<EMBED SRC="http://ha.ckers.org/xss.swf" AllowScriptAccess="always"></EMBED>', '']; + $data[] = [ + '<EMBED SRC="http://ha.ckers.org/xss.swf" AllowScriptAccess="always"></EMBED>', + '', + ]; // You can EMBED SVG which can contain your XSS vector. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#You_can_EMBED_SVG_which_can_contain_your_XSS_vector - // cspell:disable-next-line - $data[] = ['<EMBED SRC="data:image/svg+xml;base64,PHN2ZyB4bWxuczpzdmc9Imh0dH A6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hs aW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjAiIHk9IjAiIHdpZHRoPSIxOTQiIGhlaWdodD0iMjAw IiBpZD0ieHNzIj48c2NyaXB0IHR5cGU9InRleHQvZWNtYXNjcmlwdCI+YWxlcnQoIlh TUyIpOzwvc2NyaXB0Pjwvc3ZnPg==" type="image/svg+xml" AllowScriptAccess="always"></EMBED>', '']; + $data[] = [ + // cspell:disable-next-line + '<EMBED SRC="data:image/svg+xml;base64,PHN2ZyB4bWxuczpzdmc9Imh0dH A6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hs aW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjAiIHk9IjAiIHdpZHRoPSIxOTQiIGhlaWdodD0iMjAw IiBpZD0ieHNzIj48c2NyaXB0IHR5cGU9InRleHQvZWNtYXNjcmlwdCI+YWxlcnQoIlh TUyIpOzwvc2NyaXB0Pjwvc3ZnPg==" type="image/svg+xml" AllowScriptAccess="always"></EMBED>', + '', + ]; // XML data island with CDATA obfuscation. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#XML_data_island_with_CDATA_obfuscation - $data[] = ['<XML ID="xss"><I><B><IMG SRC="javas<!-- -->cript:alert(\'XSS\')"></B></I></XML><SPAN DATASRC="#xss" DATAFLD="B" DATAFORMATAS="HTML"></SPAN>', '<XML id="xss"><I><B><IMG>cript:alert(\'XSS\')"></B></I></XML><SPAN datasrc="#xss" datafld="B" dataformatas="HTML"></SPAN>']; + $data[] = [ + '<XML ID="xss"><I><B><IMG SRC="javas<!-- -->cript:alert(\'XSS\')"></B></I></XML><SPAN DATASRC="#xss" DATAFLD="B" DATAFORMATAS="HTML"></SPAN>', + '<XML id="xss"><I><B><IMG>cript:alert(\'XSS\')"></B></I></XML><SPAN datasrc="#xss" datafld="B" dataformatas="HTML"></SPAN>', + ]; // Locally hosted XML with embedded JavaScript that is generated using an // XML data island. @@ -482,7 +630,10 @@ public static function providerTestFilterXss() { // HTML+TIME in XML. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#HTML.2BTIME_in_XML - $data[] = ['<?xml:namespace prefix="t" ns="urn:schemas-microsoft-com:time"><?import namespace="t" implementation="#default#time2"><t:set attributeName="innerHTML" to="XSS<SCRIPT DEFER>alert("XSS")</SCRIPT>">', '<?xml:namespace prefix="t" ns="urn:schemas-microsoft-com:time"><?import namespace="t" implementation="#default#time2"><t set attributename="innerHTML">alert("XSS")">']; + $data[] = [ + '<?xml:namespace prefix="t" ns="urn:schemas-microsoft-com:time"><?import namespace="t" implementation="#default#time2"><t:set attributeName="innerHTML" to="XSS<SCRIPT DEFER>alert("XSS")</SCRIPT>">', + '<?xml:namespace prefix="t" ns="urn:schemas-microsoft-com:time"><?import namespace="t" implementation="#default#time2"><t set attributename="innerHTML">alert("XSS")">', + ]; // Assuming you can only fit in a few characters and it filters against // ".js". @@ -496,7 +647,10 @@ public static function providerTestFilterXss() { // Cookie manipulation. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Cookie_manipulation - $data[] = ['<META HTTP-EQUIV="Set-Cookie" Content="UserID=<SCRIPT>alert(\'XSS\')</SCRIPT>">', '<META http-equiv="Set-Cookie">alert(\'XSS\')">']; + $data[] = [ + '<META HTTP-EQUIV="Set-Cookie" Content="UserID=<SCRIPT>alert(\'XSS\')</SCRIPT>">', + '<META http-equiv="Set-Cookie">alert(\'XSS\')">', + ]; // UTF-7 encoding. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#UTF-7_encoding @@ -504,13 +658,34 @@ public static function providerTestFilterXss() { // XSS using HTML quote encapsulation. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#XSS_using_HTML_quote_encapsulation - $data[] = ['<SCRIPT a=">" SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '" SRC="http://ha.ckers.org/xss.js">']; - $data[] = ['<SCRIPT =">" SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '" SRC="http://ha.ckers.org/xss.js">']; - $data[] = ['<SCRIPT a=">" \'\' SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '" \'\' SRC="http://ha.ckers.org/xss.js">']; - $data[] = ['<SCRIPT "a=\'>\'" SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '\'" SRC="http://ha.ckers.org/xss.js">']; - $data[] = ['<SCRIPT a=`>` SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '` SRC="http://ha.ckers.org/xss.js">']; - $data[] = ['<SCRIPT a=">\'>" SRC="http://ha.ckers.org/xss.js"></SCRIPT>', '\'>" SRC="http://ha.ckers.org/xss.js">']; - $data[] = ['<SCRIPT>document.write("<SCRI");</SCRIPT>PT SRC="http://ha.ckers.org/xss.js"></SCRIPT>', 'document.write("<SCRI>PT SRC="http://ha.ckers.org/xss.js">']; + $data[] = [ + '<SCRIPT a=">" SRC="http://ha.ckers.org/xss.js"></SCRIPT>', + '" SRC="http://ha.ckers.org/xss.js">', + ]; + $data[] = [ + '<SCRIPT =">" SRC="http://ha.ckers.org/xss.js"></SCRIPT>', + '" SRC="http://ha.ckers.org/xss.js">', + ]; + $data[] = [ + '<SCRIPT a=">" \'\' SRC="http://ha.ckers.org/xss.js"></SCRIPT>', + '" \'\' SRC="http://ha.ckers.org/xss.js">', + ]; + $data[] = [ + '<SCRIPT "a=\'>\'" SRC="http://ha.ckers.org/xss.js"></SCRIPT>', + '\'" SRC="http://ha.ckers.org/xss.js">', + ]; + $data[] = [ + '<SCRIPT a=`>` SRC="http://ha.ckers.org/xss.js"></SCRIPT>', + '` SRC="http://ha.ckers.org/xss.js">', + ]; + $data[] = [ + '<SCRIPT a=">\'>" SRC="http://ha.ckers.org/xss.js"></SCRIPT>', + '\'>" SRC="http://ha.ckers.org/xss.js">', + ]; + $data[] = [ + '<SCRIPT>document.write("<SCRI");</SCRIPT>PT SRC="http://ha.ckers.org/xss.js"></SCRIPT>', + 'document.write("<SCRI>PT SRC="http://ha.ckers.org/xss.js">', + ]; // URL string evasion. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#URL_string_evasion @@ -522,12 +697,21 @@ public static function providerTestFilterXss() { // @see \Drupal\editor\EditorXssFilter::filterXssDataAttributes() // The following two test cases verify that XSS attack vectors are filtered. - $data[] = ['<img src="butterfly.jpg" data-caption="<script>alert();</script>" />', '<img src="butterfly.jpg" data-caption="alert();">']; - $data[] = ['<img src="butterfly.jpg" data-caption="<EMBED SRC="http://ha.ckers.org/xss.swf" AllowScriptAccess="always"></EMBED>" />', '<img src="butterfly.jpg" data-caption>']; + $data[] = [ + '<img src="butterfly.jpg" data-caption="<script>alert();</script>" />', + '<img src="butterfly.jpg" data-caption="alert();">', + ]; + $data[] = [ + '<img src="butterfly.jpg" data-caption="<EMBED SRC="http://ha.ckers.org/xss.swf" AllowScriptAccess="always"></EMBED>" />', + '<img src="butterfly.jpg" data-caption>', + ]; // When including HTML-tags as visible content, they are double-escaped. // This test case ensures that we leave that content unchanged. - $data[] = ['<img src="butterfly.jpg" data-caption="&lt;script&gt;alert();&lt;/script&gt;" />', '<img src="butterfly.jpg" data-caption="&lt;script&gt;alert();&lt;/script&gt;">']; + $data[] = [ + '<img src="butterfly.jpg" data-caption="&lt;script&gt;alert();&lt;/script&gt;" />', + '<img src="butterfly.jpg" data-caption="&lt;script&gt;alert();&lt;/script&gt;">', + ]; return $data; } diff --git a/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php b/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php index 51e564c3599459922f29d8af99bba7db3c9758be..07f2b29dd663627abfdf92b601cfcc2e8b2ae21b 100644 --- a/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php +++ b/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php @@ -130,7 +130,11 @@ public function testCalculateDependencies(): void { $this->fieldTypePluginManager->expects($this->any()) ->method('getDefinition') ->with('test_field') - ->willReturn(['provider' => 'test_module', 'config_dependencies' => ['module' => ['test_module2']], 'class' => '\Drupal\Tests\field\Unit\DependencyFieldItem']); + ->willReturn([ + 'provider' => 'test_module', + 'config_dependencies' => ['module' => ['test_module2']], + 'class' => '\Drupal\Tests\field\Unit\DependencyFieldItem', + ]); $this->fieldStorage->expects($this->once()) ->method('getConfigDependencyName') @@ -178,7 +182,11 @@ public function testCalculateDependenciesIncorrectBundle(): void { $this->fieldTypePluginManager->expects($this->any()) ->method('getDefinition') ->with('test_field') - ->willReturn(['provider' => 'test_module', 'config_dependencies' => ['module' => ['test_module2']], 'class' => '\Drupal\Tests\field\Unit\DependencyFieldItem']); + ->willReturn([ + 'provider' => 'test_module', + 'config_dependencies' => ['module' => ['test_module2']], + 'class' => '\Drupal\Tests\field\Unit\DependencyFieldItem', + ]); $field = new FieldConfig([ 'field_name' => $this->fieldStorage->getName(), diff --git a/core/modules/filter/tests/src/Unit/FilterHtmlTest.php b/core/modules/filter/tests/src/Unit/FilterHtmlTest.php index 5566b3d683bb03b46594fc05e7e03d316bd26260..8d4c3aec9a5ab6a36cc91958c7c2c8129011abba 100644 --- a/core/modules/filter/tests/src/Unit/FilterHtmlTest.php +++ b/core/modules/filter/tests/src/Unit/FilterHtmlTest.php @@ -60,22 +60,55 @@ public static function providerFilterAttributes() { ['<p id="first" />', '<p></p>'], ['<p id="first" lang="en">text</p>', '<p lang="en">text</p>'], ['<p style="display: none;" />', '<p></p>'], - ['<code class="pretty invalid">foreach ($a as $b) {}</code>', '<code class="pretty">foreach ($a as $b) {}</code>'], - ['<code class="boring pretty">foreach ($a as $b) {}</code>', '<code class="boring pretty">foreach ($a as $b) {}</code>'], - ['<code class="boring pretty ">foreach ($a as $b) {}</code>', '<code class="boring pretty">foreach ($a as $b) {}</code>'], - ['<code class="invalid alpaca">foreach ($a as $b) {}</code>', '<code>foreach ($a as $b) {}</code>'], + [ + '<code class="pretty invalid">foreach ($a as $b) {}</code>', + '<code class="pretty">foreach ($a as $b) {}</code>', + ], + [ + '<code class="boring pretty">foreach ($a as $b) {}</code>', + '<code class="boring pretty">foreach ($a as $b) {}</code>', + ], + [ + '<code class="boring pretty ">foreach ($a as $b) {}</code>', + '<code class="boring pretty">foreach ($a as $b) {}</code>', + ], + [ + '<code class="invalid alpaca">foreach ($a as $b) {}</code>', + '<code>foreach ($a as $b) {}</code>', + ], ['<h3 class="big">a heading</h3>', '<h3>a heading</h3>'], ['<h3 id="first">a heading</h3>', '<h3 id="first">a heading</h3>'], // Wildcard value. Case matters, so upper case doesn't match. - ['<code class="align-left bold">foreach ($a as $b) {}</code>', '<code class="align-left">foreach ($a as $b) {}</code>'], - ['<code class="align-right ">foreach ($a as $b) {}</code>', '<code class="align-right">foreach ($a as $b) {}</code>'], - ['<code class="Align-right ">foreach ($a as $b) {}</code>', '<code>foreach ($a as $b) {}</code>'], + [ + '<code class="align-left bold">foreach ($a as $b) {}</code>', + '<code class="align-left">foreach ($a as $b) {}</code>', + ], + [ + '<code class="align-right ">foreach ($a as $b) {}</code>', + '<code class="align-right">foreach ($a as $b) {}</code>', + ], + [ + '<code class="Align-right ">foreach ($a as $b) {}</code>', + '<code>foreach ($a as $b) {}</code>', + ], // Wildcard name, case is ignored. - ['<ol style="display: none;" llama-wim="noble majestic"></ol>', '<ol llama-wim="noble majestic"></ol>'], - ['<ol style="display: none;" LlamA-Wim="majestic"></ol>', '<ol llama-wim="majestic"></ol>'], - ['<ol style="display: none;" llama-="noble majestic"></ol>', '<ol llama-="noble majestic"></ol>'], + [ + '<ol style="display: none;" llama-wim="noble majestic"></ol>', + '<ol llama-wim="noble majestic"></ol>', + ], + [ + '<ol style="display: none;" LlamA-Wim="majestic"></ol>', + '<ol llama-wim="majestic"></ol>', + ], + [ + '<ol style="display: none;" llama-="noble majestic"></ol>', + '<ol llama-="noble majestic"></ol>', + ], // Both wildcard names and values. - ['<ul style="display: none;" alpaca-wool="wooly-warm strong majestic"></ul>', '<ul alpaca-wool="wooly-warm strong"></ul>'], + [ + '<ul style="display: none;" alpaca-wool="wooly-warm strong majestic"></ul>', + '<ul alpaca-wool="wooly-warm strong"></ul>', + ], ]; } diff --git a/core/modules/jsonapi/tests/src/Unit/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php b/core/modules/jsonapi/tests/src/Unit/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php index 55c6a1ef0b9986a93e689536dda8111c64477990..7ac043710e97fef974f8b4917db4fb3d2882569f 100644 --- a/core/modules/jsonapi/tests/src/Unit/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php +++ b/core/modules/jsonapi/tests/src/Unit/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php @@ -123,7 +123,14 @@ public static function denormalizeProvider() { 'data' => [ 'type' => 'lorem', 'id' => '0676d1bf-55b3-4bbc-9fbc-3df10f4599d5', - 'relationships' => ['field_dummy' => ['data' => ['type' => 'node', 'id' => '76dd5c18-ea1b-4150-9e75-b21958a2b836']]], + 'relationships' => [ + 'field_dummy' => [ + 'data' => [ + 'type' => 'node', + 'id' => '76dd5c18-ea1b-4150-9e75-b21958a2b836', + ], + ], + ], ], ], [ diff --git a/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php b/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php index 89d27c9b06ad64c4d3b61e2b187e960015a36bcf..0784b457a125ac2bcbcb4d916f21c41268719b91 100644 --- a/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php +++ b/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php @@ -267,7 +267,8 @@ public function testDomain($http_host, $domains, $expected_langcode): void { $this->assertSame('foo', $method->processOutbound('foo', $options, $request, $cacheability)); $expected_cacheability = new BubbleableMetadata(); if ($expected_langcode !== FALSE && count($domains) > 1) { - $expected_cacheability->setCacheMaxAge(Cache::PERMANENT)->setCacheContexts(['languages:' . LanguageInterface::TYPE_URL, 'url.site']); + $expected_cacheability->setCacheMaxAge( + Cache::PERMANENT)->setCacheContexts(['languages:' . LanguageInterface::TYPE_URL, 'url.site']); } $this->assertEquals($expected_cacheability, $cacheability); } diff --git a/core/modules/locale/tests/src/Unit/LocaleLookupTest.php b/core/modules/locale/tests/src/Unit/LocaleLookupTest.php index 6e10c231b90301120597d3065bc282cda3d66954..9e646de9e487ca7efdf72de5c50fa3a6ebfb321a 100644 --- a/core/modules/locale/tests/src/Unit/LocaleLookupTest.php +++ b/core/modules/locale/tests/src/Unit/LocaleLookupTest.php @@ -119,7 +119,16 @@ public function testResolveCacheMissWithoutFallback(): void { ->willReturn($result); $locale_lookup = $this->getMockBuilder('Drupal\locale\LocaleLookup') - ->setConstructorArgs(['en', 'irrelevant', $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack]) + ->setConstructorArgs([ + 'en', + 'irrelevant', + $this->storage, + $this->cache, + $this->lock, + $this->configFactory, + $this->languageManager, + $this->requestStack, + ]) ->onlyMethods(['persist']) ->getMock(); $locale_lookup->expects($this->never()) @@ -237,7 +246,16 @@ public function testResolveCacheMissWithPersist(): void { $this->configFactory = $this->getConfigFactoryStub(['locale.settings' => ['cache_strings' => TRUE]]); $locale_lookup = $this->getMockBuilder('Drupal\locale\LocaleLookup') - ->setConstructorArgs(['en', 'irrelevant', $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack]) + ->setConstructorArgs([ + 'en', + 'irrelevant', + $this->storage, + $this->cache, + $this->lock, + $this->configFactory, + $this->languageManager, + $this->requestStack, + ]) ->onlyMethods(['persist']) ->getMock(); $locale_lookup->expects($this->once()) @@ -267,7 +285,16 @@ public function testResolveCacheMissNoTranslation(): void { $this->requestStack->push($request); $locale_lookup = $this->getMockBuilder('Drupal\locale\LocaleLookup') - ->setConstructorArgs(['en', 'irrelevant', $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack]) + ->setConstructorArgs([ + 'en', + 'irrelevant', + $this->storage, + $this->cache, + $this->lock, + $this->configFactory, + $this->languageManager, + $this->requestStack, + ]) ->onlyMethods(['persist']) ->getMock(); $locale_lookup->expects($this->never()) @@ -360,7 +387,16 @@ public function testGetCid(array $roles, $expected): void { \Drupal::setContainer($container); $locale_lookup = $this->getMockBuilder('Drupal\locale\LocaleLookup') - ->setConstructorArgs(['en', 'irrelevant', $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack]) + ->setConstructorArgs([ + 'en', + 'irrelevant', + $this->storage, + $this->cache, + $this->lock, + $this->configFactory, + $this->languageManager, + $this->requestStack, + ]) ->getMock(); $o = new \ReflectionObject($locale_lookup); diff --git a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php index e8fc47637ea71ee9202e8afe7224a259abb77402..b162742a2e35ff486e2a01b6cd8a7ccab49090e7 100644 --- a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php +++ b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php @@ -306,10 +306,22 @@ public function testMessageSave(): void { 4 => ['message' => $message, 'level' => MigrationInterface::MESSAGE_INFORMATIONAL], ]; $expected_results = [ - '7ad742edb7e866caa78ced1e4455d2e9cbd8adb2074e7c323d21b4e67732e755' => ['message' => $message, 'level' => MigrationInterface::MESSAGE_ERROR], - '2d3ec2b0c547e819346e6ae03f881fd9f5c978ff3cbe29dfb807d40735e53703' => ['message' => $message, 'level' => MigrationInterface::MESSAGE_WARNING], - '12a042f72cad9a2a8c7715df0c7695d762975f0687d87f5d480725dae1432a6f' => ['message' => $message, 'level' => MigrationInterface::MESSAGE_NOTICE], - 'd9d1fd27a2447ace48f47a2e9ff649673f67b446d9381a7963c949fc083f8791' => ['message' => $message, 'level' => MigrationInterface::MESSAGE_INFORMATIONAL], + '7ad742edb7e866caa78ced1e4455d2e9cbd8adb2074e7c323d21b4e67732e755' => [ + 'message' => $message, + 'level' => MigrationInterface::MESSAGE_ERROR, + ], + '2d3ec2b0c547e819346e6ae03f881fd9f5c978ff3cbe29dfb807d40735e53703' => [ + 'message' => $message, + 'level' => MigrationInterface::MESSAGE_WARNING, + ], + '12a042f72cad9a2a8c7715df0c7695d762975f0687d87f5d480725dae1432a6f' => [ + 'message' => $message, + 'level' => MigrationInterface::MESSAGE_NOTICE, + ], + 'd9d1fd27a2447ace48f47a2e9ff649673f67b446d9381a7963c949fc083f8791' => [ + 'message' => $message, + 'level' => MigrationInterface::MESSAGE_INFORMATIONAL, + ], ]; $id_map = $this->getIdMap(); @@ -360,7 +372,8 @@ public function testGetRowBySource(): void { $row = [ 'sourceid1' => 'source_id_value_3', 'sourceid2' => 'source_id_value_4', - 'source_ids_hash' => $this->getIdMap()->getSourceIdsHash(['source_id_property' => 'source_id_value_3', 'sourceid2' => 'source_id_value_4']), + 'source_ids_hash' => $this->getIdMap() + ->getSourceIdsHash(['source_id_property' => 'source_id_value_3', 'sourceid2' => 'source_id_value_4']), 'destid1' => 'destination_id_value_2', ] + $this->idMapDefaults(); $this->saveMap($row); @@ -521,9 +534,11 @@ public function testLookupDestinationIds(): void { // Lookup by partial associative list. $this->assertEquals([[101, 'en'], [101, 'fr'], [101, 'de']], $id_map->lookupDestinationIds(['nid' => 1])); $this->assertEquals([[102, 'en']], $id_map->lookupDestinationIds(['nid' => 2])); - $this->assertEquals([], $id_map->lookupDestinationIds(['nid' => 99])); - $this->assertEquals([[101, 'en'], [101, 'fr'], [101, 'de']], $id_map->lookupDestinationIds(['nid' => 1, 'language' => NULL])); $this->assertEquals([[102, 'en']], $id_map->lookupDestinationIds(['nid' => 2, 'language' => NULL])); + $this->assertEquals([], $id_map->lookupDestinationIds(['nid' => 99])); + $this->assertEquals( + [[101, 'en'], [101, 'fr'], [101, 'de']], + $id_map->lookupDestinationIds(['nid' => 1, 'language' => NULL])); // Out-of-order partial associative list. $this->assertEquals([[101, 'en'], [102, 'en']], $id_map->lookupDestinationIds(['language' => 'en'])); $this->assertEquals([[101, 'fr']], $id_map->lookupDestinationIds(['language' => 'fr'])); diff --git a/core/modules/migrate/tests/src/Unit/process/UrlEncodeTest.php b/core/modules/migrate/tests/src/Unit/process/UrlEncodeTest.php index 555b47ae76fc9e13fdeb1f706f03d187060d600f..4716e5cbbf8b97a55ee22fd62ac3b5c2bebac225 100644 --- a/core/modules/migrate/tests/src/Unit/process/UrlEncodeTest.php +++ b/core/modules/migrate/tests/src/Unit/process/UrlEncodeTest.php @@ -30,12 +30,30 @@ class UrlEncodeTest extends MigrateTestCase { */ public static function urlDataProvider() { return [ - 'A URL with no characters requiring encoding' => ['http://example.com/normal_url.html', 'http://example.com/normal_url.html'], - 'The definitive use case - encoding spaces in URLs' => ['http://example.com/url with spaces.html', 'http://example.com/url%20with%20spaces.html'], - 'Definitive use case 2 - spaces in directories' => ['http://example.com/dir with spaces/foo.html', 'http://example.com/dir%20with%20spaces/foo.html'], - 'Local file specs without spaces should not be transformed' => ['/tmp/normal.txt', '/tmp/normal.txt'], - 'Local file specs with spaces should not be transformed' => ['/tmp/with spaces.txt', '/tmp/with spaces.txt'], - 'Make sure URL characters (:, ?, &) are not encoded but others are.' => ['https://example.com/?a=b@c&d=e+f%', 'https://example.com/?a%3Db%40c&d%3De%2Bf%25'], + 'A URL with no characters requiring encoding' => [ + 'http://example.com/normal_url.html', + 'http://example.com/normal_url.html', + ], + 'The definitive use case - encoding spaces in URLs' => [ + 'http://example.com/url with spaces.html', + 'http://example.com/url%20with%20spaces.html', + ], + 'Definitive use case 2 - spaces in directories' => [ + 'http://example.com/dir with spaces/foo.html', + 'http://example.com/dir%20with%20spaces/foo.html', + ], + 'Local file specs without spaces should not be transformed' => [ + '/tmp/normal.txt', + '/tmp/normal.txt', + ], + 'Local file specs with spaces should not be transformed' => [ + '/tmp/with spaces.txt', + '/tmp/with spaces.txt', + ], + 'Make sure URL characters (:, ?, &) are not encoded but others are.' => [ + 'https://example.com/?a=b@c&d=e+f%', + 'https://example.com/?a%3Db%40c&d%3De%2Bf%25', + ], ]; } diff --git a/core/modules/pgsql/tests/src/Unit/SchemaTest.php b/core/modules/pgsql/tests/src/Unit/SchemaTest.php index 9880bdbb4fb6fb14fe8fb9791be4999388e4649a..4a554a014de3c990c69c755076b108d1ea0adfcd 100644 --- a/core/modules/pgsql/tests/src/Unit/SchemaTest.php +++ b/core/modules/pgsql/tests/src/Unit/SchemaTest.php @@ -53,7 +53,11 @@ public static function providerComputedConstraintName() { return [ ['user_field_data', 'pkey', 'user_field_data____pkey'], ['user_field_data', 'name__key', 'user_field_data__name__key'], - ['user_field_data', 'a_very_very_very_very_super_long_field_name__key', 'drupal_WW_a8TlbZ3UQi20UTtRlJFaIeSa6FEtQS5h4NRA3UeU_key'], + [ + 'user_field_data', + 'a_very_very_very_very_super_long_field_name__key', + 'drupal_WW_a8TlbZ3UQi20UTtRlJFaIeSa6FEtQS5h4NRA3UeU_key', + ], ]; } diff --git a/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php b/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php index 86537ed3f582e621cae8ebbf61d64b30f94fde4a..8c3cb279e9d06b17e7573704bd01c8d5ca3b7c20 100644 --- a/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php +++ b/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php @@ -95,7 +95,10 @@ public function testCalculateDependencies(): void { $entity = new ResponsiveImageStyle(['breakpoint_group' => 'test_group']); $entity->setBreakpointGroup('test_group'); $entity->setFallbackImageStyle('fallback'); - $entity->addImageStyleMapping('test_breakpoint', '1x', ['image_mapping_type' => 'image_style', 'image_mapping' => 'small']); + $entity->addImageStyleMapping('test_breakpoint', '1x', [ + 'image_mapping_type' => 'image_style', + 'image_mapping' => 'small', + ]); $entity->addImageStyleMapping('test_breakpoint', '2x', [ 'image_mapping_type' => 'sizes', 'image_mapping' => [ diff --git a/core/modules/rest/tests/src/Unit/Plugin/views/style/SerializerTest.php b/core/modules/rest/tests/src/Unit/Plugin/views/style/SerializerTest.php index d01df6eb2d828af5fe91186c760e486e49ed1784..f3a417c47f784679d9734c2b9dc19509d0be06e9 100644 --- a/core/modules/rest/tests/src/Unit/Plugin/views/style/SerializerTest.php +++ b/core/modules/rest/tests/src/Unit/Plugin/views/style/SerializerTest.php @@ -65,12 +65,19 @@ public function testSerializerReceivesOptions(): void { // This is the main expectation of the test. We want to make sure the // serializer options are passed to the SerializerInterface object. $mock_serializer->serialize([], 'json', Argument::that(function ($argument) { - return isset($argument['views_style_plugin']) && $argument['views_style_plugin'] instanceof Serializer; + return isset($argument['views_style_plugin']) + && $argument['views_style_plugin'] instanceof Serializer; })) ->willReturn('') ->shouldBeCalled(); - $view_serializer_style = new Serializer([], 'dummy_serializer', [], $mock_serializer->reveal(), ['json', 'xml'], ['json' => 'serialization', 'xml' => 'serialization']); + $view_serializer_style = new Serializer( + [], + 'dummy_serializer', + [], + $mock_serializer->reveal(), + ['json', 'xml'], + ['json' => 'serialization', 'xml' => 'serialization']); $view_serializer_style->options = ['formats' => ['xml', 'json']]; $view_serializer_style->view = $this->view; $view_serializer_style->displayHandler = $this->displayHandler; diff --git a/core/modules/search/tests/src/Unit/SearchPluginCollectionTest.php b/core/modules/search/tests/src/Unit/SearchPluginCollectionTest.php index 80b043ea5168ef32fb7cce39ef83339ae640dc4d..660b11352cea19413070938238caecaf848598bc 100644 --- a/core/modules/search/tests/src/Unit/SearchPluginCollectionTest.php +++ b/core/modules/search/tests/src/Unit/SearchPluginCollectionTest.php @@ -41,7 +41,11 @@ protected function setUp(): void { parent::setUp(); $this->pluginManager = $this->createMock('Drupal\Component\Plugin\PluginManagerInterface'); - $this->searchPluginCollection = new SearchPluginCollection($this->pluginManager, 'banana', ['id' => 'banana', 'color' => 'yellow'], 'fruit_stand'); + $this->searchPluginCollection = new SearchPluginCollection( + $this->pluginManager, + 'banana', + ['id' => 'banana', 'color' => 'yellow'], + 'fruit_stand'); } /** diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeNormalizerTest.php index 2737f367bfe274928c2f8f422c52f2242ab40f6b..3527c5ef6ffdaaa98b898d63cbf59dacde1947b9 100644 --- a/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeNormalizerTest.php +++ b/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeNormalizerTest.php @@ -160,9 +160,21 @@ public function testDenormalizeUserFormats($normalized, $format, $expected): voi public static function providerTestDenormalizeUserFormats() { $data = []; - $data['Y/m/d H:i:s P'] = ['2016/11/06 09:02:00 +00:00', 'Y/m/d H:i:s P', new \DateTimeImmutable('2016-11-06T09:02:00+00:00')]; - $data['H:i:s Y/m/d P'] = ['09:02:00 2016/11/06 +01:00', 'H:i:s Y/m/d P', new \DateTimeImmutable('2016-11-06T09:02:00+01:00')]; - $data['Y/m/d H:i:s'] = ['09:02:00 2016/11/06', 'H:i:s Y/m/d', new \DateTimeImmutable('2016-11-06T09:02:00+11:00')]; + $data['Y/m/d H:i:s P'] = [ + '2016/11/06 09:02:00 +00:00', + 'Y/m/d H:i:s P', + new \DateTimeImmutable('2016-11-06T09:02:00+00:00'), + ]; + $data['H:i:s Y/m/d P'] = [ + '09:02:00 2016/11/06 +01:00', + 'H:i:s Y/m/d P', + new \DateTimeImmutable('2016-11-06T09:02:00+01:00'), + ]; + $data['Y/m/d H:i:s'] = [ + '09:02:00 2016/11/06', + 'H:i:s Y/m/d', + new \DateTimeImmutable('2016-11-06T09:02:00+11:00'), + ]; return $data; } diff --git a/core/modules/system/tests/src/Unit/Event/SecurityFileUploadEventSubscriberTest.php b/core/modules/system/tests/src/Unit/Event/SecurityFileUploadEventSubscriberTest.php index 8c92f8d05afadb87bff3befa99f1b20cf997cb50..79b9f52812e80db61f3c2e2bb9921993bfa05596 100644 --- a/core/modules/system/tests/src/Unit/Event/SecurityFileUploadEventSubscriberTest.php +++ b/core/modules/system/tests/src/Unit/Event/SecurityFileUploadEventSubscriberTest.php @@ -147,9 +147,18 @@ public static function provideFilenamesNoMunge() { // The following filename would be rejected by 'FileExtension' constraint // and therefore remains unchanged. '.php is not munged when it would be rejected' => ['foo.php.php', 'jpg'], - '.php is not munged when it would be rejected and filename contains null byte character' => ['foo.' . chr(0) . 'php.php', 'jpg'], - 'extension less files are not munged when they would be rejected' => ['foo', 'jpg'], - 'dot files are not munged when they would be rejected' => ['.htaccess', 'jpg png'], + '.php is not munged when it would be rejected and filename contains null byte character' => [ + 'foo.' . chr(0) . 'php.php', + 'jpg', + ], + 'extension less files are not munged when they would be rejected' => [ + 'foo', + 'jpg', + ], + 'dot files are not munged when they would be rejected' => [ + '.htaccess', + 'jpg png', + ], ]; } diff --git a/core/modules/system/tests/src/Unit/Menu/MenuLinkTreeTest.php b/core/modules/system/tests/src/Unit/Menu/MenuLinkTreeTest.php index da1865e0fefe39ac9fbdc208a0f4e27a21c3358c..51a9bd0e38d416a8caf4f48dd06a5a1d728c8fe9 100644 --- a/core/modules/system/tests/src/Unit/Menu/MenuLinkTreeTest.php +++ b/core/modules/system/tests/src/Unit/Menu/MenuLinkTreeTest.php @@ -176,12 +176,31 @@ public static function providerTestBuildCacheability() { $cache_defaults = ['cache_max_age' => Cache::PERMANENT, 'cache_tags' => []]; $links_scenarios = [ [ - MenuLinkMock::create(['id' => 'test.example1', 'route_name' => 'example1', 'title' => 'Example 1']), - MenuLinkMock::create(['id' => 'test.example2', 'route_name' => 'example1', 'title' => 'Example 2', 'metadata' => ['cache_contexts' => ['llama']] + $cache_defaults]), + MenuLinkMock::create([ + 'id' => 'test.example1', + 'route_name' => 'example1', + 'title' => 'Example 1', + ]), + MenuLinkMock::create([ + 'id' => 'test.example2', + 'route_name' => 'example1', + 'title' => 'Example 2', + 'metadata' => ['cache_contexts' => ['llama']] + $cache_defaults, + ]), ], [ - MenuLinkMock::create(['id' => 'test.example1', 'route_name' => 'example1', 'title' => 'Example 1', 'metadata' => ['cache_contexts' => ['foo']] + $cache_defaults]), - MenuLinkMock::create(['id' => 'test.example2', 'route_name' => 'example1', 'title' => 'Example 2', 'metadata' => ['cache_contexts' => ['bar']] + $cache_defaults]), + MenuLinkMock::create([ + 'id' => 'test.example1', + 'route_name' => 'example1', + 'title' => 'Example 1', + 'metadata' => ['cache_contexts' => ['foo']] + $cache_defaults, + ]), + MenuLinkMock::create([ + 'id' => 'test.example2', + 'route_name' => 'example1', + 'title' => 'Example 2', + 'metadata' => ['cache_contexts' => ['bar']] + $cache_defaults, + ]), ], ]; @@ -244,9 +263,21 @@ public static function providerTestBuildCacheability() { ]; // Multi-level tree. - $multi_level_root_a = MenuLinkMock::create(['id' => 'test.root_a', 'route_name' => 'root_a', 'title' => 'Root A']); - $multi_level_root_b = MenuLinkMock::create(['id' => 'test.root_b', 'route_name' => 'root_b', 'title' => 'Root B']); - $multi_level_parent_c = MenuLinkMock::create(['id' => 'test.parent_c', 'route_name' => 'parent_c', 'title' => 'Parent C']); + $multi_level_root_a = MenuLinkMock::create([ + 'id' => 'test.root_a', + 'route_name' => 'root_a', + 'title' => 'Root A', + ]); + $multi_level_root_b = MenuLinkMock::create([ + 'id' => 'test.root_b', + 'route_name' => 'root_b', + 'title' => 'Root B', + ]); + $multi_level_parent_c = MenuLinkMock::create([ + 'id' => 'test.parent_c', + 'route_name' => 'parent_c', + 'title' => 'Parent C', + ]); $tree = [ new MenuLinkTreeElement($multi_level_root_a, TRUE, 0, FALSE, [ new MenuLinkTreeElement($multi_level_parent_c, TRUE, 0, FALSE, [ diff --git a/core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php b/core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php index 922e7aef2c46e6720913c610879c914bc0febd0a..251e0938c87dd7eb2654452431eda95e9888390b 100644 --- a/core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php +++ b/core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php @@ -44,9 +44,39 @@ public function testUserAdminLocalTasks($route, $expected): void { */ public static function getUserAdminRoutes() { return [ - ['entity.user.collection', [['entity.user.collection', 'user.admin_permissions', 'entity.user_role.collection', 'user.role.settings']]], - ['user.admin_permissions', [['entity.user.collection', 'user.admin_permissions', 'entity.user_role.collection', 'user.role.settings']]], - ['entity.user_role.collection', [['entity.user.collection', 'user.admin_permissions', 'entity.user_role.collection', 'user.role.settings']]], + [ + 'entity.user.collection', + [ + [ + 'entity.user.collection', + 'user.admin_permissions', + 'entity.user_role.collection', + 'user.role.settings', + ], + ], + ], + [ + 'user.admin_permissions', + [ + [ + 'entity.user.collection', + 'user.admin_permissions', + 'entity.user_role.collection', + 'user.role.settings', + ], + ], + ], + [ + 'entity.user_role.collection', + [ + [ + 'entity.user.collection', + 'user.admin_permissions', + 'entity.user_role.collection', + 'user.role.settings', + ], + ], + ], ['entity.user.admin_form', [['user.account_settings_tab']]], ]; } diff --git a/core/modules/user/tests/src/Unit/PermissionAccessCheckTest.php b/core/modules/user/tests/src/Unit/PermissionAccessCheckTest.php index e1e80dba56c82c27e87340592bb44122a0652f1a..7071543c7aff808819027b7d324556f6ec6dcfd6 100644 --- a/core/modules/user/tests/src/Unit/PermissionAccessCheckTest.php +++ b/core/modules/user/tests/src/Unit/PermissionAccessCheckTest.php @@ -58,10 +58,20 @@ public static function providerTestAccess() { return [ [[], FALSE], [['_permission' => 'allowed'], TRUE, ['user.permissions']], - [['_permission' => 'denied'], FALSE, ['user.permissions'], "The 'denied' permission is required."], + [ + ['_permission' => 'denied'], + FALSE, + ['user.permissions'], + "The 'denied' permission is required.", + ], [['_permission' => 'allowed+denied'], TRUE, ['user.permissions']], [['_permission' => 'allowed+denied+other'], TRUE, ['user.permissions']], - [['_permission' => 'allowed,denied'], FALSE, ['user.permissions'], "The following permissions are required: 'allowed' AND 'denied'."], + [ + ['_permission' => 'allowed,denied'], + FALSE, + ['user.permissions'], + "The following permissions are required: 'allowed' AND 'denied'.", + ], ]; } diff --git a/core/modules/user/tests/src/Unit/PermissionHandlerTest.php b/core/modules/user/tests/src/Unit/PermissionHandlerTest.php index ee2e80837f4977c2fcc02aaa606672758d1df389..0a46196d1d46ef7b7e9bb250767b08fcabd7c385 100644 --- a/core/modules/user/tests/src/Unit/PermissionHandlerTest.php +++ b/core/modules/user/tests/src/Unit/PermissionHandlerTest.php @@ -253,10 +253,22 @@ public function testBuildPermissionsYamlCallback(): void { $this->callableResolver->expects($this->exactly(4)) ->method('getCallableFromDefinition') ->willReturnMap([ - ['Drupal\\user\\Tests\\TestPermissionCallbacks::singleDescription', [new TestPermissionCallbacks(), 'singleDescription']], - ['Drupal\\user\\Tests\\TestPermissionCallbacks::titleDescription', [new TestPermissionCallbacks(), 'titleDescription']], - ['Drupal\\user\\Tests\\TestPermissionCallbacks::titleProvider', [new TestPermissionCallbacks(), 'titleProvider']], - ['Drupal\\user\\Tests\\TestPermissionCallbacks::titleDescriptionRestrictAccess', [new TestPermissionCallbacks(), 'titleDescriptionRestrictAccess']], + [ + 'Drupal\\user\\Tests\\TestPermissionCallbacks::singleDescription', + [new TestPermissionCallbacks(), 'singleDescription'], + ], + [ + 'Drupal\\user\\Tests\\TestPermissionCallbacks::titleDescription', + [new TestPermissionCallbacks(), 'titleDescription'], + ], + [ + 'Drupal\\user\\Tests\\TestPermissionCallbacks::titleProvider', + [new TestPermissionCallbacks(), 'titleProvider'], + ], + [ + 'Drupal\\user\\Tests\\TestPermissionCallbacks::titleDescriptionRestrictAccess', + [new TestPermissionCallbacks(), 'titleDescriptionRestrictAccess'], + ], ]); $module_extension_list = $this->createMock(ModuleExtensionList::class); diff --git a/core/modules/user/tests/src/Unit/Plugin/Validation/Constraint/UserMailRequiredValidatorTest.php b/core/modules/user/tests/src/Unit/Plugin/Validation/Constraint/UserMailRequiredValidatorTest.php index 8cbd25fe5bee931829b4ab941943ced5d1134daf..2adbfe034df6998ff4a6361abd71e0de3a0fcb44 100644 --- a/core/modules/user/tests/src/Unit/Plugin/Validation/Constraint/UserMailRequiredValidatorTest.php +++ b/core/modules/user/tests/src/Unit/Plugin/Validation/Constraint/UserMailRequiredValidatorTest.php @@ -148,7 +148,11 @@ public static function providerTestValidate() { $account->getFieldDefinition("mail")->willReturn($field_definition->reveal())->shouldBeCalledTimes(1); $items->getEntity()->willReturn($account->reveal())->shouldBeCalledTimes(1); $items->isEmpty()->willReturn(TRUE); - $cases['Existing users without an email should be ignored if the current user is an administrator.'] = [$items->reveal(), FALSE, TRUE]; + $cases['Existing users without an email should be ignored if the current user is an administrator.'] = [ + $items->reveal(), + FALSE, + TRUE, + ]; return $cases; } diff --git a/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php b/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php index 7cd391c654d029f022734d418e167aa1fadf069d..bfdded9345de1097b4e03b512471f98f4de2f0d8 100644 --- a/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php +++ b/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php @@ -80,7 +80,9 @@ public function testRouteRebuildFinished(): void { $this->state->expects($this->once()) ->method('set') - ->with('views.view_route_names', ['test_id.page_1' => 'views.test_id.page_1', 'test_id.page_2' => 'views.test_id.page_2']); + ->with( + 'views.view_route_names', + ['test_id.page_1' => 'views.test_id.page_1', 'test_id.page_2' => 'views.test_id.page_2']); $this->routeSubscriber->routeRebuildFinished(); } diff --git a/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php b/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php index 6ff9fe991f17531a0453d33617f25e2efd4bc4c7..c7dbd103ea10df83980b1a22200b8e88c5298442 100644 --- a/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php @@ -154,7 +154,14 @@ protected function setUp(): void { */ public function testBuild(): void { $output = $this->randomMachineName(100); - $build = ['view_build' => $output, '#view_id' => 'test_view', '#view_display_plugin_class' => '\Drupal\views\Plugin\views\display\Block', '#view_display_show_admin_links' => FALSE, '#view_display_plugin_id' => 'block', '#pre_rendered' => TRUE]; + $build = [ + 'view_build' => $output, + '#view_id' => 'test_view', + '#view_display_plugin_class' => '\Drupal\views\Plugin\views\display\Block', + '#view_display_show_admin_links' => FALSE, + '#view_display_plugin_id' => 'block', + '#pre_rendered' => TRUE, + ]; $this->executable->expects($this->once()) ->method('buildRenderable') ->with('block_1', []) @@ -246,7 +253,15 @@ public static function providerTestCacheableMetadata(): array { * @covers ::build */ public function testBuildEmpty(): void { - $build = ['view_build' => [], '#view_id' => 'test_view', '#view_display_plugin_class' => '\Drupal\views\Plugin\views\display\Block', '#view_display_show_admin_links' => FALSE, '#view_display_plugin_id' => 'block', '#pre_rendered' => TRUE, '#cache' => ['contexts' => ['user']]]; + $build = [ + 'view_build' => [], + '#view_id' => 'test_view', + '#view_display_plugin_class' => '\Drupal\views\Plugin\views\display\Block', + '#view_display_show_admin_links' => FALSE, + '#view_display_plugin_id' => 'block', + '#pre_rendered' => TRUE, + '#cache' => ['contexts' => ['user']], + ]; $this->executable->expects($this->once()) ->method('buildRenderable') ->with('block_1', []) diff --git a/core/modules/views/tests/src/Unit/Plugin/HandlerBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/HandlerBaseTest.php index a0b0b81fb571aca00abd4916983c4fb856f151bb..e470d2b45e54d50d6c563bef8b22a9a70327a4df 100644 --- a/core/modules/views/tests/src/Unit/Plugin/HandlerBaseTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/HandlerBaseTest.php @@ -60,7 +60,13 @@ public function testGetEntityTypeForFieldWithRelationship(): void { $this->display->expects($this->atLeastOnce()) ->method('getOption') ->with('relationships') - ->willReturn(['test_relationship' => ['table' => 'test_entity_type_table', 'id' => 'test_relationship', 'field' => 'test_relationship']]); + ->willReturn([ + 'test_relationship' => [ + 'table' => 'test_entity_type_table', + 'id' => 'test_relationship', + 'field' => 'test_relationship', + ], + ]); $this->view->expects($this->any()) ->method('get') diff --git a/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php index 202de37e43d93a9cdeb97cba913fa06807cf3443..90951c4899db62d183c2e1fac64b145619dec5c7 100644 --- a/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php @@ -359,7 +359,12 @@ public function testGetRestRoute(): void { */ public function testAlterRouteWithAlterCallback(): void { $collection = new RouteCollection(); - $collection->add('test_route', new Route('test_route', ['_controller' => 'Drupal\Tests\Core\Controller\TestController::content', '_title_callback' => '\Drupal\Tests\views\Unit\Plugin\display\TestController::testTitle'])); + $collection->add('test_route', new Route( + 'test_route', + [ + '_controller' => 'Drupal\Tests\Core\Controller\TestController::content', + '_title_callback' => '\Drupal\Tests\views\Unit\Plugin\display\TestController::testTitle', + ])); $route_2 = new Route('test_route/example', ['_controller' => 'Drupal\Tests\Core\Controller\TestController::content']); $collection->add('test_route_2', $route_2); diff --git a/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php index a36a9cc1a4ee67554bc126c6681598bfbb05ea28..f2afff8e31dddd03b4c9e75565684c893080b042 100644 --- a/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php @@ -428,42 +428,84 @@ public static function providerTestRenderAsLinkWithUrlAndOptions() { // Simple URL with parameters. $url_parameters = Url::fromRoute('test_route', ['key' => 'value']); - $data[] = [$url_parameters, [], clone $url_parameters, '/test-path/value', clone $url_parameters, '<a href="/test-path/value">value</a>']; + $data[] = [ + $url_parameters, + [], + clone $url_parameters, + '/test-path/value', + clone $url_parameters, + '<a href="/test-path/value">value</a>', + ]; // Add a fragment. $url = Url::fromRoute('test_route'); $url_with_fragment = Url::fromRoute('test_route'); $options = ['fragment' => 'test'] + static::DEFAULT_URL_OPTIONS; $url_with_fragment->setOptions($options); - $data[] = [$url, ['fragment' => 'test'], $url_with_fragment, '/test-path#test', clone $url_with_fragment, '<a href="/test-path#test">value</a>']; + $data[] = [ + $url, + ['fragment' => 'test'], + $url_with_fragment, + '/test-path#test', + clone $url_with_fragment, + '<a href="/test-path#test">value</a>', + ]; // Rel attributes. $url = Url::fromRoute('test_route'); $url_with_rel = Url::fromRoute('test_route'); $options = ['attributes' => ['rel' => 'up']] + static::DEFAULT_URL_OPTIONS; $url_with_rel->setOptions($options); - $data[] = [$url, ['rel' => 'up'], clone $url, '/test-path', $url_with_rel, '<a href="/test-path" rel="up">value</a>']; + $data[] = [ + $url, + ['rel' => 'up'], + clone $url, + '/test-path', + $url_with_rel, + '<a href="/test-path" rel="up">value</a>', + ]; // Target attributes. $url = Url::fromRoute('test_route'); $url_with_target = Url::fromRoute('test_route'); $options = ['attributes' => ['target' => '_blank']] + static::DEFAULT_URL_OPTIONS; $url_with_target->setOptions($options); - $data[] = [$url, ['target' => '_blank'], $url_with_target, '/test-path', clone $url_with_target, '<a href="/test-path" target="_blank">value</a>']; + $data[] = [ + $url, + ['target' => '_blank'], + $url_with_target, + '/test-path', + clone $url_with_target, + '<a href="/test-path" target="_blank">value</a>', + ]; // Link attributes. $url = Url::fromRoute('test_route'); $url_with_link_attributes = Url::fromRoute('test_route'); $options = ['attributes' => ['foo' => 'bar']] + static::DEFAULT_URL_OPTIONS; $url_with_link_attributes->setOptions($options); - $data[] = [$url, ['link_attributes' => ['foo' => 'bar']], clone $url, '/test-path', $url_with_link_attributes, '<a href="/test-path" foo="bar">value</a>']; + $data[] = [ + $url, + ['link_attributes' => ['foo' => 'bar']], + clone $url, + '/test-path', + $url_with_link_attributes, + '<a href="/test-path" foo="bar">value</a>', + ]; // Manual specified query. $url = Url::fromRoute('test_route'); $url_with_query = Url::fromRoute('test_route'); $options = ['query' => ['foo' => 'bar']] + static::DEFAULT_URL_OPTIONS; $url_with_query->setOptions($options); - $data[] = [$url, ['query' => ['foo' => 'bar']], clone $url_with_query, '/test-path?foo=bar', $url_with_query, '<a href="/test-path?foo=bar">value</a>']; + $data[] = [ + $url, + ['query' => ['foo' => 'bar']], + clone $url_with_query, + '/test-path?foo=bar', + $url_with_query, + '<a href="/test-path?foo=bar">value</a>', + ]; // Query specified as part of the path. $url = Url::fromRoute('test_route')->setOption('query', ['foo' => 'bar']); @@ -476,14 +518,28 @@ public static function providerTestRenderAsLinkWithUrlAndOptions() { $url_with_query = Url::fromRoute('test_route'); $options = ['query' => ['key' => 'value']] + static::DEFAULT_URL_OPTIONS; $url_with_query->setOptions($options); - $data[] = [$url, ['query' => ['key' => 'value']], $url_with_query, '/test-path?key=value', clone $url_with_query, '<a href="/test-path?key=value">value</a>']; + $data[] = [ + $url, + ['query' => ['key' => 'value']], + $url_with_query, + '/test-path?key=value', + clone $url_with_query, + '<a href="/test-path?key=value">value</a>', + ]; // Alias flag. $url = Url::fromRoute('test_route'); $url_without_alias = Url::fromRoute('test_route'); $options = ['alias' => TRUE] + static::DEFAULT_URL_OPTIONS; $url_without_alias->setOptions($options); - $data[] = [$url, ['alias' => TRUE], $url_without_alias, '/test-path', clone $url_without_alias, '<a href="/test-path">value</a>']; + $data[] = [ + $url, + ['alias' => TRUE], + $url_without_alias, + '/test-path', + clone $url_without_alias, + '<a href="/test-path">value</a>', + ]; // Language flag. $language = new Language(['id' => 'fr']); @@ -491,7 +547,14 @@ public static function providerTestRenderAsLinkWithUrlAndOptions() { $url_with_language = Url::fromRoute('test_route'); $options = ['language' => $language] + static::DEFAULT_URL_OPTIONS; $url_with_language->setOptions($options); - $data[] = [$url, ['language' => $language], $url_with_language, '/fr/test-path', clone $url_with_language, '<a href="/fr/test-path" hreflang="fr">value</a>']; + $data[] = [ + $url, + ['language' => $language], + $url_with_language, + '/fr/test-path', + clone $url_with_language, + '<a href="/fr/test-path" hreflang="fr">value</a>', + ]; // Entity flag. $entity = (new Prophet())->prophesize(EntityInterface::class)->reveal(); @@ -499,7 +562,14 @@ public static function providerTestRenderAsLinkWithUrlAndOptions() { $url_with_entity = Url::fromRoute('test_route'); $options = ['entity' => $entity] + static::DEFAULT_URL_OPTIONS; $url_with_entity->setOptions($options); - $data[] = [$url, ['entity' => $entity], $url_with_entity, '/test-path', clone $url_with_entity, '<a href="/test-path">value</a>']; + $data[] = [ + $url, + ['entity' => $entity], + $url_with_entity, + '/test-path', + clone $url_with_entity, + '<a href="/test-path">value</a>', + ]; // Test entity_type flag. $entity_type_id = 'node'; @@ -507,15 +577,36 @@ public static function providerTestRenderAsLinkWithUrlAndOptions() { $url_with_entity_type = Url::fromRoute('test_route'); $options = ['entity_type' => $entity_type_id] + static::DEFAULT_URL_OPTIONS; $url_with_entity_type->setOptions($options); - $data[] = [$url, ['entity_type' => $entity_type_id], $url_with_entity_type, '/test-path', clone $url_with_entity_type, '<a href="/test-path">value</a>']; + $data[] = [ + $url, + ['entity_type' => $entity_type_id], + $url_with_entity_type, + '/test-path', + clone $url_with_entity_type, + '<a href="/test-path">value</a>', + ]; // Test prefix. $url = Url::fromRoute('test_route'); - $data[] = [$url, ['prefix' => 'test_prefix'], clone $url, '/test-path', clone $url, 'test_prefix<a href="/test-path">value</a>']; + $data[] = [ + $url, + ['prefix' => 'test_prefix'], + clone $url, + '/test-path', + clone $url, + 'test_prefix<a href="/test-path">value</a>', + ]; // Test suffix. $url = Url::fromRoute('test_route'); - $data[] = [$url, ['suffix' => 'test_suffix'], clone $url, '/test-path', clone $url, '<a href="/test-path">value</a>test_suffix']; + $data[] = [ + $url, + ['suffix' => 'test_suffix'], + clone $url, + '/test-path', + clone $url, + '<a href="/test-path">value</a>test_suffix', + ]; return $data; } @@ -628,10 +719,30 @@ public function testRenderAsExternalLinkWithPathAndTokens($path, $tokens, $link_ public static function providerTestRenderAsExternalLinkWithPathAndTokens() { $data = []; - $data[] = ['{{ foo }}', ['{{ foo }}' => 'http://www.example.com'], '<a href="http://www.example.com">value</a>', ['context_path' => 'http://www.example.com']]; - $data[] = ['{{ foo }}', ['{{ foo }}' => ''], 'value', ['context_path' => '']]; - $data[] = ['{{ foo }}', ['{{ foo }}' => ''], 'value', ['context_path' => '', 'alter' => ['external' => TRUE]]]; - $data[] = ['{{ foo }}', ['{{ foo }}' => '/test-path/123'], '<a href="/test-path/123">value</a>', ['context_path' => '/test-path/123']]; + $data[] = [ + '{{ foo }}', + ['{{ foo }}' => 'http://www.example.com'], + '<a href="http://www.example.com">value</a>', + ['context_path' => 'http://www.example.com'], + ]; + $data[] = [ + '{{ foo }}', + ['{{ foo }}' => ''], + 'value', + ['context_path' => ''], + ]; + $data[] = [ + '{{ foo }}', + ['{{ foo }}' => ''], + 'value', + ['context_path' => '', 'alter' => ['external' => TRUE]], + ]; + $data[] = [ + '{{ foo }}', + ['{{ foo }}' => '/test-path/123'], + '<a href="/test-path/123">value</a>', + ['context_path' => '/test-path/123'], + ]; return $data; } diff --git a/core/modules/views/tests/src/Unit/Plugin/views/query/SqliteDateSqlTest.php b/core/modules/views/tests/src/Unit/Plugin/views/query/SqliteDateSqlTest.php index d66c4c68a1a3a2898293e7c6bc1d8d291cb3951c..95ee740703186269241f79f5d0b077bcc3f3d09e 100644 --- a/core/modules/views/tests/src/Unit/Plugin/views/query/SqliteDateSqlTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/views/query/SqliteDateSqlTest.php @@ -67,10 +67,26 @@ public function testGetDateFormat($field, $format, $expected): void { */ public static function providerTestGetDateFormat() { return [ - ['foo.field', 'Y-y-M-m', "strftime('%Y-%Y-%m-%m', foo.field, 'unixepoch')"], - ['bar.field', 'n-F D d l', "strftime('%m-%m %d %d %d', bar.field, 'unixepoch')"], - ['baz.bar_field', 'j/W/H-h i s A', "strftime('%d/%W/%H-%H %M %S ', baz.bar_field, 'unixepoch')"], - ['foo.field', 'W', "CAST(((strftime('%j', date(strftime('%Y-%m-%d', foo.field, 'unixepoch'), '-3 days', 'weekday 4')) - 1) / 7 + 1) AS NUMERIC)"], + [ + 'foo.field', + 'Y-y-M-m', + "strftime('%Y-%Y-%m-%m', foo.field, 'unixepoch')", + ], + [ + 'bar.field', + 'n-F D d l', + "strftime('%m-%m %d %d %d', bar.field, 'unixepoch')", + ], + [ + 'baz.bar_field', + 'j/W/H-h i s A', + "strftime('%d/%W/%H-%H %M %S ', baz.bar_field, 'unixepoch')", + ], + [ + 'foo.field', + 'W', + "CAST(((strftime('%j', date(strftime('%Y-%m-%d', foo.field, 'unixepoch'), '-3 days', 'weekday 4')) - 1) / 7 + 1) AS NUMERIC)", + ], ]; } diff --git a/core/modules/views/tests/src/Unit/PluginBaseTest.php b/core/modules/views/tests/src/Unit/PluginBaseTest.php index e596fc14fffad6dd93956ac6e9e3f9c6d468cc29..b0b708a71d8e8352281131466758c7d049fe0c62 100644 --- a/core/modules/views/tests/src/Unit/PluginBaseTest.php +++ b/core/modules/views/tests/src/Unit/PluginBaseTest.php @@ -306,10 +306,22 @@ public static function providerTestFilterByDefinedOptions() { $data[] = [$values_2, $options_1, $values_1]; // Nested options, all properly defined. - $data[] = [['sub1' => $values_2, 'sub2' => $values_2], ['sub1' => ['contains' => $options_2], 'sub2' => ['contains' => $options_2]], ['sub1' => $values_2, 'sub2' => $values_2]]; + $data[] = [['sub1' => $values_2, 'sub2' => $values_2], + [ + 'sub1' => ['contains' => $options_2], + 'sub2' => ['contains' => $options_2], + ], + ['sub1' => $values_2, 'sub2' => $values_2], + ]; // Nested options, not all properly defined. - $data[] = [['sub1' => $values_2, 'sub2' => $values_2], ['sub1' => ['contains' => $options_2], 'sub2' => ['contains' => $options_1]], ['sub1' => $values_2, 'sub2' => $values_1]]; + $data[] = [['sub1' => $values_2, 'sub2' => $values_2], + [ + 'sub1' => ['contains' => $options_2], + 'sub2' => ['contains' => $options_1], + ], + ['sub1' => $values_2, 'sub2' => $values_1], + ]; return $data; } diff --git a/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php b/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php index c299d711b04608ade13a15a245c961719d9c8daf..07e8894e70740d8ca20ffcf94796fa13891646ba 100644 --- a/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php +++ b/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php @@ -67,7 +67,11 @@ public function testPageController(): void { $options = [ '_view_display_plugin_class' => '\Drupal\views\Plugin\views\display\Page', ]; - $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('/test', ['view_id' => 'test_page_view', 'display_id' => 'default'], [], $options)); + $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route( + '/test', + ['view_id' => 'test_page_view', 'display_id' => 'default'], + [], + $options)); $route_match = RouteMatch::createFromRequest($request); $output = $this->pageController->handle($route_match->getParameter('view_id'), $route_match->getParameter('display_id'), $route_match); @@ -88,7 +92,11 @@ public function testHandleWithArgumentsWithoutOverridden(): void { '_view_argument_map' => ['arg_0' => 'arg_0'], '_view_display_plugin_class' => '\Drupal\views\Plugin\views\display\Page', ]; - $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('/test/{arg_0}', ['view_id' => 'test_page_view', 'display_id' => 'default'], [], $options)); + $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route( + '/test/{arg_0}', + ['view_id' => 'test_page_view', 'display_id' => 'default'], + [], + $options)); $route_match = RouteMatch::createFromRequest($request); $result = $this->pageController->handle($route_match->getParameter('view_id'), $route_match->getParameter('display_id'), $route_match); @@ -124,7 +132,11 @@ public function testHandleWithArgumentsOnOverriddenRoute(): void { ], '_view_display_plugin_class' => '\Drupal\views\Plugin\views\display\Page', ]; - $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('/test/{parameter}', ['view_id' => 'test_page_view', 'display_id' => 'default'], [], $options)); + $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route( + '/test/{parameter}', + ['view_id' => 'test_page_view', 'display_id' => 'default'], + [], + $options)); $route_match = RouteMatch::createFromRequest($request); $result = $this->pageController->handle($route_match->getParameter('view_id'), $route_match->getParameter('display_id'), $route_match); @@ -163,7 +175,11 @@ public function testHandleWithArgumentsOnOverriddenRouteWithUpcasting(): void { ], '_view_display_plugin_class' => '\Drupal\views\Plugin\views\display\Page', ]; - $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('/test/{test_entity}', ['view_id' => 'test_page_view', 'display_id' => 'default'], [], $options)); + $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route( + '/test/{test_entity}', + ['view_id' => 'test_page_view', 'display_id' => 'default'], + [], + $options)); $route_match = RouteMatch::createFromRequest($request); $result = $this->pageController->handle($route_match->getParameter('view_id'), $route_match->getParameter('display_id'), $route_match); diff --git a/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php b/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php index 3854945a089069adfa21150442ce2e4f7483b561..b6a878eb54861520d06a4f3d0830ee302e7887c2 100644 --- a/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php +++ b/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php @@ -84,7 +84,15 @@ public function testBuildRowEntityList(): void { $parent_form_selector = $this->createMock(MenuParentFormSelector::class); $page_display = $this->getMockBuilder('Drupal\views\Plugin\views\display\Page') ->onlyMethods(['initDisplay', 'getPath']) - ->setConstructorArgs([[], 'default', $display_manager->getDefinition('page'), $route_provider, $state, $menu_storage, $parent_form_selector]) + ->setConstructorArgs([ + [], + 'default', + $display_manager->getDefinition('page'), + $route_provider, + $state, + $menu_storage, + $parent_form_selector, + ]) ->getMock(); $page_display->expects($this->any()) ->method('getPath') diff --git a/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php b/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php index 788d5ad1c159495c8bfee8bc3f190ea10a013142..329b0060fc2958df853bd1dace8dbf89a1e3af06 100644 --- a/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php +++ b/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php @@ -39,7 +39,16 @@ public function testEntityDecoration(): void { // uninstallation process. EntityInterface::getConfigDependencyName() and // ConfigEntityInterface::calculateDependencies() are only used for // dependency management. - if (!in_array($reflection_method->getName(), ['isNew', 'isSyncing', 'isUninstalling', 'getConfigDependencyKey', 'getConfigDependencyName', 'calculateDependencies'])) { + if (!in_array( + $reflection_method->getName(), + [ + 'isNew', + 'isSyncing', + 'isUninstalling', + 'getConfigDependencyKey', + 'getConfigDependencyName', + 'calculateDependencies', + ])) { if (count($reflection_method->getParameters()) == 0) { $method_args[$reflection_method->getName()] = []; } diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist index 2b080cef01c2a3dba05652d6a741d7b300e2a2ed..ca89fb3ab2f606ad2d512c5a869e3e56ab6e5349 100644 --- a/core/phpcs.xml.dist +++ b/core/phpcs.xml.dist @@ -31,6 +31,7 @@ <!-- Drupal sniffs --> <rule ref="Drupal.Arrays.Array"/> <rule ref="Drupal.Arrays.Array.LongLineDeclaration"> + <include-pattern>core/*/Unit/*</include-pattern> <include-pattern>core/lib/*</include-pattern> <include-pattern>core/modules/*/tests/modules/*</include-pattern> </rule>