From 9a862ddd87ce8ef75d11dc87e089f7163aeb117f Mon Sep 17 00:00:00 2001 From: quietone <quietone@2572884.no-reply.drupal.org> Date: Sat, 15 Mar 2025 12:52:11 +1300 Subject: [PATCH 1/2] Functional --- .../block/tests/src/Functional/BlockTest.php | 11 +++- .../src/Functional/Views/DisplayBlockTest.php | 49 +++++++++++++-- .../src/Functional/BlockContentTypeTest.php | 4 +- .../Views/BlockContentFieldFilterTest.php | 7 ++- .../tests/src/Functional/CommentAdminTest.php | 6 +- .../src/Functional/CommentAnonymousTest.php | 6 +- .../src/Functional/CommentInterfaceTest.php | 32 ++++++++-- .../tests/src/Functional/CommentPagerTest.php | 3 +- .../Functional/CommentTranslationUITest.php | 6 +- .../Rest/CommentResourceTestBase.php | 7 ++- .../src/Functional/ConfigImportAllTest.php | 3 +- .../ConfigInstallProfileOverrideTest.php | 6 +- .../src/Functional/ConfigInstallWebTest.php | 7 ++- .../src/Functional/ContactSitewideTest.php | 23 ++++++- .../Functional/ModeratedContentViewTest.php | 48 ++++++++++++--- .../ViewsModerationStateFilterTest.php | 30 +++++++++- .../Functional/ContentTranslationTestBase.php | 12 +++- .../ContentTranslationUITestBase.php | 7 ++- .../ContentTranslationWorkflowsTest.php | 31 ++++++++-- .../tests/src/Functional/EditorAdminTest.php | 4 +- .../EntityReferenceXSSTest.php | 9 ++- .../Functional/ManageFieldsLifecycleTest.php | 7 ++- .../src/Functional/FileTokenReplaceTest.php | 3 +- .../help/tests/src/Functional/HelpTest.php | 6 +- .../ImageFieldDefaultImagesTest.php | 10 +++- .../src/Functional/ImageFieldValidateTest.php | 54 +++++++++++++++-- .../ImageOnTranslatedEntityTest.php | 15 ++++- .../tests/src/Functional/FileUploadTest.php | 8 ++- .../jsonapi/tests/src/Functional/NodeTest.php | 3 +- .../Functional/ResourceResponseTestTrait.php | 4 +- .../tests/src/Functional/ResourceTestBase.php | 55 +++++++++++++++-- .../jsonapi/tests/src/Functional/UserTest.php | 11 +++- .../tests/src/Functional/LanguageListTest.php | 10 +++- .../LanguageUILanguageNegotiationTest.php | 6 +- .../Functional/Views/LinkViewsTokensTest.php | 6 +- .../LocaleConfigTranslationTest.php | 18 ++++-- .../tests/src/Functional/LocalePathTest.php | 6 +- .../MediaTemplateSuggestionsTest.php | 10 +++- .../Functional/MediaUiReferenceWidgetTest.php | 13 +++- .../MenuLinkContentTranslationUITest.php | 10 +++- .../src/Functional/MenuCacheTagsTest.php | 15 ++++- .../tests/src/Functional/MenuUiNodeTest.php | 8 ++- .../tests/src/Functional/MenuUiTest.php | 19 ++++-- .../Functional/NodeAccessBaseTableTest.php | 11 +++- .../NodeAccessUnpublishedCacheabilityTest.php | 6 +- .../tests/src/Functional/NodeAdminTest.php | 14 ++++- .../Functional/NodeBlockFunctionalTest.php | 60 ++++++++++++++++--- .../src/Functional/NodeTranslationUITest.php | 11 +++- .../tests/src/Functional/PagePreviewTest.php | 4 +- .../Functional/Views/NodeFieldFilterTest.php | 7 ++- .../Functional/Views/NodeIntegrationTest.php | 5 +- .../src/Functional/Views/NodeLanguageTest.php | 7 ++- .../src/Functional/Views/StatusExtraTest.php | 5 +- .../Views/Wizard/NodeRevisionWizardTest.php | 18 +++++- .../tests/src/Functional/PageCacheTest.php | 3 +- .../EntityResource/EntityResourceTestBase.php | 19 +++++- .../ModeratedNodeResourceTestBase.php | 5 +- .../tests/src/Functional/ResourceTestBase.php | 6 +- .../Views/StyleSerializerEntityTest.php | 19 +++++- .../Functional/Views/StyleSerializerTest.php | 17 +++++- .../SearchConfigSettingsFormTest.php | 5 +- .../src/Functional/SearchRankingTest.php | 7 ++- .../Functional/ShortcutTranslationUITest.php | 14 ++++- .../Database/SelectTableSortDefaultTest.php | 4 +- .../DrupalKernel/ContainerRebuildWebTest.php | 18 +++++- .../Entity/EntityCacheTagsTestBase.php | 4 +- .../Entity/EntityListBuilderTest.php | 10 +++- .../Entity/EntityTranslationFormTest.php | 5 +- .../tests/src/Functional/Form/FormTest.php | 47 +++++++++++++-- .../Form/LanguageSelectElementTest.php | 11 +++- .../src/Functional/Menu/LocalActionTest.php | 10 +++- .../src/Functional/Routing/RouterTest.php | 8 ++- .../Functional/System/TokenReplaceWebTest.php | 6 +- .../src/Functional/Theme/EngineTwigTest.php | 24 ++++++-- .../src/Functional/Theme/ThemeInfoTest.php | 8 ++- .../src/Functional/Theme/ThemeUiTest.php | 6 +- .../src/Functional/Theme/ThemeUpdateTest.php | 4 +- .../Theme/TwigRegistryLoaderTest.php | 7 ++- .../Functional/Rest/TermResourceTestBase.php | 3 +- .../tests/src/Functional/TermParentsTest.php | 16 +++-- .../src/Functional/TermTranslationUITest.php | 3 +- .../Views/TaxonomyFieldFilterTest.php | 7 ++- .../src/Functional/ToolbarAdminMenuTest.php | 12 +++- .../Functional/Rest/UserResourceTestBase.php | 4 +- .../src/Functional/UserTokenReplaceTest.php | 23 +++++-- .../src/Functional/Handler/FieldWebTest.php | 47 ++++++++++++--- .../src/Functional/Handler/HandlerTest.php | 8 ++- .../Functional/Plugin/DisplayPageWebTest.php | 7 ++- .../src/Functional/Plugin/DisplayTest.php | 29 ++++++++- .../src/Functional/Plugin/ExposedFormTest.php | 16 ++++- .../tests/src/Functional/Plugin/PagerTest.php | 18 +++++- .../tests/src/Functional/WorkflowUiTest.php | 42 +++++++++++-- core/phpcs.xml.dist | 1 + 93 files changed, 1067 insertions(+), 192 deletions(-) diff --git a/core/modules/block/tests/src/Functional/BlockTest.php b/core/modules/block/tests/src/Functional/BlockTest.php index 6d894612d4c5..c0ae66988e1d 100644 --- a/core/modules/block/tests/src/Functional/BlockTest.php +++ b/core/modules/block/tests/src/Functional/BlockTest.php @@ -458,7 +458,8 @@ public function testBlockCacheTags(): void { 'rendered', ]; sort($expected_cache_tags); - $keys = \Drupal::service('cache_contexts_manager')->convertTokensToKeys(['languages:language_interface', 'theme', 'user.permissions'])->getKeys(); + $keys = \Drupal::service('cache_contexts_manager') + ->convertTokensToKeys(['languages:language_interface', 'theme', 'user.permissions'])->getKeys(); $this->assertSame($expected_cache_tags, $cache_entry->tags); $cache_entry = \Drupal::cache('render')->get('entity_view:block:powered:' . implode(':', $keys)); $expected_cache_tags = [ @@ -507,7 +508,9 @@ public function testBlockCacheTags(): void { 'rendered', ]; sort($expected_cache_tags); - $keys = \Drupal::service('cache_contexts_manager')->convertTokensToKeys(['languages:language_interface', 'theme', 'user.permissions'])->getKeys(); + $keys = \Drupal::service('cache_contexts_manager') + ->convertTokensToKeys(['languages:language_interface', 'theme', 'user.permissions']) + ->getKeys(); $cache_entry = \Drupal::cache('render')->get('entity_view:block:powered:' . implode(':', $keys)); $this->assertSame($expected_cache_tags, $cache_entry->tags); $expected_cache_tags = [ @@ -516,7 +519,9 @@ public function testBlockCacheTags(): void { 'rendered', ]; sort($expected_cache_tags); - $keys = \Drupal::service('cache_contexts_manager')->convertTokensToKeys(['languages:language_interface', 'theme', 'user.permissions'])->getKeys(); + $keys = \Drupal::service('cache_contexts_manager') + ->convertTokensToKeys(['languages:language_interface', 'theme', 'user.permissions']) + ->getKeys(); $cache_entry = \Drupal::cache('render')->get('entity_view:block:powered_2:' . implode(':', $keys)); $this->assertSame($expected_cache_tags, $cache_entry->tags); diff --git a/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php b/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php index aede08a4cf29..8044fffa1f07 100644 --- a/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php +++ b/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php @@ -290,7 +290,17 @@ public function testBlockRendering(): void { $this->drupalGet(''); $this->assertSession()->elementNotExists('xpath', "{$block_xpath}/h2"); - $this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:system.site', 'config:views.view.test_view_block', 'http_response', 'CACHE_MISS_IF_UNCACHEABLE_HTTP_METHOD:form', 'rendered'])); + $this->assertCacheTags(array_merge( + $block->getCacheTags(), + [ + 'block_view', + 'config:block_list', + 'config:system.site', + 'config:views.view.test_view_block', + 'http_response', + 'CACHE_MISS_IF_UNCACHEABLE_HTTP_METHOD:form', + 'rendered', + ])); } /** @@ -304,7 +314,12 @@ public function testBlockEmptyRendering(): void { $view = View::load('test_view_block'); $view->invalidateCaches(); - $block = $this->drupalPlaceBlock('views_block:test_view_block-block_1', ['label' => 'test_view_block-block_1:1', 'views_label' => 'Custom title']); + $block = $this->drupalPlaceBlock( + 'views_block:test_view_block-block_1', + [ + 'label' => 'test_view_block-block_1:1', + 'views_label' => 'Custom title', + ]); $block_xpath = $this->assertSession()->buildXPathQuery('//div[@id = :id]', [ ':id' => 'block-' . $block->id(), ]); @@ -319,7 +334,15 @@ public function testBlockEmptyRendering(): void { $this->assertSession()->elementNotExists('xpath', $block_xpath); // Ensure that the view cacheability metadata is propagated even, for an // empty block. - $this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block', 'http_response', 'rendered'])); + $this->assertCacheTags(array_merge( + $block->getCacheTags(), + [ + 'block_view', + 'config:block_list', + 'config:views.view.test_view_block', + 'http_response', + 'rendered', + ])); $this->assertCacheContexts(['url.query_args:_wrapper_format']); // Add a header displayed on empty result. @@ -337,7 +360,15 @@ public function testBlockEmptyRendering(): void { $this->drupalGet($url); $this->assertSession()->elementsCount('xpath', $block_xpath, 1); - $this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block', 'http_response', 'rendered'])); + $this->assertCacheTags(array_merge( + $block->getCacheTags(), + [ + 'block_view', + 'config:block_list', + 'config:views.view.test_view_block', + 'http_response', + 'rendered', + ])); $this->assertCacheContexts(['url.query_args:_wrapper_format']); // Hide the header on empty results. @@ -355,7 +386,9 @@ public function testBlockEmptyRendering(): void { $this->drupalGet($url); $this->assertSession()->elementNotExists('xpath', $block_xpath); - $this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block', 'http_response', 'rendered'])); + $this->assertCacheTags(array_merge( + $block->getCacheTags(), + ['block_view', 'config:block_list', 'config:views.view.test_view_block', 'http_response', 'rendered'])); $this->assertCacheContexts(['url.query_args:_wrapper_format']); // Add an empty text. @@ -372,7 +405,9 @@ public function testBlockEmptyRendering(): void { $this->drupalGet($url); $this->assertSession()->elementsCount('xpath', $block_xpath, 1); - $this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block', 'http_response', 'rendered'])); + $this->assertCacheTags(array_merge( + $block->getCacheTags(), + ['block_view', 'config:block_list', 'config:views.view.test_view_block', 'http_response', 'rendered'])); $this->assertCacheContexts(['url.query_args:_wrapper_format']); } @@ -395,8 +430,10 @@ public function testBlockContextualLinks(): void { $cached_id_token = Crypt::hmacBase64($cached_id, Settings::getHashSalt() . $this->container->get('private_key')->get()); // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder() // Check existence of the contextual link placeholders. + // phpcs:disable Drupal.Arrays.Array.LongLineDeclaration $this->assertSession()->responseContains('<div' . new Attribute(['data-contextual-id' => $id, 'data-contextual-token' => $id_token, 'data-drupal-ajax-container' => '']) . '></div>'); $this->assertSession()->responseContains('<div' . new Attribute(['data-contextual-id' => $cached_id, 'data-contextual-token' => $cached_id_token, 'data-drupal-ajax-container' => '']) . '></div>'); + // phpcs:enable // Get server-rendered contextual links. // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:renderContextualLinks() diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php index fba8362cd2cd..17414f79a9dc 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php @@ -237,7 +237,9 @@ public function testsBlockContentAddTypes(): void { $blocks = $storage->loadByProperties(['info' => $edit['info[0][value]']]); if (!empty($blocks)) { $block = reset($blocks); - $this->assertSession()->addressEquals(Url::fromRoute('block.admin_add', ['plugin_id' => 'block_content:' . $block->uuid(), 'theme' => $theme])); + $this->assertSession()->addressEquals( + Url::fromRoute('block.admin_add', + ['plugin_id' => 'block_content:' . $block->uuid(), 'theme' => $theme])); $this->submitForm(['region' => 'content'], 'Save block'); $this->assertSession()->addressEquals(Url::fromRoute('block.admin_display_theme', ['theme' => $theme], ['query' => ['block-placement' => $theme . '-' . Html::getClass($edit['info[0][value]'])]])); } diff --git a/core/modules/block_content/tests/src/Functional/Views/BlockContentFieldFilterTest.php b/core/modules/block_content/tests/src/Functional/Views/BlockContentFieldFilterTest.php index 674e99923861..88041e2741d9 100644 --- a/core/modules/block_content/tests/src/Functional/Views/BlockContentFieldFilterTest.php +++ b/core/modules/block_content/tests/src/Functional/Views/BlockContentFieldFilterTest.php @@ -62,7 +62,12 @@ protected function setUp($import_test_views = TRUE, $modules = ['block_content_t ]; // Create block_content with translations. - $block_content = $this->createBlockContent(['info' => $this->blockContentInfos['en'], 'langcode' => 'en', 'type' => 'basic', 'body' => [['value' => $this->blockContentInfos['en']]]]); + $block_content = $this->createBlockContent([ + 'info' => $this->blockContentInfos['en'], + 'langcode' => 'en', + 'type' => 'basic', + 'body' => [['value' => $this->blockContentInfos['en']]], + ]); foreach (['es', 'fr'] as $langcode) { $translation = $block_content->addTranslation($langcode, ['info' => $this->blockContentInfos[$langcode]]); $translation->body->value = $this->blockContentInfos[$langcode]; diff --git a/core/modules/comment/tests/src/Functional/CommentAdminTest.php b/core/modules/comment/tests/src/Functional/CommentAdminTest.php index f8dfc8a9b38b..d06849d003b8 100644 --- a/core/modules/comment/tests/src/Functional/CommentAdminTest.php +++ b/core/modules/comment/tests/src/Functional/CommentAdminTest.php @@ -225,7 +225,11 @@ public function testEditComment(): void { // Post comment with contact info (required). $author_name = $this->randomMachineName(); $author_mail = $this->randomMachineName() . '@example.com'; - $anonymous_comment = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), ['name' => $author_name, 'mail' => $author_mail]); + $anonymous_comment = $this->postComment( + $this->node, + $this->randomMachineName(), + $this->randomMachineName(), + ['name' => $author_name, 'mail' => $author_mail]); // Log in as an admin user. $this->drupalLogin($this->adminUser); diff --git a/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php index a6a00eb75893..50aae234a32f 100644 --- a/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php +++ b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php @@ -132,7 +132,11 @@ public function testAnonymous(): void { // Post comment with contact info (required). $author_name = $this->randomMachineName(); $author_mail = $this->randomMachineName() . '@example.com'; - $anonymous_comment3 = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), ['name' => $author_name, 'mail' => $author_mail]); + $anonymous_comment3 = $this->postComment( + $this->node, + $this->randomMachineName(), + $this->randomMachineName(), + ['name' => $author_name, 'mail' => $author_mail]); $this->assertTrue($this->commentExists($anonymous_comment3), 'Anonymous comment with contact info (required) found.'); // Make sure the user data appears correctly when editing the comment. diff --git a/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php b/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php index beb71661cd4f..a1b9c1138706 100644 --- a/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php +++ b/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php @@ -76,7 +76,14 @@ public function testCommentInterface(): void { // Comment as anonymous with preview required. $this->drupalLogout(); - user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access content', 'access comments', 'post comments', 'skip comment approval']); + user_role_grant_permissions( + RoleInterface::ANONYMOUS_ID, + [ + 'access content', + 'access comments', + 'post comments', + 'skip comment approval', + ]); $anonymous_comment = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), TRUE); $this->assertTrue($this->commentExists($anonymous_comment), 'Comment found.'); $anonymous_comment->delete(); @@ -124,7 +131,10 @@ public function testCommentInterface(): void { // \Drupal\comment\Controller\CommentController::redirectNode(). $this->drupalGet('comment/' . $this->node->id() . '/reply'); // Verify we were correctly redirected. - $this->assertSession()->addressEquals(Url::fromRoute('comment.reply', ['entity_type' => 'node', 'entity' => $this->node->id(), 'field_name' => 'comment'])); + $this->assertSession()->addressEquals( + Url::fromRoute( + 'comment.reply', + ['entity_type' => 'node', 'entity' => $this->node->id(), 'field_name' => 'comment'])); $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $comment->id()); $this->assertSession()->pageTextContains($subject_text); $this->assertSession()->pageTextContains($comment_text); @@ -175,21 +185,33 @@ public function testCommentInterface(): void { $this->assertSession()->statusCodeEquals(403); // Attempt to post to node with comments disabled. - $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'comment' => [['status' => CommentItemInterface::HIDDEN]]]); + $this->node = $this->drupalCreateNode([ + 'type' => 'article', + 'promote' => 1, + 'comment' => [['status' => CommentItemInterface::HIDDEN]], + ]); $this->assertNotNull($this->node, 'Article node created.'); $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment'); $this->assertSession()->statusCodeEquals(403); $this->assertSession()->fieldNotExists('edit-comment'); // Attempt to post to node with read-only comments. - $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'comment' => [['status' => CommentItemInterface::CLOSED]]]); + $this->node = $this->drupalCreateNode([ + 'type' => 'article', + 'promote' => 1, + 'comment' => [['status' => CommentItemInterface::CLOSED]], + ]); $this->assertNotNull($this->node, 'Article node created.'); $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment'); $this->assertSession()->statusCodeEquals(403); $this->assertSession()->fieldNotExists('edit-comment'); // Attempt to post to node with comments enabled (check field names etc). - $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'comment' => [['status' => CommentItemInterface::OPEN]]]); + $this->node = $this->drupalCreateNode([ + 'type' => 'article', + 'promote' => 1, + 'comment' => [['status' => CommentItemInterface::OPEN]], + ]); $this->assertNotNull($this->node, 'Article node created.'); $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment'); $this->assertSession()->pageTextNotContains('This discussion is closed'); diff --git a/core/modules/comment/tests/src/Functional/CommentPagerTest.php b/core/modules/comment/tests/src/Functional/CommentPagerTest.php index 819403386b1c..57e00748344f 100644 --- a/core/modules/comment/tests/src/Functional/CommentPagerTest.php +++ b/core/modules/comment/tests/src/Functional/CommentPagerTest.php @@ -446,7 +446,8 @@ protected function clickLinkWithXPath($xpath, $arguments = [], $index = 0) { $url_target = $this->getAbsoluteUrl($urls[$index]->getAttribute('href')); return $this->drupalGet($url_target); } - $this->fail(new FormattableMarkup('Link %label does not exist on @url_before', ['%label' => $xpath, '@url_before' => $url_before])); + $this->fail(new FormattableMarkup( + 'Link %label does not exist on @url_before', ['%label' => $xpath, '@url_before' => $url_before])); return FALSE; } diff --git a/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php index 4d6db8c4bfd2..298388645342 100644 --- a/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php +++ b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php @@ -201,7 +201,11 @@ protected function doTestAuthoringInfo(): void { * Tests translate link on comment content admin page. */ public function testTranslateLinkCommentAdminPage(): void { - $this->adminUser = $this->drupalCreateUser(array_merge(parent::getTranslatorPermissions(), ['access administration pages', 'administer comments', 'skip comment approval'])); + $this->adminUser = $this->drupalCreateUser(array_merge(parent::getTranslatorPermissions(), [ + 'access administration pages', + 'administer comments', + 'skip comment approval', + ])); $this->drupalLogin($this->adminUser); $cid_translatable = $this->createEntity([], $this->langcodes[0]); diff --git a/core/modules/comment/tests/src/Functional/Rest/CommentResourceTestBase.php b/core/modules/comment/tests/src/Functional/Rest/CommentResourceTestBase.php index 6c0b4dc35f34..e065c1b26705 100644 --- a/core/modules/comment/tests/src/Functional/Rest/CommentResourceTestBase.php +++ b/core/modules/comment/tests/src/Functional/Rest/CommentResourceTestBase.php @@ -60,7 +60,8 @@ abstract class CommentResourceTestBase extends EntityResourceTestBase { */ #[Before] public function commentResourceTestBaseSkipTests(): void { - if (static::$format === 'xml' && in_array($this->name(), ['testPostDxWithoutCriticalBaseFields', 'testPostSkipCommentApproval'], TRUE)) { + if (static::$format === 'xml' + && in_array($this->name(), ['testPostDxWithoutCriticalBaseFields', 'testPostSkipCommentApproval'], TRUE)) { $this->markTestSkipped('Deserialization of the XML format is not supported.'); } } @@ -274,7 +275,9 @@ protected function getNormalizedPostEntity() { * {@inheritdoc} */ protected function getNormalizedPatchEntity() { - return array_diff_key($this->getNormalizedPostEntity(), ['entity_type' => TRUE, 'entity_id' => TRUE, 'field_name' => TRUE]); + return array_diff_key( + $this->getNormalizedPostEntity(), + ['entity_type' => TRUE, 'entity_id' => TRUE, 'field_name' => TRUE]); } /** diff --git a/core/modules/config/tests/src/Functional/ConfigImportAllTest.php b/core/modules/config/tests/src/Functional/ConfigImportAllTest.php index 501953547012..ca7cfa8ea8f9 100644 --- a/core/modules/config/tests/src/Functional/ConfigImportAllTest.php +++ b/core/modules/config/tests/src/Functional/ConfigImportAllTest.php @@ -96,7 +96,8 @@ public function testInstallUninstall(): void { // example, if a comment field exists then Comment cannot be uninstalled. $entity_type_manager = \Drupal::entityTypeManager(); foreach ($entity_type_manager->getDefinitions() as $entity_type) { - if (($entity_type instanceof ContentEntityTypeInterface || in_array($entity_type->id(), ['field_storage_config', 'filter_format'], TRUE)) + if (($entity_type instanceof ContentEntityTypeInterface + || in_array($entity_type->id(), ['field_storage_config', 'filter_format'], TRUE)) && !in_array($entity_type->getProvider(), ['system', 'user'], TRUE)) { $storage = $entity_type_manager->getStorage($entity_type->id()); $storage->delete($storage->loadMultiple()); diff --git a/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php b/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php index 8ee31a50f904..164c2cd0f4b3 100644 --- a/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php +++ b/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php @@ -109,7 +109,11 @@ public function testInstallProfileConfigOverwrite(): void { // type does not exist. $optional_dir = $this->getModulePath('testing_config_overrides') . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY; $optional_storage = new FileStorage($optional_dir); - foreach (['config_test.dynamic.dotted.default', 'config_test.dynamic.override', 'config_test.dynamic.override_unmet'] as $id) { + foreach ([ + 'config_test.dynamic.dotted.default', + 'config_test.dynamic.override', + 'config_test.dynamic.override_unmet', + ] as $id) { $this->assertTrue(\Drupal::config($id)->isNew(), "The config_test entity $id contained in the profile's optional directory does not exist."); // Make that we don't get false positives from the assertion above. $this->assertTrue($optional_storage->exists($id), "The config_test entity $id does exist in the profile's optional directory."); diff --git a/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php b/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php index 0209fb0e1ccd..6bcde6faa1b9 100644 --- a/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php +++ b/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php @@ -205,7 +205,12 @@ public function testPreExistingConfigInstall(): void { } catch (PreExistingConfigException $e) { $this->assertEquals('config_clash_test_theme', $e->getExtension()); - $this->assertEquals([StorageInterface::DEFAULT_COLLECTION => ['config_test.dynamic.dotted.default'], 'language.fr' => ['config_test.dynamic.dotted.default']], $e->getConfigObjects()); + $this->assertEquals( + [ + StorageInterface::DEFAULT_COLLECTION => ['config_test.dynamic.dotted.default'], + 'language.fr' => ['config_test.dynamic.dotted.default'], + ], + $e->getConfigObjects()); $this->assertEquals('Configuration objects (config_test.dynamic.dotted.default, language/fr/config_test.dynamic.dotted.default) provided by config_clash_test_theme already exist in active configuration', $e->getMessage()); } } diff --git a/core/modules/contact/tests/src/Functional/ContactSitewideTest.php b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php index b3cba2bd1baa..805b3e10e113 100644 --- a/core/modules/contact/tests/src/Functional/ContactSitewideTest.php +++ b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php @@ -213,10 +213,29 @@ public function testSiteWideContact(): void { $this->drupalLogin($admin_user); // Add more forms. - $this->addContactForm($this->randomMachineName(16), $label = $this->randomMachineName(16), implode(',', [$recipients[0], $recipients[1]]), '', FALSE); + $this->addContactForm( + $this->randomMachineName(16), + $label = $this->randomMachineName(16), + implode(',', + [ + $recipients[0], + $recipients[1], + ]), + '', + FALSE); $this->assertSession()->pageTextContains('Contact form ' . $label . ' has been added.'); - $this->addContactForm($name = $this->randomMachineName(16), $label = $this->randomMachineName(16), implode(',', [$recipients[0], $recipients[1], $recipients[2]]), '', FALSE); + $this->addContactForm( + $name = $this->randomMachineName(16), + $label = $this->randomMachineName(16), + implode(',', + [ + $recipients[0], + $recipients[1], + $recipients[2], + ]), + '', + FALSE); $this->assertSession()->pageTextContains('Contact form ' . $label . ' has been added.'); // Try adding a form that already exists. diff --git a/core/modules/content_moderation/tests/src/Functional/ModeratedContentViewTest.php b/core/modules/content_moderation/tests/src/Functional/ModeratedContentViewTest.php index 25cbff3e9486..555c47f232b8 100644 --- a/core/modules/content_moderation/tests/src/Functional/ModeratedContentViewTest.php +++ b/core/modules/content_moderation/tests/src/Functional/ModeratedContentViewTest.php @@ -77,31 +77,63 @@ public function testModeratedContentPage(): void { // table style configuration with a default sort on the 'changed' field // descending. $time = \Drupal::time()->getRequestTime(); - $excluded_nodes['published_page'] = $this->drupalCreateNode(['type' => 'page', 'changed' => $time--, 'moderation_state' => 'published']); - $excluded_nodes['published_article'] = $this->drupalCreateNode(['type' => 'article', 'changed' => $time--, 'moderation_state' => 'published']); + $excluded_nodes['published_page'] = $this->drupalCreateNode([ + 'type' => 'page', + 'changed' => $time--, + 'moderation_state' => 'published', + ]); + $excluded_nodes['published_article'] = $this->drupalCreateNode([ + 'type' => 'article', + 'changed' => $time--, + 'moderation_state' => 'published', + ]); - $excluded_nodes['unmoderated_type'] = $this->drupalCreateNode(['type' => 'unmoderated_type', 'changed' => $time--]); + $excluded_nodes['unmoderated_type'] = $this->drupalCreateNode([ + 'type' => 'unmoderated_type', + 'changed' => $time--, + ]); $excluded_nodes['unmoderated_type']->setNewRevision(TRUE); $excluded_nodes['unmoderated_type']->isDefaultRevision(FALSE); $excluded_nodes['unmoderated_type']->changed->value = $time--; $excluded_nodes['unmoderated_type']->save(); - $nodes['published_then_draft_article'] = $this->drupalCreateNode(['type' => 'article', 'changed' => $time--, 'moderation_state' => 'published', 'title' => 'first article - published']); + $nodes['published_then_draft_article'] = $this->drupalCreateNode([ + 'type' => 'article', + 'changed' => $time--, + 'moderation_state' => 'published', + 'title' => 'first article - published', + ]); $nodes['published_then_draft_article']->setNewRevision(TRUE); $nodes['published_then_draft_article']->setTitle('first article - draft'); $nodes['published_then_draft_article']->moderation_state->value = 'draft'; $nodes['published_then_draft_article']->changed->value = $time--; $nodes['published_then_draft_article']->save(); - $nodes['published_then_archived_article'] = $this->drupalCreateNode(['type' => 'article', 'changed' => $time--, 'moderation_state' => 'published']); + $nodes['published_then_archived_article'] = $this->drupalCreateNode([ + 'type' => 'article', + 'changed' => $time--, + 'moderation_state' => 'published', + ]); $nodes['published_then_archived_article']->setNewRevision(TRUE); $nodes['published_then_archived_article']->moderation_state->value = 'archived'; $nodes['published_then_archived_article']->changed->value = $time--; $nodes['published_then_archived_article']->save(); - $nodes['draft_article'] = $this->drupalCreateNode(['type' => 'article', 'changed' => $time--, 'moderation_state' => 'draft']); - $nodes['draft_page_1'] = $this->drupalCreateNode(['type' => 'page', 'changed' => $time--, 'moderation_state' => 'draft']); - $nodes['draft_page_2'] = $this->drupalCreateNode(['type' => 'page', 'changed' => $time, 'moderation_state' => 'draft']); + $nodes['draft_article'] = $this->drupalCreateNode([ + 'type' => 'article', + 'changed' => $time--, + 'moderation_state' => 'draft', + ]); + $nodes['draft_page_1'] = $this->drupalCreateNode([ + 'type' => 'page', + 'changed' => $time--, + 'moderation_state' => 'draft', + ]); + $nodes['draft_page_2'] = $this->drupalCreateNode([ + 'type' => 'page', + 'changed' => $time, + 'moderation_state' => 'draft', + ]); // Verify view, edit, and delete links for any content. $this->drupalGet('admin/content/moderated'); diff --git a/core/modules/content_moderation/tests/src/Functional/ViewsModerationStateFilterTest.php b/core/modules/content_moderation/tests/src/Functional/ViewsModerationStateFilterTest.php index e7c0b8f9e8f1..f85dd697bfe0 100644 --- a/core/modules/content_moderation/tests/src/Functional/ViewsModerationStateFilterTest.php +++ b/core/modules/content_moderation/tests/src/Functional/ViewsModerationStateFilterTest.php @@ -203,7 +203,10 @@ public function testWorkflowChanges($view_id): void { // Check that only the archived nodes from both bundles are displayed by the // view. $view = $this->loadViewUnchanged($view_id); - $this->executeAndAssertIdenticalResultset($view, [['nid' => $archived_node_a->id()], ['nid' => $archived_node_b->id()]], ['nid' => 'nid']); + $this->executeAndAssertIdenticalResultset( + $view, + [['nid' => $archived_node_a->id()], ['nid' => $archived_node_b->id()]], + ['nid' => 'nid']); // Remove the Editorial workflow from one of the bundles. $this->drupalGet('admin/config/workflow/workflows/manage/editorial/type/node'); @@ -295,7 +298,16 @@ public function testFilterRenderCache(): void { // Adding a second workflow to nodes will also show new states. $this->drupalGet('admin/config/workflow/workflows/manage/new_workflow/type/node'); $this->submitForm(['bundles[example_b]' => TRUE], 'Save'); - $this->assertFilterStates(['All', 'editorial-draft', 'editorial-published', 'editorial-archived', 'editorial-foo', 'new_workflow-draft', 'new_workflow-published', 'new_workflow-bar']); + $this->assertFilterStates([ + 'All', + 'editorial-draft', + 'editorial-published', + 'editorial-archived', + 'editorial-foo', + 'new_workflow-draft', + 'new_workflow-published', + 'new_workflow-bar', + ]); // Add a few more states and change the exposed filter to allow multiple // selections so we can check that the size of the select element does not @@ -318,7 +330,19 @@ public function testFilterRenderCache(): void { $this->drupalGet("admin/structure/views/view/{$view_id}"); $this->submitForm([], 'Save'); - $this->assertFilterStates(['editorial-draft', 'editorial-published', 'editorial-archived', 'editorial-foo', 'editorial-foo2', 'editorial-foo3', 'new_workflow-draft', 'new_workflow-published', 'new_workflow-bar'], TRUE); + $this->assertFilterStates( + [ + 'editorial-draft', + 'editorial-published', + 'editorial-archived', + 'editorial-foo', + 'editorial-foo2', + 'editorial-foo3', + 'new_workflow-draft', + 'new_workflow-published', + 'new_workflow-bar', + ], + TRUE); } /** diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php index 7d43cc6d0e3a..c3591c604fa0 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php @@ -115,7 +115,12 @@ protected function setupLanguages() { * Returns an array of permissions needed for the translator. */ protected function getTranslatorPermissions() { - return array_filter([$this->getTranslatePermission(), 'create content translations', 'update content translations', 'delete content translations']); + return array_filter([ + $this->getTranslatePermission(), + 'create content translations', + 'update content translations', + 'delete content translations', + ]); } /** @@ -140,7 +145,10 @@ protected function getEditorPermissions() { * Returns an array of permissions needed for the administrator. */ protected function getAdministratorPermissions() { - return array_merge($this->getEditorPermissions(), $this->getTranslatorPermissions(), ['administer languages', 'administer content translation']); + return array_merge( + $this->getEditorPermissions(), + $this->getTranslatorPermissions(), + ['administer languages', 'administer content translation']); } /** diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php index 65e4ea516546..a5f791238db9 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php @@ -48,7 +48,12 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase { * * @var string[] */ - protected $defaultCacheContexts = ['languages:language_interface', 'theme', 'url.query_args:_wrapper_format', 'user.permissions']; + protected $defaultCacheContexts = [ + 'languages:language_interface', + 'theme', + 'url.query_args:_wrapper_format', + 'user.permissions', + ]; /** * Tests the basic translation UI. diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php index 63e67b7f351c..38d75e522cf5 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php @@ -127,7 +127,13 @@ protected function setupUsers(): void { * Returns an array of permissions needed for the entity owner. */ protected function getEntityOwnerPermissions(): array { - return ['edit own entity_test content', 'translate editable entities', 'view test entity', 'view test entity translations', 'view unpublished test entity translations']; + return [ + 'edit own entity_test content', + 'translate editable entities', + 'view test entity', + 'view test entity translations', + 'view unpublished test entity translations', + ]; } /** @@ -171,7 +177,13 @@ protected function setupEntity(?UserInterface $user = NULL): void { // Create a translation that is not published to test view access. $this->drupalLogin($this->translator); - $add_translation_url = Url::fromRoute("entity.$this->entityTypeId.content_translation_add", [$this->entityTypeId => $id, 'source' => $default_langcode, 'target' => $this->langcodes[2]]); + $add_translation_url = Url::fromRoute( + "entity.$this->entityTypeId.content_translation_add", + [ + $this->entityTypeId => $id, + 'source' => $default_langcode, + 'target' => $this->langcodes[2], + ]); $edit = [ 'name[0][value]' => 'translation name', 'content_translation[status]' => FALSE, @@ -331,7 +343,10 @@ protected function doTestWorkflows(UserInterface $user, $expected_status): void $this->assertSession()->statusCodeEquals($expected_status['overview']); // Check whether the user is allowed to create a translation. - $add_translation_url = Url::fromRoute("entity.$this->entityTypeId.content_translation_add", [$this->entityTypeId => $this->entity->id(), 'source' => $default_langcode, 'target' => $langcode], $options); + $add_translation_url = Url::fromRoute( + "entity.$this->entityTypeId.content_translation_add", + [$this->entityTypeId => $this->entity->id(), 'source' => $default_langcode, 'target' => $langcode], + $options); if ($expected_status['add_translation'] == 200) { $this->clickLink('Add'); $this->assertSession()->addressEquals($add_translation_url); @@ -349,7 +364,10 @@ protected function doTestWorkflows(UserInterface $user, $expected_status): void // Check whether the user is allowed to edit a translation. $langcode = $this->langcodes[2]; $options['language'] = $languages[$langcode]; - $edit_translation_url = Url::fromRoute("entity.$this->entityTypeId.content_translation_edit", [$this->entityTypeId => $this->entity->id(), 'language' => $langcode], $options); + $edit_translation_url = Url::fromRoute( + "entity.$this->entityTypeId.content_translation_edit", + [$this->entityTypeId => $this->entity->id(), 'language' => $langcode], + $options); if ($expected_status['edit_translation'] == 200) { $this->drupalGet($translations_url); $editor = $expected_status['edit'] == 200; @@ -390,7 +408,10 @@ protected function doTestWorkflows(UserInterface $user, $expected_status): void } // Check whether the user is allowed to delete a translation. - $delete_translation_url = Url::fromRoute("entity.$this->entityTypeId.content_translation_delete", [$this->entityTypeId => $this->entity->id(), 'language' => $langcode], $options); + $delete_translation_url = Url::fromRoute( + "entity.$this->entityTypeId.content_translation_delete", + [$this->entityTypeId => $this->entity->id(), 'language' => $langcode], + $options); if ($expected_status['delete_translation'] == 200) { $this->drupalGet($translations_url); $editor = $expected_status['delete'] == 200; diff --git a/core/modules/editor/tests/src/Functional/EditorAdminTest.php b/core/modules/editor/tests/src/Functional/EditorAdminTest.php index 639aa030618a..217609d5dfdd 100644 --- a/core/modules/editor/tests/src/Functional/EditorAdminTest.php +++ b/core/modules/editor/tests/src/Functional/EditorAdminTest.php @@ -142,7 +142,9 @@ public function testDisableFormatWithEditor(): void { $this->drupalLogin($account); // The node edit page header. - $text = (string) new FormattableMarkup('<em>Edit @type</em> @title', ['@type' => $node_type->label(), '@title' => $node->label()]); + $text = (string) new FormattableMarkup( + '<em>Edit @type</em> @title', + ['@type' => $node_type->label(), '@title' => $node->label()]); // Go to node edit form. $this->drupalGet('node/' . $node->id() . '/edit'); diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceXSSTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceXSSTest.php index 229a59f26a8e..185f72d03b59 100644 --- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceXSSTest.php +++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceXSSTest.php @@ -48,7 +48,14 @@ public function testEntityReferenceXSS(): void { 'title' => 'My bundle has markup', ]); - $this->createEntityReferenceField('node', 'article', 'entity_reference_test', 'Entity Reference test', 'node', 'default', ['target_bundles' => [$node_type_one->id(), $node_type_two->id()]]); + $this->createEntityReferenceField( + 'node', + 'article', + 'entity_reference_test', + 'Entity Reference test', + 'node', + 'default', + ['target_bundles' => [$node_type_one->id(), $node_type_two->id()]]); EntityFormDisplay::load('node.article.default') ->setComponent('entity_reference_test', ['type' => 'options_select']) diff --git a/core/modules/field_ui/tests/src/Functional/ManageFieldsLifecycleTest.php b/core/modules/field_ui/tests/src/Functional/ManageFieldsLifecycleTest.php index 5d80b3c28ef2..f34cbe3a4837 100644 --- a/core/modules/field_ui/tests/src/Functional/ManageFieldsLifecycleTest.php +++ b/core/modules/field_ui/tests/src/Functional/ManageFieldsLifecycleTest.php @@ -174,7 +174,12 @@ protected function cardinalitySettings(): void { $this->assertSession()->pageTextContains("There is 1 entity with 2 or more values in this field"); // Create a second entity with three values. - $edit = ['title[0][value]' => 'Cardinality 3', 'body[0][value]' => 'Body 1', 'body[1][value]' => 'Body 2', 'body[2][value]' => 'Body 3']; + $edit = [ + 'title[0][value]' => 'Cardinality 3', + 'body[0][value]' => 'Body 1', + 'body[1][value]' => 'Body 2', + 'body[2][value]' => 'Body 3', + ]; $this->drupalGet('node/add/article'); $this->submitForm($edit, 'Save'); diff --git a/core/modules/file/tests/src/Functional/FileTokenReplaceTest.php b/core/modules/file/tests/src/Functional/FileTokenReplaceTest.php index a82913d1878f..c16723fce258 100644 --- a/core/modules/file/tests/src/Functional/FileTokenReplaceTest.php +++ b/core/modules/file/tests/src/Functional/FileTokenReplaceTest.php @@ -101,7 +101,8 @@ public function testFileTokenReplacement(): void { $tests['[file:size]'] = ByteSizeMarkup::create($file->getSize()); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, ['file' => $file], ['langcode' => $language_interface->getId(), 'sanitize' => FALSE]); + $output = $token_service->replace( + $input, ['file' => $file], ['langcode' => $language_interface->getId(), 'sanitize' => FALSE]); $this->assertEquals($expected, $output, "Unsanitized file token $input replaced."); } } diff --git a/core/modules/help/tests/src/Functional/HelpTest.php b/core/modules/help/tests/src/Functional/HelpTest.php index 3a954ac0eadd..204c3567922e 100644 --- a/core/modules/help/tests/src/Functional/HelpTest.php +++ b/core/modules/help/tests/src/Functional/HelpTest.php @@ -99,7 +99,11 @@ public function testHelp(): void { // Make sure links are properly added for modules implementing hook_help(). foreach ($this->getModuleList() as $module => $name) { - $this->assertSession()->linkExists($name, 0, new FormattableMarkup('Link properly added to @name (admin/help/@module)', ['@module' => $module, '@name' => $name])); + $this->assertSession()->linkExists( + $name, + 0, + new FormattableMarkup( + 'Link properly added to @name (admin/help/@module)', ['@module' => $module, '@name' => $name])); } // Ensure a module which does not provide a module overview page is handled diff --git a/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php b/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php index a6f9bc57c561..6d712f2cec55 100644 --- a/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php +++ b/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php @@ -53,7 +53,15 @@ public function testDefaultImages(): void { $file->save(); } $default_images = []; - foreach (['field_storage', 'field', 'field2', 'field_storage_new', 'field_new', 'field_storage_private', 'field_private'] as $image_target) { + foreach ([ + 'field_storage', + 'field', + 'field2', + 'field_storage_new', + 'field_new', + 'field_storage_private', + 'field_private', + ] as $image_target) { $file = File::create((array) array_pop($files)); $file->save(); $default_images[$image_target] = $file; diff --git a/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php b/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php index 8b15f60acade..7cdf276426e5 100644 --- a/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php +++ b/core/modules/image/tests/src/Functional/ImageFieldValidateTest.php @@ -252,14 +252,56 @@ public function testEmpty($field_name, $required, $cardinality, $form_element_na */ public static function providerTestEmpty() { return [ - 'optional-single' => ['field_image', FALSE, 1, 'files[field_image_0]', 'Article Article with edit-access-allowed image field has been created.', 'Article Article with edit-access-forbidden image field has been created.'], - 'optional-unlimited' => ['field_image', FALSE, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, 'files[field_image_0][]', 'Article Article with edit-access-allowed image field has been created.', 'Article Article with edit-access-forbidden image field has been created.'], - 'optional-multiple-limited' => ['field_image', FALSE, 2, 'files[field_image_0][]', 'Article Article with edit-access-allowed image field has been created.', 'Article Article with edit-access-forbidden image field has been created.'], - 'required-single' => ['field_image', TRUE, 1, 'files[field_image_0]', 'field_image field is required.', 'field_image field is required.'], - 'required-unlimited' => ['field_image', TRUE, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, 'files[field_image_0][]', 'field_image field is required.', 'field_image field is required.'], + 'optional-single' => [ + 'field_image', + FALSE, + 1, + 'files[field_image_0]', + 'Article Article with edit-access-allowed image field has been created.', + 'Article Article with edit-access-forbidden image field has been created.', + ], + 'optional-unlimited' => [ + 'field_image', + FALSE, + FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, + 'files[field_image_0][]', + 'Article Article with edit-access-allowed image field has been created.', + 'Article Article with edit-access-forbidden image field has been created.', + ], + 'optional-multiple-limited' => [ + 'field_image', + FALSE, + 2, + 'files[field_image_0][]', + 'Article Article with edit-access-allowed image field has been created.', + 'Article Article with edit-access-forbidden image field has been created.', + ], + 'required-single' => [ + 'field_image', + TRUE, + 1, + 'files[field_image_0]', + 'field_image field is required.', + 'field_image field is required.', + ], + 'required-unlimited' => [ + 'field_image', + TRUE, + FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, + 'files[field_image_0][]', + 'field_image field is required.', + 'field_image field is required.', + ], // @todo Fix this discrepancy in https://www.drupal.org/project/drupal/issues/3011744. - 'required-multiple-limited' => ['field_image', TRUE, 2, 'files[field_image_0][]', 'This value should not be null.', 'Article Article with edit-access-forbidden image field has been created.'], + 'required-multiple-limited' => [ + 'field_image', + TRUE, + 2, + 'files[field_image_0][]', + 'This value should not be null.', + 'Article Article with edit-access-forbidden image field has been created.', + ], ]; } diff --git a/core/modules/image/tests/src/Functional/ImageOnTranslatedEntityTest.php b/core/modules/image/tests/src/Functional/ImageOnTranslatedEntityTest.php index ccbbcfe9a802..85cd8bf6a715 100644 --- a/core/modules/image/tests/src/Functional/ImageOnTranslatedEntityTest.php +++ b/core/modules/image/tests/src/Functional/ImageOnTranslatedEntityTest.php @@ -101,7 +101,10 @@ public function testSyncedImages(): void { $edit[$name] = \Drupal::service('file_system')->realpath($this->drupalGetTestFiles('image')[0]->uri); $this->drupalGet('node/' . $default_language_node->id() . '/edit'); $this->submitForm($edit, 'Save'); - $edit = [$this->fieldName . '[0][alt]' => 'Lost in translation image', $this->fieldName . '[0][title]' => 'Lost in translation image title']; + $edit = [ + $this->fieldName . '[0][alt]' => 'Lost in translation image', + $this->fieldName . '[0][title]' => 'Lost in translation image title', + ]; $this->submitForm($edit, 'Save'); $first_fid = $this->getLastFileId(); @@ -115,7 +118,10 @@ public function testSyncedImages(): void { $name = 'files[' . $this->fieldName . '_0]'; $edit[$name] = \Drupal::service('file_system')->realpath($this->drupalGetTestFiles('image')[1]->uri); $this->submitForm($edit, 'Save (this translation)'); - $edit = [$this->fieldName . '[0][alt]' => 'Scarlett Johansson image', $this->fieldName . '[0][title]' => 'Scarlett Johansson image title']; + $edit = [ + $this->fieldName . '[0][alt]' => 'Scarlett Johansson image', + $this->fieldName . '[0][title]' => 'Scarlett Johansson image title', + ]; $this->submitForm($edit, 'Save (this translation)'); // This inspects the HTML after the post of the translation, the image // should be displayed on the original node. @@ -148,7 +154,10 @@ public function testSyncedImages(): void { $name = 'files[' . $this->fieldName . '_0]'; $edit[$name] = \Drupal::service('file_system')->realpath($this->drupalGetTestFiles('image')[2]->uri); $this->submitForm($edit, 'Save (this translation)'); - $edit = [$this->fieldName . '[0][alt]' => 'Ada Lovelace image', $this->fieldName . '[0][title]' => 'Ada Lovelace image title']; + $edit = [ + $this->fieldName . '[0][alt]' => 'Ada Lovelace image', + $this->fieldName . '[0][title]' => 'Ada Lovelace image title', + ]; $this->submitForm($edit, 'Save (this translation)'); $third_fid = $this->getLastFileId(); diff --git a/core/modules/jsonapi/tests/src/Functional/FileUploadTest.php b/core/modules/jsonapi/tests/src/Functional/FileUploadTest.php index 22f8f7f57d1b..57473c24cbbb 100644 --- a/core/modules/jsonapi/tests/src/Functional/FileUploadTest.php +++ b/core/modules/jsonapi/tests/src/Functional/FileUploadTest.php @@ -288,7 +288,13 @@ public function testPostFileUploadAndUseInSingleRequest(): void { // This request fails despite the upload succeeding, because we're not // allowed to view the entity we're uploading to. $response = $this->fileRequest($uri, $this->testFileData); - $this->assertResourceErrorResponse(403, $this->getExpectedUnauthorizedAccessMessage('GET'), $uri, $response, FALSE, ['4xx-response', 'http_response'], ['url.query_args', 'url.site', 'user.permissions']); + $this->assertResourceErrorResponse( + 403, $this->getExpectedUnauthorizedAccessMessage('GET'), + $uri, + $response, + FALSE, + ['4xx-response', 'http_response'], + ['url.query_args', 'url.site', 'user.permissions']); $this->setUpAuthorization('GET'); diff --git a/core/modules/jsonapi/tests/src/Functional/NodeTest.php b/core/modules/jsonapi/tests/src/Functional/NodeTest.php index 33e96003d6ad..335a87ae9145 100644 --- a/core/modules/jsonapi/tests/src/Functional/NodeTest.php +++ b/core/modules/jsonapi/tests/src/Functional/NodeTest.php @@ -405,7 +405,8 @@ protected function assertNormalizedFieldsAreCached(array $field_names): void { // the internal properties of our variation cache. Reset it. $variation_cache->reset(); - $cache = $variation_cache->get(['node--camelids', $this->entity->uuid(), $this->entity->language()->getId()], new CacheableMetadata()); + $cache = $variation_cache + ->get(['node--camelids', $this->entity->uuid(), $this->entity->language()->getId()], new CacheableMetadata()); $cached_fields = $cache->data['fields']; $this->assertSameSize($field_names, $cached_fields); array_walk($field_names, function ($field_name) use ($cached_fields) { diff --git a/core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php b/core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php index a21c3b895946..31dce001a08e 100644 --- a/core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php +++ b/core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php @@ -526,7 +526,9 @@ protected static function getAccessDeniedResponse(EntityInterface $entity, Acces 'jsonapi' => static::$jsonApiMember, 'errors' => [$error], ], 403)) - ->addCacheableDependency((new CacheableMetadata())->addCacheTags(['4xx-response', 'http_response'])->addCacheContexts(['url.query_args', 'url.site'])) + ->addCacheableDependency((new CacheableMetadata()) + ->addCacheTags(['4xx-response', 'http_response']) + ->addCacheContexts(['url.query_args', 'url.site'])) ->addCacheableDependency($access); } diff --git a/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php b/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php index 43cd406f61bc..549ae1378e20 100644 --- a/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php +++ b/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php @@ -977,7 +977,14 @@ public function testGetIndividual(): void { ], ], ]; - $this->assertResourceResponse(400, $expected_document, $response, ['4xx-response', 'http_response'], ['url.query_args', 'url.site'], 'UNCACHEABLE (request policy)', TRUE); + $this->assertResourceResponse( + 400, + $expected_document, + $response, + ['4xx-response', 'http_response'], + ['url.query_args', 'url.site'], + 'UNCACHEABLE (request policy)', + TRUE); // 200 for well-formed HEAD request. $response = $this->request('HEAD', $url, $request_options); @@ -1062,14 +1069,45 @@ public function testGetIndividual(): void { $url = Url::fromRoute(sprintf('jsonapi.%s.individual', static::$resourceTypeName), ['entity' => $random_uuid]); $response = $this->request('GET', $url, $request_options); $message_url = clone $url; - $path = str_replace($random_uuid, '{entity}', $message_url->setAbsolute()->setOptions(['base_url' => '', 'query' => []])->toString()); + $path = str_replace( + $random_uuid, + '{entity}', + $message_url->setAbsolute()->setOptions(['base_url' => '', 'query' => []])->toString()); $message = 'The "entity" parameter was not converted for the path "' . $path . '" (route name: "jsonapi.' . static::$resourceTypeName . '.individual")'; - $this->assertResourceErrorResponse(404, $message, $url, $response, FALSE, ['4xx-response', 'http_response'], ['url.query_args', 'url.site'], 'UNCACHEABLE (request policy)', 'UNCACHEABLE (poor cacheability)'); + $this->assertResourceErrorResponse( + 404, + $message, + $url, + $response, + FALSE, + [ + '4xx-response', + 'http_response', + ], + [ + 'url.query_args', + 'url.site', + ], + 'UNCACHEABLE (request policy)', 'UNCACHEABLE (poor cacheability)'); // DX: when Accept request header is missing, still 404, same response. unset($request_options[RequestOptions::HEADERS]['Accept']); $response = $this->request('GET', $url, $request_options); - $this->assertResourceErrorResponse(404, $message, $url, $response, FALSE, ['4xx-response', 'http_response'], ['url.query_args', 'url.site'], 'UNCACHEABLE (request policy)', 'UNCACHEABLE (poor cacheability)'); + $this->assertResourceErrorResponse( + 404, + $message, + $url, + $response, + FALSE, + [ + '4xx-response', + 'http_response', + ], + [ + 'url.query_args', + 'url.site', + ], + 'UNCACHEABLE (request policy)', 'UNCACHEABLE (poor cacheability)'); } /** @@ -3031,7 +3069,14 @@ public function testRevisions(): void { 'url.query_args', 'url.site', ]; - $this->assertResourceErrorResponse(400, 'Collection resources only support the following resource version identifiers: rel:latest-version, rel:working-copy', $rel_invalid_collection_url, $actual_response, FALSE, ['4xx-response', 'http_response'], $invalid_version_expected_cache_contexts); + $this->assertResourceErrorResponse( + 400, + 'Collection resources only support the following resource version identifiers: rel:latest-version, rel:working-copy', + $rel_invalid_collection_url, + $actual_response, + FALSE, + ['4xx-response', 'http_response'], + $invalid_version_expected_cache_contexts); // Move the entity to its draft moderation state. $entity->set('field_revisionable_number', 42); diff --git a/core/modules/jsonapi/tests/src/Functional/UserTest.php b/core/modules/jsonapi/tests/src/Functional/UserTest.php index 20076123569e..49c8d28cec1e 100644 --- a/core/modules/jsonapi/tests/src/Functional/UserTest.php +++ b/core/modules/jsonapi/tests/src/Functional/UserTest.php @@ -474,7 +474,16 @@ public function testQueryInvolvingRoles(): void { $response = $this->request('GET', $collection_url, $request_options); $expected_cache_contexts = ['url.path', 'url.query_args', 'url.site']; - $this->assertResourceErrorResponse(400, "Filtering on config entities is not supported by Drupal's entity API. You tried to filter on a Role config entity.", $collection_url, $response, FALSE, ['4xx-response', 'http_response'], $expected_cache_contexts, NULL, 'MISS'); + $this->assertResourceErrorResponse( + 400, + "Filtering on config entities is not supported by Drupal's entity API. You tried to filter on a Role config entity.", + $collection_url, + $response, + FALSE, + ['4xx-response', 'http_response'], + $expected_cache_contexts, + NULL, + 'MISS'); } /** diff --git a/core/modules/language/tests/src/Functional/LanguageListTest.php b/core/modules/language/tests/src/Functional/LanguageListTest.php index 573ff4bd883f..1301f67c8651 100644 --- a/core/modules/language/tests/src/Functional/LanguageListTest.php +++ b/core/modules/language/tests/src/Functional/LanguageListTest.php @@ -216,7 +216,15 @@ public function testLanguageStates(): void { ConfigurableLanguage::create(['label' => $this->randomMachineName(), 'id' => 'l3'])->save(); ConfigurableLanguage::create(['label' => $this->randomMachineName(), 'id' => 'l4', 'locked' => TRUE])->save(); $expected_locked_languages = ['l4' => 'l4', 'l2' => 'l2', 'und' => 'und', 'zxx' => 'zxx']; - $expected_all_languages = ['l4' => 'l4', 'l3' => 'l3', 'l2' => 'l2', 'l1' => 'l1', 'en' => 'en', 'und' => 'und', 'zxx' => 'zxx']; + $expected_all_languages = [ + 'l4' => 'l4', + 'l3' => 'l3', + 'l2' => 'l2', + 'l1' => 'l1', + 'en' => 'en', + 'und' => 'und', + 'zxx' => 'zxx', + ]; $expected_conf_languages = ['l3' => 'l3', 'l1' => 'l1', 'en' => 'en']; $locked_languages = $this->container->get('language_manager')->getLanguages(LanguageInterface::STATE_LOCKED); diff --git a/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php index 858685053db6..c418007971c4 100644 --- a/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php @@ -258,7 +258,11 @@ public function testUILanguageNegotiation(): void { ], // Default, browser language preference is not one of site's lang. [ - 'language_negotiation' => [LanguageNegotiationUrl::METHOD_ID, LanguageNegotiationBrowser::METHOD_ID, LanguageNegotiationSelected::METHOD_ID], + 'language_negotiation' => [ + LanguageNegotiationUrl::METHOD_ID, + LanguageNegotiationBrowser::METHOD_ID, + LanguageNegotiationSelected::METHOD_ID, + ], 'path' => 'admin/config', 'expect' => $default_string, 'expected_method_id' => LanguageNegotiatorInterface::METHOD_ID, diff --git a/core/modules/link/tests/src/Functional/Views/LinkViewsTokensTest.php b/core/modules/link/tests/src/Functional/Views/LinkViewsTokensTest.php index 159865cc8ea0..266562779692 100644 --- a/core/modules/link/tests/src/Functional/Views/LinkViewsTokensTest.php +++ b/core/modules/link/tests/src/Functional/Views/LinkViewsTokensTest.php @@ -79,7 +79,11 @@ public function testLinkViewsTokens(): void { // Add nodes with the URI's and titles. foreach ($uris as $uri => $title) { $values = ['type' => 'page']; - $values[$this->fieldName][] = ['uri' => $uri, 'title' => $title, 'options' => ['attributes' => ['class' => 'test-link-class']]]; + $values[$this->fieldName][] = [ + 'uri' => $uri, + 'title' => $title, + 'options' => ['attributes' => ['class' => 'test-link-class']], + ]; $this->drupalCreateNode($values); } diff --git a/core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php b/core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php index 837c8ba87c14..d586e4d0b5d0 100644 --- a/core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php +++ b/core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php @@ -111,7 +111,8 @@ public function testConfigTranslation(): void { $this->assertEquals($message, $translation['message']); // Check default medium date format exists and create a translation for it. - $string = $this->storage->findString(['source' => 'D, j M Y - H:i', 'context' => 'PHP date format', 'type' => 'configuration']); + $string = $this->storage + ->findString(['source' => 'D, j M Y - H:i', 'context' => 'PHP date format', 'type' => 'configuration']); $this->assertNotEmpty($string, 'Configuration date formats have been created upon installation.'); // Translate using the UI so configuration is refreshed. @@ -155,7 +156,11 @@ public function testConfigTranslation(): void { $this->assertArrayHasKey('image.style.medium', $locations['configuration']); // Check the string is unique and has no translation yet. - $translations = $this->storage->getTranslations(['language' => $this->langcode, 'type' => 'configuration', 'name' => 'image.style.medium']); + $translations = $this->storage->getTranslations([ + 'language' => $this->langcode, + 'type' => 'configuration', + 'name' => 'image.style.medium', + ]); $this->assertCount(1, $translations); $translation = reset($translations); $this->assertEquals($string->source, $translation->source); @@ -179,7 +184,8 @@ public function testConfigTranslation(): void { $this->submitForm($edit, 'Save translations'); // Check the right single translation has been created. - $translations = $this->storage->getTranslations(['language' => $this->langcode, 'type' => 'configuration', 'name' => 'image.style.medium']); + $translations = $this->storage->getTranslations( + ['language' => $this->langcode, 'type' => 'configuration', 'name' => 'image.style.medium']); $translation = reset($translations); $this->assertCount(1, $translations, 'Got only one translation for image configuration.'); $this->assertEquals($string->source, $translation->source); @@ -269,7 +275,11 @@ protected function assertNodeConfig(bool $required, bool $optional): void { } // Check the optional default configuration in node module. - $string = $this->storage->findString(['source' => 'No front page content has been created yet.<br/>Follow the <a target="_blank" href="https://www.drupal.org/docs/user_guide/en/index.html">User Guide</a> to start building your site.', 'context' => '', 'type' => 'configuration']); + $string = $this->storage->findString([ + 'source' => 'No front page content has been created yet.<br/>Follow the <a target="_blank" href="https://www.drupal.org/docs/user_guide/en/index.html">User Guide</a> to start building your site.', + 'context' => '', + 'type' => 'configuration', + ]); if ($optional) { $this->assertFalse($this->config('views.view.frontpage')->isNew()); $this->assertNotEmpty($string, 'Node view text can be found with node and views modules.'); diff --git a/core/modules/locale/tests/src/Functional/LocalePathTest.php b/core/modules/locale/tests/src/Functional/LocalePathTest.php index 3a540ee385ed..bf2d96015371 100644 --- a/core/modules/locale/tests/src/Functional/LocalePathTest.php +++ b/core/modules/locale/tests/src/Functional/LocalePathTest.php @@ -126,7 +126,11 @@ public function testPathLanguageConfiguration(): void { // Create language nodes to check priority of aliases. $first_node = $this->drupalCreateNode(['type' => 'page', 'promote' => 1, 'langcode' => 'en']); - $second_node = $this->drupalCreateNode(['type' => 'page', 'promote' => 1, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED]); + $second_node = $this->drupalCreateNode([ + 'type' => 'page', + 'promote' => 1, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, + ]); // Assign a custom path alias to the first node with the English language. $this->createPathAlias('/node/' . $first_node->id(), '/' . $custom_path, $first_node->language()->getId()); diff --git a/core/modules/media/tests/src/Functional/MediaTemplateSuggestionsTest.php b/core/modules/media/tests/src/Functional/MediaTemplateSuggestionsTest.php index b84db25ec69b..7637577b05dc 100644 --- a/core/modules/media/tests/src/Functional/MediaTemplateSuggestionsTest.php +++ b/core/modules/media/tests/src/Functional/MediaTemplateSuggestionsTest.php @@ -44,7 +44,15 @@ public function testMediaThemeHookSuggestions(): void { $variables['elements'] = $build; $suggestions = \Drupal::moduleHandler()->invokeAll('theme_suggestions_media', [$variables]); - $this->assertSame($suggestions, ['media__full', 'media__' . $media_type->id(), 'media__' . $media_type->id() . '__full', 'media__source_' . $media_type->getSource()->getPluginId()], 'Found expected media suggestions.'); + $this->assertSame( + $suggestions, + [ + 'media__full', + 'media__' . $media_type->id(), + 'media__' . $media_type->id() . '__full', + 'media__source_' . $media_type->getSource()->getPluginId(), + ], + 'Found expected media suggestions.'); } } diff --git a/core/modules/media/tests/src/Functional/MediaUiReferenceWidgetTest.php b/core/modules/media/tests/src/Functional/MediaUiReferenceWidgetTest.php index c42ebc3a5673..8850bd4522b4 100644 --- a/core/modules/media/tests/src/Functional/MediaUiReferenceWidgetTest.php +++ b/core/modules/media/tests/src/Functional/MediaUiReferenceWidgetTest.php @@ -87,9 +87,18 @@ public static function providerTestMediaReferenceWidget() { 'multi-value:single_type:create_list:tags' => [3, [TRUE], TRUE, 'entity_reference_autocomplete_tags'], // Unlimited value field. - 'unlimited_value:single_type:create_list' => [FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, [TRUE], TRUE], + 'unlimited_value:single_type:create_list' => [ + FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, + [TRUE], + TRUE, + ], // Unlimited value field with the tags widget. - 'unlimited_value:single_type:create_list:tags' => [FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, [TRUE], TRUE, 'entity_reference_autocomplete_tags'], + 'unlimited_value:single_type:create_list:tags' => [ + FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, + [TRUE], + TRUE, + 'entity_reference_autocomplete_tags', + ], ]; } diff --git a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentTranslationUITest.php b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentTranslationUITest.php index c8f12118c2d0..d691481b51fd 100644 --- a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentTranslationUITest.php +++ b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentTranslationUITest.php @@ -17,7 +17,15 @@ class MenuLinkContentTranslationUITest extends ContentTranslationUITestBase { /** * {@inheritdoc} */ - protected $defaultCacheContexts = ['languages:language_interface', 'session', 'theme', 'url.path', 'url.query_args', 'user.permissions', 'user.roles:authenticated']; + protected $defaultCacheContexts = [ + 'languages:language_interface', + 'session', + 'theme', + 'url.path', + 'url.query_args', + 'user.permissions', + 'user.roles:authenticated', + ]; /** * {@inheritdoc} diff --git a/core/modules/menu_ui/tests/src/Functional/MenuCacheTagsTest.php b/core/modules/menu_ui/tests/src/Functional/MenuCacheTagsTest.php index 216b68ef6801..f9e186c05fef 100644 --- a/core/modules/menu_ui/tests/src/Functional/MenuCacheTagsTest.php +++ b/core/modules/menu_ui/tests/src/Functional/MenuCacheTagsTest.php @@ -45,8 +45,19 @@ public function testMenuBlock(): void { /** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */ $menu_link_manager = \Drupal::service('plugin.manager.menu.link'); // Move a link into the new menu. - $menu_link = $menu_link_manager->updateDefinition('test_page_test.test_page', ['menu_name' => 'llama', 'parent' => '']); - $block = $this->drupalPlaceBlock('system_menu_block:llama', ['label' => 'Llama', 'provider' => 'system', 'region' => 'footer']); + $menu_link = $menu_link_manager->updateDefinition( + 'test_page_test.test_page', + [ + 'menu_name' => 'llama', + 'parent' => '', + ]); + $block = $this->drupalPlaceBlock( + 'system_menu_block:llama', + [ + 'label' => 'Llama', + 'provider' => 'system', + 'region' => 'footer', + ]); // Prime the page cache. $this->verifyPageCache($url, 'MISS'); diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php index 69b11f376d03..ba0b86f02225 100644 --- a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php @@ -325,7 +325,13 @@ public function testMultilingualMenuNodeFormWidget(): void { // Create translation. $translated_node_title = $this->randomMachineName(8); - $node->addTranslation($langcodes[1], ['title' => $translated_node_title, 'body' => $this->randomMachineName(16), 'status' => 1]); + $node->addTranslation( + $langcodes[1], + [ + 'title' => $translated_node_title, + 'body' => $this->randomMachineName(16), + 'status' => 1, + ]); $node->save(); // Edit the node and create a menu link. diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php index f7f811c5e517..541c7c40b0ef 100644 --- a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php @@ -261,7 +261,9 @@ public function addCustomMenuCRUD(): void { $this->drupalGet('admin/structure/menu'); $this->assertSession()->pageTextContains($new_label); // Click the "Delete menu" operation in the Tools row. - $links = $this->xpath('//*/td[contains(text(),:menu_label)]/following::a[normalize-space()=:link_label]', [':menu_label' => $new_label, ':link_label' => 'Delete menu']); + $links = $this->xpath( + '//*/td[contains(text(),:menu_label)]/following::a[normalize-space()=:link_label]', + [':menu_label' => $new_label, ':link_label' => 'Delete menu']); $links[0]->click(); $this->submitForm([], 'Delete'); $this->assertSession()->addressEquals('admin/structure/menu'); @@ -363,7 +365,9 @@ public function doMenuTests(): void { // Test adding a menu link direct from the menus listing page. $this->drupalGet('admin/structure/menu'); // Click the "Add link" operation in the Tools row. - $links = $this->xpath('//*/td[contains(text(),:menu_label)]/following::a[normalize-space()=:link_label]', [':menu_label' => 'Tools', ':link_label' => 'Add link']); + $links = $this->xpath( + '//*/td[contains(text(),:menu_label)]/following::a[normalize-space()=:link_label]', + [':menu_label' => 'Tools', ':link_label' => 'Add link']); $links[0]->click(); $this->assertMatchesRegularExpression('#admin/structure/menu/manage/tools/add\?destination=(/[^/]*)*/admin/structure/menu/manage/tools$#', $this->getSession()->getCurrentUrl()); $link_title = $this->randomString(); @@ -378,7 +382,12 @@ public function doMenuTests(): void { $this->drupalGet('admin/structure/menu'); // Select the edit menu link for our menu. - $links = $this->xpath('//*/td[contains(text(),:menu_label)]/following::a[normalize-space()=:link_label]', [':menu_label' => (string) $this->menu->label(), ':link_label' => 'Edit menu']); + $links = $this->xpath( + '//*/td[contains(text(),:menu_label)]/following::a[normalize-space()=:link_label]', + [ + ':menu_label' => (string) $this->menu->label(), + ':link_label' => 'Edit menu', + ]); $links[0]->click(); // Test the 'Add link' local action. @@ -404,7 +413,9 @@ public function doMenuTests(): void { $this->drupalGet('admin/structure/menu'); // Select the edit menu link for our menu. - $links = $this->xpath('//*/td[contains(text(),:menu_label)]/following::a[normalize-space()=:link_label]', [':menu_label' => (string) $this->menu->label(), ':link_label' => 'Edit menu']); + $links = $this->xpath( + '//*/td[contains(text(),:menu_label)]/following::a[normalize-space()=:link_label]', + [':menu_label' => (string) $this->menu->label(), ':link_label' => 'Edit menu']); $links[0]->click(); // Test the 'Add link' local action. diff --git a/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php b/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php index 2e584f3b8260..c6b6320d6c0d 100644 --- a/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php +++ b/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php @@ -269,7 +269,16 @@ protected function assertTaxonomyPage(bool $is_admin): void { if (!$is_admin && $tid_is_private) { $should_be_visible = $should_be_visible && $uid == $this->webUser->id(); } - $this->assertSame($should_be_visible, isset($this->nidsVisible[$nid]), strtr('A %private node by user %uid is %visible for user %current_uid on the %tid_is_private page.', ['%private' => $is_private ? 'private' : 'public', '%uid' => $uid, '%visible' => isset($this->nidsVisible[$nid]) ? 'visible' : 'not visible', '%current_uid' => $this->webUser->id(), '%tid_is_private' => $tid_is_private ? 'private' : 'public'])); + $this->assertSame( + $should_be_visible, + isset($this->nidsVisible[$nid]), + strtr('A %private node by user %uid is %visible for user %current_uid on the %tid_is_private page.', [ + '%private' => $is_private ? 'private' : 'public', + '%uid' => $uid, + '%visible' => isset($this->nidsVisible[$nid]) ? 'visible' : 'not visible', + '%current_uid' => $this->webUser->id(), + '%tid_is_private' => $tid_is_private ? 'private' : 'public', + ])); } } } diff --git a/core/modules/node/tests/src/Functional/NodeAccessUnpublishedCacheabilityTest.php b/core/modules/node/tests/src/Functional/NodeAccessUnpublishedCacheabilityTest.php index 7874196660bb..85cc3a76f563 100644 --- a/core/modules/node/tests/src/Functional/NodeAccessUnpublishedCacheabilityTest.php +++ b/core/modules/node/tests/src/Functional/NodeAccessUnpublishedCacheabilityTest.php @@ -37,7 +37,11 @@ public function testNodeAccessCacheabilityBubbleUpOnUnpublishedContent(): void { $test_user1 = $this->drupalCreateUser(values: ['roles' => [$rid]]); $test_user2 = $this->drupalCreateUser(values: ['roles' => [$rid]]); - $unpublished_node_by_test_user1 = $this->createNode(['type' => 'page', 'uid' => $test_user1->id(), 'status' => NodeInterface::NOT_PUBLISHED]); + $unpublished_node_by_test_user1 = $this->createNode([ + 'type' => 'page', + 'uid' => $test_user1->id(), + 'status' => NodeInterface::NOT_PUBLISHED, + ]); $this->drupalLogin($test_user2); $this->drupalGet('node_access_test_auto_bubbling_node_access/' . $unpublished_node_by_test_user1->id()); diff --git a/core/modules/node/tests/src/Functional/NodeAdminTest.php b/core/modules/node/tests/src/Functional/NodeAdminTest.php index db7d47eba49e..b134eb5f9a3a 100644 --- a/core/modules/node/tests/src/Functional/NodeAdminTest.php +++ b/core/modules/node/tests/src/Functional/NodeAdminTest.php @@ -149,8 +149,18 @@ public function testContentAdminPages(): void { $time = time(); $nodes['published_page'] = $this->drupalCreateNode(['type' => 'page', 'changed' => $time--]); $nodes['published_article'] = $this->drupalCreateNode(['type' => 'article', 'changed' => $time--]); - $nodes['unpublished_page_1'] = $this->drupalCreateNode(['type' => 'page', 'changed' => $time--, 'uid' => $this->baseUser1->id(), 'status' => 0]); - $nodes['unpublished_page_2'] = $this->drupalCreateNode(['type' => 'page', 'changed' => $time, 'uid' => $this->baseUser2->id(), 'status' => 0]); + $nodes['unpublished_page_1'] = $this->drupalCreateNode([ + 'type' => 'page', + 'changed' => $time--, + 'uid' => $this->baseUser1->id(), + 'status' => 0, + ]); + $nodes['unpublished_page_2'] = $this->drupalCreateNode([ + 'type' => 'page', + 'changed' => $time, + 'uid' => $this->baseUser2->id(), + 'status' => 0, + ]); // Verify view, edit, and delete links for any content. $this->drupalGet('admin/content'); diff --git a/core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php b/core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php index cda97950c642..41f39b98348d 100644 --- a/core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php +++ b/core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php @@ -141,7 +141,14 @@ public function testRecentNodeBlock(): void { $this->assertSession()->pageTextContains($node3->label()); $this->assertSession()->pageTextContains($node4->label()); - $this->assertCacheContexts(['languages:language_content', 'languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'url.site', 'user']); + $this->assertCacheContexts([ + 'languages:language_content', + 'languages:language_interface', + 'theme', + 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, + 'url.site', + 'user', + ]); // Enable the "Powered by Drupal" block only on article nodes. $theme = \Drupal::service('theme_handler')->getDefault(); @@ -169,7 +176,15 @@ public function testRecentNodeBlock(): void { $label = $block->label(); // Check that block is not displayed on the front page. $this->assertSession()->pageTextNotContains($label); - $this->assertCacheContexts(['languages:language_content', 'languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'url.site', 'user', 'route']); + $this->assertCacheContexts([ + 'languages:language_content', + 'languages:language_interface', + 'theme', + 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, + 'url.site', + 'user', + 'route', + ]); // Ensure that a page that does not have a node context can still be cached. \Drupal::service('module_installer')->install(['dynamic_page_cache_test']); @@ -182,7 +197,16 @@ public function testRecentNodeBlock(): void { $this->drupalGet('node/add/article'); // Check that block is displayed on the add article page. $this->assertSession()->pageTextContains($label); - $this->assertCacheContexts(['languages:language_content', 'languages:language_interface', 'session', 'theme', 'url.path', 'url.query_args', 'user', 'route']); + $this->assertCacheContexts([ + 'languages:language_content', + 'languages:language_interface', + 'session', + 'theme', + 'url.path', + 'url.query_args', + 'user', + 'route', + ]); // The node/add/article page is an admin path and currently uncacheable. $this->assertSession()->responseHeaderEquals('X-Drupal-Dynamic-Cache', 'UNCACHEABLE (poor cacheability)'); @@ -191,7 +215,16 @@ public function testRecentNodeBlock(): void { // Check that block is displayed on the node page when node is of type // 'article'. $this->assertSession()->pageTextContains($label); - $this->assertCacheContexts(['languages:language_content', 'languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'url.site', 'user', 'route', 'timezone']); + $this->assertCacheContexts([ + 'languages:language_content', + 'languages:language_interface', + 'theme', + 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, + 'url.site', + 'user', + 'route', + 'timezone', + ]); $this->assertSession()->responseHeaderEquals('X-Drupal-Dynamic-Cache', 'MISS'); $this->drupalGet('node/' . $node1->id()); $this->assertSession()->responseHeaderEquals('X-Drupal-Dynamic-Cache', 'HIT'); @@ -200,7 +233,16 @@ public function testRecentNodeBlock(): void { // Check that block is not displayed on the node page when node is of type // 'page'. $this->assertSession()->pageTextNotContains($label); - $this->assertCacheContexts(['languages:language_content', 'languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'url.site', 'user', 'route', 'timezone']); + $this->assertCacheContexts([ + 'languages:language_content', + 'languages:language_interface', + 'theme', + 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, + 'url.site', + 'user', + 'route', + 'timezone', + ]); $this->assertSession()->responseHeaderEquals('X-Drupal-Dynamic-Cache', 'MISS'); $this->drupalGet('node/' . $node5->id()); $this->assertSession()->responseHeaderEquals('X-Drupal-Dynamic-Cache', 'HIT'); @@ -225,11 +267,15 @@ public function testRecentNodeBlock(): void { $this->assertSession()->pageTextContains('Displaying node #' . $node1->id() . ', revision #: Node revision 2 title'); // Assert that the revision page for both revisions displays the block. - $this->drupalGet(Url::fromRoute('entity.node.revision', ['node' => $node1->id(), 'node_revision' => $node1_revision_1->getRevisionId()])); + $this->drupalGet(Url::fromRoute( + 'entity.node.revision', + ['node' => $node1->id(), 'node_revision' => $node1_revision_1->getRevisionId()])); $this->assertSession()->pageTextContains($label); $this->assertSession()->pageTextContains('Displaying node #' . $node1->id() . ', revision #' . $node1_revision_1->getRevisionId() . ': ' . $node1_revision_1->label()); - $this->drupalGet(Url::fromRoute('entity.node.revision', ['node' => $node1->id(), 'node_revision' => $node1->getRevisionId()])); + $this->drupalGet(Url::fromRoute( + 'entity.node.revision', + ['node' => $node1->id(), 'node_revision' => $node1->getRevisionId()])); $this->assertSession()->pageTextContains($label); $this->assertSession()->pageTextContains('Displaying node #' . $node1->id() . ', revision #' . $node1->getRevisionId() . ': Node revision 2 title'); diff --git a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php index 2bb252f7c6e1..ad819d57969a 100644 --- a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php +++ b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php @@ -142,7 +142,16 @@ protected function getEditorPermissions(): array { * {@inheritdoc} */ protected function getAdministratorPermissions(): array { - return array_merge(parent::getAdministratorPermissions(), ['access administration pages', 'administer content types', 'administer node fields', 'access content overview', 'bypass node access', 'administer languages', 'administer themes', 'view the administration theme']); + return array_merge(parent::getAdministratorPermissions(), [ + 'access administration pages', + 'administer content types', + 'administer node fields', + 'access content overview', + 'bypass node access', + 'administer languages', + 'administer themes', + 'view the administration theme', + ]); } /** diff --git a/core/modules/node/tests/src/Functional/PagePreviewTest.php b/core/modules/node/tests/src/Functional/PagePreviewTest.php index c30ebc17bc1d..7e2d5747c19c 100644 --- a/core/modules/node/tests/src/Functional/PagePreviewTest.php +++ b/core/modules/node/tests/src/Functional/PagePreviewTest.php @@ -522,7 +522,9 @@ public function testSimultaneousPreview(): void { $edit2 = [$title_key => 'Another page title']; $this->drupalGet('node/' . $node->id() . '/edit'); $this->submitForm($edit2, 'Preview'); - $this->assertSession()->addressEquals(Url::fromRoute('entity.node.preview', ['node_preview' => $node->uuid(), 'view_mode_id' => 'full'])); + $this->assertSession()->addressEquals( + Url::fromRoute('entity.node.preview', + ['node_preview' => $node->uuid(), 'view_mode_id' => 'full'])); $this->assertSession()->pageTextContains($edit2[$title_key]); } diff --git a/core/modules/node/tests/src/Functional/Views/NodeFieldFilterTest.php b/core/modules/node/tests/src/Functional/Views/NodeFieldFilterTest.php index c33d932ead0a..502d4581c896 100644 --- a/core/modules/node/tests/src/Functional/Views/NodeFieldFilterTest.php +++ b/core/modules/node/tests/src/Functional/Views/NodeFieldFilterTest.php @@ -60,7 +60,12 @@ protected function setUp($import_test_views = TRUE, $modules = ['node_test_views ]; // Create node with translations. - $node = $this->drupalCreateNode(['title' => $this->nodeTitles['en'], 'langcode' => 'en', 'type' => 'page', 'body' => [['value' => $this->nodeTitles['en']]]]); + $node = $this->drupalCreateNode([ + 'title' => $this->nodeTitles['en'], + 'langcode' => 'en', + 'type' => 'page', + 'body' => [['value' => $this->nodeTitles['en']]], + ]); foreach (['es', 'fr'] as $langcode) { $translation = $node->addTranslation($langcode, ['title' => $this->nodeTitles[$langcode]]); $translation->body->value = $this->nodeTitles[$langcode]; diff --git a/core/modules/node/tests/src/Functional/Views/NodeIntegrationTest.php b/core/modules/node/tests/src/Functional/Views/NodeIntegrationTest.php index 41e24f110e17..b2bf594490d0 100644 --- a/core/modules/node/tests/src/Functional/Views/NodeIntegrationTest.php +++ b/core/modules/node/tests/src/Functional/Views/NodeIntegrationTest.php @@ -36,7 +36,10 @@ public function testNodeViewTypeArgument(): void { for ($j = 0; $j < 5; $j++) { // Ensure the right order of the nodes. - $node = $this->drupalCreateNode(['type' => $type->id(), 'created' => \Drupal::time()->getRequestTime() - ($i * 5 + $j)]); + $node = $this->drupalCreateNode([ + 'type' => $type->id(), + 'created' => \Drupal::time()->getRequestTime() - ($i * 5 + $j), + ]); $nodes[$type->id()][$node->id()] = $node; $all_nids[] = $node->id(); } diff --git a/core/modules/node/tests/src/Functional/Views/NodeLanguageTest.php b/core/modules/node/tests/src/Functional/Views/NodeLanguageTest.php index 745ace0c0bb3..8b2dfc34e893 100644 --- a/core/modules/node/tests/src/Functional/Views/NodeLanguageTest.php +++ b/core/modules/node/tests/src/Functional/Views/NodeLanguageTest.php @@ -100,7 +100,12 @@ protected function setUp($import_test_views = TRUE, $modules = []): void { } // Create non-translatable nodes. foreach ($this->nodeTitles[LanguageInterface::LANGCODE_NOT_SPECIFIED] as $index => $title) { - $node = $this->drupalCreateNode(['title' => $title, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'type' => 'page', 'promote' => 1]); + $node = $this->drupalCreateNode([ + 'title' => $title, + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, + 'type' => 'page', + 'promote' => 1, + ]); $node->body->value = $this->randomMachineName(32); $node->save(); } diff --git a/core/modules/node/tests/src/Functional/Views/StatusExtraTest.php b/core/modules/node/tests/src/Functional/Views/StatusExtraTest.php index 5d4dbfd659cc..fa68f8a5fc6b 100644 --- a/core/modules/node/tests/src/Functional/Views/StatusExtraTest.php +++ b/core/modules/node/tests/src/Functional/Views/StatusExtraTest.php @@ -50,7 +50,10 @@ public function testStatusExtra(): void { // Create one unpublished node by a user who does not have the `view own // unpublished content` permission. - $node_unpublished3 = $this->drupalCreateNode(['uid' => $node_author_not_unpublished->id(), 'status' => NodeInterface::NOT_PUBLISHED]); + $node_unpublished3 = $this->drupalCreateNode([ + 'uid' => $node_author_not_unpublished->id(), + 'status' => NodeInterface::NOT_PUBLISHED, + ]); // The administrator should simply see all nodes. $this->drupalLogin($admin_user); diff --git a/core/modules/node/tests/src/Functional/Views/Wizard/NodeRevisionWizardTest.php b/core/modules/node/tests/src/Functional/Views/Wizard/NodeRevisionWizardTest.php index 139800853761..7e3c62090e3c 100644 --- a/core/modules/node/tests/src/Functional/Views/Wizard/NodeRevisionWizardTest.php +++ b/core/modules/node/tests/src/Functional/Views/Wizard/NodeRevisionWizardTest.php @@ -28,7 +28,11 @@ public function testViewAdd(): void { // Create two nodes with two revision. $node_storage = \Drupal::entityTypeManager()->getStorage('node'); /** @var \Drupal\node\NodeInterface $node */ - $node = $node_storage->create(['title' => $this->randomString(), 'type' => 'article', 'changed' => \Drupal::time()->getRequestTime() + 40]); + $node = $node_storage->create([ + 'title' => $this->randomString(), + 'type' => 'article', + 'changed' => \Drupal::time()->getRequestTime() + 40, + ]); $node->save(); $node = $node->createDuplicate(); @@ -36,7 +40,11 @@ public function testViewAdd(): void { $node->changed->value = \Drupal::time()->getRequestTime() + 20; $node->save(); - $node = $node_storage->create(['title' => $this->randomString(), 'type' => 'article', 'changed' => \Drupal::time()->getRequestTime() + 30]); + $node = $node_storage->create([ + 'title' => $this->randomString(), + 'type' => 'article', + 'changed' => \Drupal::time()->getRequestTime() + 30, + ]); $node->save(); $node = $node->createDuplicate(); @@ -45,7 +53,11 @@ public function testViewAdd(): void { $node->save(); $this->drupalCreateContentType(['type' => 'not_article']); - $node = $node_storage->create(['title' => $this->randomString(), 'type' => 'not_article', 'changed' => \Drupal::time()->getRequestTime() + 80]); + $node = $node_storage->create([ + 'title' => $this->randomString(), + 'type' => 'not_article', + 'changed' => \Drupal::time()->getRequestTime() + 80, + ]); $node->save(); $type = [ diff --git a/core/modules/page_cache/tests/src/Functional/PageCacheTest.php b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php index 1cbb2cf0c5a3..94a9bde774fe 100644 --- a/core/modules/page_cache/tests/src/Functional/PageCacheTest.php +++ b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php @@ -270,7 +270,8 @@ protected function testPageCacheHeaders(): void { $this->assertSession()->responseHeaderEquals('Foo', 'bar'); // Check replacing default headers. - $this->drupalGet('system-test/set-header', ['query' => ['name' => 'Expires', 'value' => 'Fri, 19 Nov 2008 05:00:00 GMT']]); + $this->drupalGet('system-test/set-header', + ['query' => ['name' => 'Expires', 'value' => 'Fri, 19 Nov 2008 05:00:00 GMT']]); $this->assertSession()->responseHeaderEquals('Expires', 'Fri, 19 Nov 2008 05:00:00 GMT'); $this->drupalGet('system-test/set-header', ['query' => ['name' => 'Vary', 'value' => 'User-Agent']]); $this->assertSession()->responseHeaderContains('Vary', 'user-agent'); diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php index 365f7b2f06ae..b364ba3654b8 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php @@ -507,7 +507,10 @@ public function testGet(): void { $response = $this->request('GET', $url, $request_options); if ($has_canonical_url) { $this->assertSame(403, $response->getStatusCode()); - $dynamic_cache = str_starts_with($response->getHeader('X-Drupal-Cache-Max-Age')[0], '0') || !empty(array_intersect(['user', 'session'], explode(' ', $response->getHeader('X-Drupal-Cache-Contexts')[0]))) ? 'UNCACHEABLE (poor cacheability)' : 'MISS'; + $dynamic_cache = str_starts_with($response->getHeader('X-Drupal-Cache-Max-Age')[0], '0') + || !empty(array_intersect( + ['user', 'session'], + explode(' ', $response->getHeader('X-Drupal-Cache-Contexts')[0]))) ? 'UNCACHEABLE (poor cacheability)' : 'MISS'; $this->assertSame([$dynamic_cache], $response->getHeader('X-Drupal-Dynamic-Cache')); } else { @@ -615,7 +618,14 @@ public function testGet(): void { // 'Vary' headers are also added to the list of headers to ignore, as they // may be added to GET requests, depending on web server configuration. They // are usually 'Transfer-Encoding: chunked' and 'Vary: Accept-Encoding'. - $ignored_headers = ['Date', 'Content-Length', 'X-Drupal-Cache', 'X-Drupal-Dynamic-Cache', 'Transfer-Encoding', 'Vary']; + $ignored_headers = [ + 'Date', + 'Content-Length', + 'X-Drupal-Cache', + 'X-Drupal-Dynamic-Cache', + 'Transfer-Encoding', + 'Vary', + ]; $header_cleaner = function ($headers) use ($ignored_headers) { foreach ($headers as $header => $value) { if (str_starts_with($header, 'X-Drupal-Assertion-') || in_array($header, $ignored_headers)) { @@ -669,7 +679,10 @@ public function testGet(): void { // DX: 404 when GETting non-existing entity. $response = $this->request('GET', $url, $request_options); - $path = str_replace('987654321', '{' . static::$entityTypeId . '}', $url->setAbsolute()->setOptions(['base_url' => '', 'query' => []])->toString()); + $path = str_replace( + '987654321', + '{' . static::$entityTypeId . '}', + $url->setAbsolute()->setOptions(['base_url' => '', 'query' => []])->toString()); $message = 'The "' . static::$entityTypeId . '" parameter was not converted for the path "' . $path . '" (route name: "rest.entity.' . static::$entityTypeId . '.GET")'; $this->assertResourceErrorResponse(404, $message, $response); } diff --git a/core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeResourceTestBase.php index b8e6f180ef47..fb9306e18941 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeResourceTestBase.php @@ -37,7 +37,10 @@ protected function setUpAuthorization($method) { case 'POST': case 'PATCH': case 'DELETE': - $this->grantPermissionsToTestedRole(['use editorial transition publish', 'use editorial transition create_new_draft']); + $this->grantPermissionsToTestedRole([ + 'use editorial transition publish', + 'use editorial transition create_new_draft', + ]); break; } } diff --git a/core/modules/rest/tests/src/Functional/ResourceTestBase.php b/core/modules/rest/tests/src/Functional/ResourceTestBase.php index 02866375e54a..f48222ff6cc4 100644 --- a/core/modules/rest/tests/src/Functional/ResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/ResourceTestBase.php @@ -149,7 +149,11 @@ protected function setUp(): void { * @param string[] $methods * The allowed methods for this resource. */ - protected function provisionResource($formats = [], $authentication = [], array $methods = ['GET', 'POST', 'PATCH', 'DELETE']) { + protected function provisionResource( + $formats = [], + $authentication = [], + array $methods = ['GET', 'POST', 'PATCH', 'DELETE'], + ) { $this->resourceConfigStorage->create([ 'id' => static::$resourceConfigId, 'granularity' => RestResourceConfigInterface::RESOURCE_GRANULARITY, diff --git a/core/modules/rest/tests/src/Functional/Views/StyleSerializerEntityTest.php b/core/modules/rest/tests/src/Functional/Views/StyleSerializerEntityTest.php index af91d1634272..e0871422c2c5 100644 --- a/core/modules/rest/tests/src/Functional/Views/StyleSerializerEntityTest.php +++ b/core/modules/rest/tests/src/Functional/Views/StyleSerializerEntityTest.php @@ -53,7 +53,14 @@ class StyleSerializerEntityTest extends ViewTestBase { * * @var array */ - public static $testViews = ['test_serializer_display_field', 'test_serializer_display_entity', 'test_serializer_display_entity_translated', 'test_serializer_node_display_field', 'test_serializer_node_exposed_filter', 'test_serializer_shared_path']; + public static $testViews = [ + 'test_serializer_display_field', + 'test_serializer_display_entity', + 'test_serializer_display_entity_translated', + 'test_serializer_node_display_field', + 'test_serializer_node_exposed_filter', + 'test_serializer_shared_path', + ]; /** * A user with permissions to look at test entity and configure views. @@ -430,7 +437,10 @@ public function testUIFieldAlias(): void { 'created' => 'created', ]; - $edit = ['row_options[field_options][name][alias]' => $alias_map['name'], 'row_options[field_options][nothing][alias]' => $alias_map['nothing']]; + $edit = [ + 'row_options[field_options][name][alias]' => $alias_map['name'], + 'row_options[field_options][nothing][alias]' => $alias_map['nothing'], + ]; $this->drupalGet($row_options); $this->submitForm($edit, 'Apply'); $this->assertSession()->pageTextContains('The machine-readable name must contain only letters, numbers, dashes and underscores.'); @@ -438,7 +448,10 @@ public function testUIFieldAlias(): void { // Change the map alias value to a valid one. $alias_map['nothing'] = $this->randomMachineName(); - $edit = ['row_options[field_options][name][alias]' => $alias_map['name'], 'row_options[field_options][nothing][alias]' => $alias_map['nothing']]; + $edit = [ + 'row_options[field_options][name][alias]' => $alias_map['name'], + 'row_options[field_options][nothing][alias]' => $alias_map['nothing'], + ]; $this->drupalGet($row_options); $this->submitForm($edit, 'Apply'); diff --git a/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php b/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php index 2b301dad2f34..d69a06b9f69b 100644 --- a/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php +++ b/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php @@ -50,7 +50,14 @@ class StyleSerializerTest extends ViewTestBase { * * @var array */ - public static $testViews = ['test_serializer_display_field', 'test_serializer_display_entity', 'test_serializer_display_entity_translated', 'test_serializer_node_display_field', 'test_serializer_node_exposed_filter', 'test_serializer_shared_path']; + public static $testViews = [ + 'test_serializer_display_field', + 'test_serializer_display_entity', + 'test_serializer_display_entity_translated', + 'test_serializer_node_display_field', + 'test_serializer_node_exposed_filter', + 'test_serializer_shared_path', + ]; /** * A user with permissions to look at test entity and configure views. @@ -261,7 +268,13 @@ public function testRestViewExposedFilter(): void { $this->assertSame($expected, $result, 'Querying a view with no exposed filter returns all nodes.'); // Test that title starts with 'Node 11' query finds 2 of the 3 nodes. - $result = Json::decode($this->drupalGet('test/serialize/node-exposed-filter', ['query' => ['_format' => 'json', 'title' => 'Node 11']])); + $result = Json::decode( + $this->drupalGet('test/serialize/node-exposed-filter', [ + 'query' => [ + '_format' => 'json', + 'title' => 'Node 11', + ], + ])); $expected = [ 0 => [ diff --git a/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php index d6ca9ced6ed6..10fb1d8f22a6 100644 --- a/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php +++ b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php @@ -214,7 +214,10 @@ public function testSearchModuleDisabling(): void { $this->drupalGet('node'); $this->submitForm($terms, 'Search'); $current = $this->getURL(); - $expected = Url::fromRoute('search.view_' . $entity->id(), [], ['query' => ['keys' => $info['keys']], 'absolute' => TRUE])->toString(); + $expected = Url::fromRoute( + 'search.view_' . $entity->id(), + [], + ['query' => ['keys' => $info['keys']], 'absolute' => TRUE])->toString(); $this->assertEquals($expected, $current, 'Block redirected to right search page'); // Try an invalid search path, which should 404. diff --git a/core/modules/search/tests/src/Functional/SearchRankingTest.php b/core/modules/search/tests/src/Functional/SearchRankingTest.php index 0f6ea993a6b4..6759c08d6cf1 100644 --- a/core/modules/search/tests/src/Functional/SearchRankingTest.php +++ b/core/modules/search/tests/src/Functional/SearchRankingTest.php @@ -235,7 +235,12 @@ public function testHTMLRankings(): void { foreach ($shuffled_tags as $tag) { switch ($tag) { case 'a': - $settings['body'] = [['value' => Link::fromTextAndUrl('Drupal Rocks', Url::fromRoute('<front>'))->toString(), 'format' => 'full_html']]; + $settings['body'] = [ + [ + 'value' => Link::fromTextAndUrl('Drupal Rocks', Url::fromRoute('<front>'))->toString(), + 'format' => 'full_html', + ], + ]; break; case 'NoTag': diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutTranslationUITest.php b/core/modules/shortcut/tests/src/Functional/ShortcutTranslationUITest.php index a73f0b685bf2..1ac5e25d1a07 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutTranslationUITest.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutTranslationUITest.php @@ -18,7 +18,15 @@ class ShortcutTranslationUITest extends ContentTranslationUITestBase { /** * {@inheritdoc} */ - protected $defaultCacheContexts = ['languages:language_interface', 'session', 'theme', 'user', 'url.path', 'url.query_args', 'url.site']; + protected $defaultCacheContexts = [ + 'languages:language_interface', + 'session', + 'theme', + 'user', + 'url.path', + 'url.query_args', + 'url.site', + ]; /** * {@inheritdoc} @@ -50,7 +58,9 @@ protected function setUp(): void { * {@inheritdoc} */ protected function getTranslatorPermissions(): array { - return array_merge(parent::getTranslatorPermissions(), ['access shortcuts', 'administer shortcuts', 'access toolbar']); + return array_merge( + parent::getTranslatorPermissions(), + ['access shortcuts', 'administer shortcuts', 'access toolbar']); } /** diff --git a/core/modules/system/tests/src/Functional/Database/SelectTableSortDefaultTest.php b/core/modules/system/tests/src/Functional/Database/SelectTableSortDefaultTest.php index 60b7c12b5a13..7a471be0ec35 100644 --- a/core/modules/system/tests/src/Functional/Database/SelectTableSortDefaultTest.php +++ b/core/modules/system/tests/src/Functional/Database/SelectTableSortDefaultTest.php @@ -61,7 +61,9 @@ public function testTableSortQueryFirst(): void { ]; foreach ($sorts as $sort) { - $this->drupalGet('database_test/tablesort_first/', ['query' => ['order' => $sort['field'], 'sort' => $sort['sort']]]); + $this->drupalGet( + 'database_test/tablesort_first/', + ['query' => ['order' => $sort['field'], 'sort' => $sort['sort']]]); $data = json_decode($this->getSession()->getPage()->getContent()); $first = array_shift($data->tasks); diff --git a/core/modules/system/tests/src/Functional/DrupalKernel/ContainerRebuildWebTest.php b/core/modules/system/tests/src/Functional/DrupalKernel/ContainerRebuildWebTest.php index b1a80ff56289..1ffd78dcf05e 100644 --- a/core/modules/system/tests/src/Functional/DrupalKernel/ContainerRebuildWebTest.php +++ b/core/modules/system/tests/src/Functional/DrupalKernel/ContainerRebuildWebTest.php @@ -33,7 +33,14 @@ public function testSetContainerRebuildWithDifferentDeploymentIdentifier(): void $this->drupalGet('<front>'); $assert->responseHeaderEquals('container_rebuild_indicator', NULL); - $this->writeSettings(['settings' => ['deployment_identifier' => (object) ['value' => 'new-identifier', 'required' => TRUE]]]); + $this->writeSettings([ + 'settings' => [ + 'deployment_identifier' => (object) [ + 'value' => 'new-identifier', + 'required' => TRUE, + ], + ], + ]); $this->drupalGet('<front>'); @@ -52,7 +59,14 @@ public function testContainerInvalidation(): void { // Ensure that after setting the parameter, without a container rebuild the // parameter is still not set. - $this->writeSettings(['settings' => ['container_rebuild_test_parameter' => (object) ['value' => 'rebuild_me', 'required' => TRUE]]]); + $this->writeSettings([ + 'settings' => [ + 'container_rebuild_test_parameter' => (object) [ + 'value' => 'rebuild_me', + 'required' => TRUE, + ], + ], + ]); $this->drupalGet('<front>'); $assert->responseHeaderEquals('container_rebuild_test_parameter', NULL); diff --git a/core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php b/core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php index 2c9897f0cfb1..824a0121d600 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php @@ -325,7 +325,9 @@ public function testReferencedEntity(): void { // The default cache contexts for rendered entities. $default_cache_contexts = ['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme', 'user.permissions']; $entity_cache_contexts = Cache::mergeContexts($default_cache_contexts, ['url.site']); - $page_cache_contexts = Cache::mergeContexts($default_cache_contexts, ['url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user.roles:authenticated']); + $page_cache_contexts = Cache::mergeContexts( + $default_cache_contexts, + ['url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user.roles:authenticated']); // Cache tags present on every rendered page. // 'user.permissions' is a required cache context, and responses that vary diff --git a/core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php b/core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php index 5dfc7d040ea8..c7e1de218cd8 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php @@ -69,7 +69,15 @@ public function testCacheContexts(): void { $build = $list_builder->render(); $this->container->get('renderer')->renderRoot($build); - $this->assertEqualsCanonicalizing(['entity_test_view_grants', 'languages:' . LanguageInterface::TYPE_INTERFACE, 'theme', 'url.query_args.pagers:0', 'user.permissions'], $build['#cache']['contexts']); + $this->assertEqualsCanonicalizing( + [ + 'entity_test_view_grants', + 'languages:' . LanguageInterface::TYPE_INTERFACE, + 'theme', + 'url.query_args.pagers:0', + 'user.permissions', + ], + $build['#cache']['contexts']); } /** diff --git a/core/modules/system/tests/src/Functional/Entity/EntityTranslationFormTest.php b/core/modules/system/tests/src/Functional/Entity/EntityTranslationFormTest.php index 7d6d758dbedf..ebc5c94cc1e3 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityTranslationFormTest.php @@ -93,7 +93,10 @@ public function testEntityFormLanguage(): void { // Enable language selector. $this->drupalGet('admin/structure/types/manage/page'); - $edit = ['language_configuration[language_alterable]' => TRUE, 'language_configuration[langcode]' => LanguageInterface::LANGCODE_NOT_SPECIFIED]; + $edit = [ + 'language_configuration[language_alterable]' => TRUE, + 'language_configuration[langcode]' => LanguageInterface::LANGCODE_NOT_SPECIFIED, + ]; $this->drupalGet('admin/structure/types/manage/page'); $this->submitForm($edit, 'Save'); $this->assertSession()->pageTextContains("The content type Basic page has been updated."); diff --git a/core/modules/system/tests/src/Functional/Form/FormTest.php b/core/modules/system/tests/src/Functional/Form/FormTest.php index 6812903dccc6..efedb9626b9c 100644 --- a/core/modules/system/tests/src/Functional/Form/FormTest.php +++ b/core/modules/system/tests/src/Functional/Form/FormTest.php @@ -60,7 +60,14 @@ protected function setUp(): void { public function testRequiredFields(): void { // Originates from https://www.drupal.org/node/117748. // Sets of empty strings and arrays. - $empty_strings = ['""' => "", '"\n"' => "\n", '" "' => " ", '"\t"' => "\t", '" \n\t "' => " \n\t ", '"\n\n\n\n\n"' => "\n\n\n\n\n"]; + $empty_strings = [ + '""' => "", + '"\n"' => "\n", + '" "' => " ", + '"\t"' => "\t", + '" \n\t "' => " \n\t ", + '"\n\n\n\n\n"' => "\n\n\n\n\n", + ]; $empty_arrays = ['array()' => []]; $empty_checkbox = [NULL]; @@ -88,16 +95,46 @@ public function testRequiredFields(): void { $elements['textarea']['element'] = ['#title' => $this->randomMachineName(), '#type' => 'textarea']; $elements['textarea']['empty_values'] = $empty_strings; - $elements['radios']['element'] = ['#title' => $this->randomMachineName(), '#type' => 'radios', '#options' => ['' => 'None', $this->randomMachineName(), $this->randomMachineName(), $this->randomMachineName()]]; + $elements['radios']['element'] = [ + '#title' => $this->randomMachineName(), + '#type' => 'radios', + '#options' => [ + '' => 'None', + $this->randomMachineName(), + $this->randomMachineName(), + $this->randomMachineName(), + ], + ]; $elements['radios']['empty_values'] = $empty_arrays; - $elements['checkbox']['element'] = ['#title' => $this->randomMachineName(), '#type' => 'checkbox', '#required' => TRUE]; + $elements['checkbox']['element'] = [ + '#title' => $this->randomMachineName(), + '#type' => 'checkbox', + '#required' => TRUE, + ]; $elements['checkbox']['empty_values'] = $empty_checkbox; - $elements['checkboxes']['element'] = ['#title' => $this->randomMachineName(), '#type' => 'checkboxes', '#options' => [$this->randomMachineName(), $this->randomMachineName(), $this->randomMachineName()]]; + $elements['checkboxes']['element'] = [ + '#title' => $this->randomMachineName(), + '#type' => 'checkboxes', + '#options' => [ + $this->randomMachineName(), + $this->randomMachineName(), + $this->randomMachineName(), + ], + ]; $elements['checkboxes']['empty_values'] = $empty_arrays; - $elements['select']['element'] = ['#title' => $this->randomMachineName(), '#type' => 'select', '#options' => ['' => 'None', $this->randomMachineName(), $this->randomMachineName(), $this->randomMachineName()]]; + $elements['select']['element'] = [ + '#title' => $this->randomMachineName(), + '#type' => 'select', + '#options' => [ + '' => 'None', + $this->randomMachineName(), + $this->randomMachineName(), + $this->randomMachineName(), + ], + ]; $elements['select']['empty_values'] = $empty_strings; $elements['file']['element'] = ['#title' => $this->randomMachineName(), '#type' => 'file']; diff --git a/core/modules/system/tests/src/Functional/Form/LanguageSelectElementTest.php b/core/modules/system/tests/src/Functional/Form/LanguageSelectElementTest.php index ab3b89e62d3c..d3ab713e6066 100644 --- a/core/modules/system/tests/src/Functional/Form/LanguageSelectElementTest.php +++ b/core/modules/system/tests/src/Functional/Form/LanguageSelectElementTest.php @@ -64,7 +64,9 @@ public function testLanguageSelectElementOptions(): void { // Test that the #options were not altered by #languages. $this->assertSession()->fieldExists('edit-language-custom-options'); - $this->_testLanguageSelectElementOptions('edit-language-custom-options', ['opt1' => 'First option', 'opt2' => 'Second option', 'opt3' => 'Third option']); + $this->_testLanguageSelectElementOptions( + 'edit-language-custom-options', + ['opt1' => 'First option', 'opt2' => 'Second option', 'opt3' => 'Third option']); } /** @@ -78,7 +80,12 @@ public function testHiddenLanguageSelectElement(): void { $this->container->get('module_installer')->uninstall(['language']); $this->drupalGet('form-test/language_select'); // Check that the language fields were rendered on the page. - $ids = ['edit-languages-all', 'edit-languages-configurable', 'edit-languages-locked', 'edit-languages-config-and-locked']; + $ids = [ + 'edit-languages-all', + 'edit-languages-configurable', + 'edit-languages-locked', + 'edit-languages-config-and-locked', + ]; foreach ($ids as $id) { $this->assertSession()->fieldNotExists($id); } diff --git a/core/modules/system/tests/src/Functional/Menu/LocalActionTest.php b/core/modules/system/tests/src/Functional/Menu/LocalActionTest.php index 0f2121f95ee0..21466f2c6ebe 100644 --- a/core/modules/system/tests/src/Functional/Menu/LocalActionTest.php +++ b/core/modules/system/tests/src/Functional/Menu/LocalActionTest.php @@ -42,8 +42,14 @@ public function testLocalAction(): void { // Ensure that both menu and route based actions are shown. $this->assertLocalAction([ [Url::fromRoute('menu_test.local_action4'), 'My dynamic-title action'], - [Url::fromRoute('menu_test.local_action4'), Html::escape("<script>alert('Welcome to the jungle!')</script>")], - [Url::fromRoute('menu_test.local_action4'), Html::escape("<script>alert('Welcome to the derived jungle!')</script>")], + [ + Url::fromRoute('menu_test.local_action4'), + Html::escape("<script>alert('Welcome to the jungle!')</script>"), + ], + [ + Url::fromRoute('menu_test.local_action4'), + Html::escape("<script>alert('Welcome to the derived jungle!')</script>"), + ], [Url::fromRoute('menu_test.local_action2'), 'My hook_menu action'], [Url::fromRoute('menu_test.local_action3'), 'My YAML discovery action'], [Url::fromRoute('menu_test.local_action5'), 'Title override'], diff --git a/core/modules/system/tests/src/Functional/Routing/RouterTest.php b/core/modules/system/tests/src/Functional/Routing/RouterTest.php index 97fa05f2f99e..94cf58674eb2 100644 --- a/core/modules/system/tests/src/Functional/Routing/RouterTest.php +++ b/core/modules/system/tests/src/Functional/Routing/RouterTest.php @@ -35,7 +35,9 @@ class RouterTest extends BrowserTestBase { */ public function testFinishResponseSubscriber(): void { $renderer_required_cache_contexts = ['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme', 'user.permissions']; - $expected_cache_contexts = Cache::mergeContexts($renderer_required_cache_contexts, ['url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user.roles:authenticated']); + $expected_cache_contexts = Cache::mergeContexts( + $renderer_required_cache_contexts, + ['url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user.roles:authenticated']); sort($expected_cache_contexts); // Confirm that the router can get to a controller. @@ -68,7 +70,9 @@ public function testFinishResponseSubscriber(): void { // X-Drupal-Cache-Contexts and X-Drupal-Cache-Tags headers. // 1. controller result: render array, globally cacheable route access. $this->drupalGet('router_test/test18'); - $expected_cache_contexts = Cache::mergeContexts($renderer_required_cache_contexts, ['url', 'user.roles:authenticated']); + $expected_cache_contexts = Cache::mergeContexts( + $renderer_required_cache_contexts, + ['url', 'user.roles:authenticated']); sort($expected_cache_contexts); $this->assertSession()->responseHeaderEquals('X-Drupal-Cache-Contexts', implode(' ', $expected_cache_contexts)); $this->assertSession()->responseHeaderEquals('X-Drupal-Cache-Tags', 'config:user.role.anonymous foo http_response rendered'); diff --git a/core/modules/system/tests/src/Functional/System/TokenReplaceWebTest.php b/core/modules/system/tests/src/Functional/System/TokenReplaceWebTest.php index 65456eac9186..c56f7fce83f4 100644 --- a/core/modules/system/tests/src/Functional/System/TokenReplaceWebTest.php +++ b/core/modules/system/tests/src/Functional/System/TokenReplaceWebTest.php @@ -38,12 +38,14 @@ public function testTokens(): void { $this->drupalGet('token-test/' . $node->id()); $this->assertSession()->pageTextContains("Tokens: {$node->id()} {$account->id()}"); $this->assertCacheTags(['node:1', 'rendered', 'user:2']); - $this->assertCacheContexts(['languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user']); + $this->assertCacheContexts( + ['languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user']); $this->drupalGet('token-test-without-bubbleable-metadata/' . $node->id()); $this->assertSession()->pageTextContains("Tokens: {$node->id()} {$account->id()}"); $this->assertCacheTags(['node:1', 'rendered', 'user:2']); - $this->assertCacheContexts(['languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user']); + $this->assertCacheContexts( + ['languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user']); } } diff --git a/core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php b/core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php index 5762a135ad66..781664b6313c 100644 --- a/core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php +++ b/core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php @@ -61,7 +61,8 @@ public function testTwigUrlGenerator(): void { 'url (as route) absolute: ' . $url_generator->generateFromRoute('user.register', [], ['absolute' => TRUE]), 'path (as route) not absolute with fragment: ' . $url_generator->generateFromRoute('user.register', [], ['fragment' => 'bottom']), 'url (as route) absolute despite option: ' . $url_generator->generateFromRoute('user.register', [], ['absolute' => TRUE]), - 'url (as route) absolute with fragment: ' . $url_generator->generateFromRoute('user.register', [], ['absolute' => TRUE, 'fragment' => 'bottom']), + 'url (as route) absolute with fragment: ' . $url_generator + ->generateFromRoute('user.register', [], ['absolute' => TRUE, 'fragment' => 'bottom']), ]; // Verify that url() has the ability to bubble cacheability metadata: @@ -90,10 +91,25 @@ public function testTwigLinkGenerator(): void { $generated_url = Url::fromRoute('user.register', [], ['absolute' => TRUE])->toString(TRUE)->getGeneratedUrl(); $expected = [ 'link via the link generator: ' . $link_generator->generate('register', new Url('user.register', [], ['absolute' => TRUE])), - 'link via the link generator: ' . $link_generator->generate('register', new Url('user.register', [], ['absolute' => TRUE, 'attributes' => ['foo' => 'bar']])), - 'link via the link generator: ' . $link_generator->generate('register', new Url('user.register', [], ['attributes' => ['foo' => 'bar', 'id' => 'kitten']])), + 'link via the link generator: ' . $link_generator->generate( + 'register', + new Url( + 'user.register', + [], + ['absolute' => TRUE, 'attributes' => ['foo' => 'bar']])), + 'link via the link generator: ' . $link_generator->generate( + 'register', + new Url( + 'user.register', + [], + ['attributes' => ['foo' => 'bar', 'id' => 'kitten']])), 'link via the link generator: ' . $link_generator->generate('register', new Url('user.register', [], ['attributes' => ['id' => 'kitten']])), - 'link via the link generator: ' . $link_generator->generate('register', new Url('user.register', [], ['attributes' => ['class' => ['llama', 'kitten', 'panda']]])), + 'link via the link generator: ' . $link_generator->generate( + 'register', + new Url( + 'user.register', + [], + ['attributes' => ['class' => ['llama', 'kitten', 'panda']]])), 'link via the link generator: ' . $link_generator->generate(Markup::create('<span>register</span>'), new Url('user.register', [], ['absolute' => TRUE])), 'link via the link generator: <a href="' . $generated_url . '"><span>register</span><svg></svg></a>', 'link via the link generator: ' . $link_generator->generate('register', new Url('user.register', [], ['attributes' => ['foo' => 'bar']])) . ' ' . $link_generator->generate('register', new Url('user.register', [], ['attributes' => ['foo' => 'bar']])), diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php index 8963a8cce4e5..6a3520caf076 100644 --- a/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php +++ b/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php @@ -96,13 +96,17 @@ public function testChanges(): void { $active_theme = $this->themeManager->getActiveTheme(); // Make sure we are not testing the wrong theme. $this->assertEquals('test_theme', $active_theme->getName()); - $this->assertEquals(['starterkit_theme/base', 'starterkit_theme/messages', 'core/normalize', 'test_theme/global-styling'], $active_theme->getLibraries()); + $this->assertEquals( + ['starterkit_theme/base', 'starterkit_theme/messages', 'core/normalize', 'test_theme/global-styling'], + $active_theme->getLibraries()); // @see theme_test_system_info_alter() $this->state->set('theme_test.modify_info_files', TRUE); $this->resetAll(); $active_theme = $this->themeManager->getActiveTheme(); - $this->assertEquals(['starterkit_theme/base', 'starterkit_theme/messages', 'core/normalize', 'test_theme/global-styling', 'core/once'], $active_theme->getLibraries()); + $this->assertEquals( + ['starterkit_theme/base', 'starterkit_theme/messages', 'core/normalize', 'test_theme/global-styling', 'core/once'], + $active_theme->getLibraries()); } } diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php index 2e8c9176375f..383288a3f560 100644 --- a/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php +++ b/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php @@ -321,7 +321,11 @@ public function testInstallModuleWithMissingDependencies(): void { * Tests installing a theme with incompatible module dependencies. */ public function testInstallModuleWithIncompatibleDependencies(): void { - $this->container->get('module_installer')->install(['test_module_compatible_constraint', 'test_module_incompatible_constraint']); + $this->container->get('module_installer') + ->install([ + 'test_module_compatible_constraint', + 'test_module_incompatible_constraint', + ]); $this->drupalGet('admin/appearance'); $theme_container = $this->getSession()->getPage()->find('css', 'h3:contains("Test Theme Depending on Version Constrained Modules")')->getParent(); $this->assertStringContainsString('Requires: Test Module Theme Depends on with Compatible ConstraintTest Module Theme Depends on with Incompatible Constraint (>=8.x-2.x) (incompatible with version 8.x-1.8)', $theme_container->getText()); diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeUpdateTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeUpdateTest.php index b523c2bd50f7..66a3a702912b 100644 --- a/core/modules/system/tests/src/Functional/Theme/ThemeUpdateTest.php +++ b/core/modules/system/tests/src/Functional/Theme/ThemeUpdateTest.php @@ -30,7 +30,9 @@ class ThemeUpdateTest extends BrowserTestBase { public function testThemeUpdates(): void { \Drupal::service('module_installer')->install(['test_module_required_by_theme']); $this->rebuildAll(); - \Drupal::state()->set('test_theme_depending_on_modules.system_info_alter', ['dependencies' => ['test_module_required_by_theme', 'stark']]); + \Drupal::state()->set( + 'test_theme_depending_on_modules.system_info_alter', + ['dependencies' => ['test_module_required_by_theme', 'stark']]); \Drupal::service('theme_installer')->install(['test_theme_depending_on_modules']); $this->assertTrue(\Drupal::service('theme_handler')->themeExists('test_theme_depending_on_modules'), 'test_theme_depending_on_modules theme installed'); \Drupal::state()->set('test_theme_depending_on_modules.system_info_alter', FALSE); diff --git a/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php b/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php index 01160807387d..625c0813a56f 100644 --- a/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php +++ b/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php @@ -34,7 +34,12 @@ class TwigRegistryLoaderTest extends BrowserTestBase { */ protected function setUp(): void { parent::setUp(); - \Drupal::service('theme_installer')->install(['test_theme_twig_registry_loader', 'test_theme_twig_registry_loader_theme', 'test_theme_twig_registry_loader_subtheme']); + \Drupal::service('theme_installer') + ->install([ + 'test_theme_twig_registry_loader', + 'test_theme_twig_registry_loader_theme', + 'test_theme_twig_registry_loader_subtheme', + ]); $this->twig = \Drupal::service('twig'); } diff --git a/core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php b/core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php index f36f28c1d606..a3f933e2fe44 100644 --- a/core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php +++ b/core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php @@ -329,7 +329,8 @@ public function testPatchPath(): void { * {@inheritdoc} */ protected function getExpectedCacheTags() { - return Cache::mergeTags(parent::getExpectedCacheTags(), ['config:filter.format.plain_text', 'config:filter.settings']); + return Cache::mergeTags( + parent::getExpectedCacheTags(), ['config:filter.format.plain_text', 'config:filter.settings']); } /** diff --git a/core/modules/taxonomy/tests/src/Functional/TermParentsTest.php b/core/modules/taxonomy/tests/src/Functional/TermParentsTest.php index 59ab2ecf3c9a..e7b243bbfcd3 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermParentsTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermParentsTest.php @@ -260,22 +260,27 @@ public function testParentFromQuery(): void { $term_3 = $this->createTerm('Test term 3'); // Add term form with one parent. - $this->drupalGet("/admin/structure/taxonomy/manage/{$this->vocabularyId}/add", ['query' => ['parent' => $term_1->id()]]); + $this->drupalGet( + "/admin/structure/taxonomy/manage/{$this->vocabularyId}/add", ['query' => ['parent' => $term_1->id()]]); $this->assertParentOption('Test term 1', TRUE); $this->assertParentOption('Test term 2', FALSE); $this->assertParentOption('Test term 3', FALSE); // Add term form with two parents. - $this->drupalGet("/admin/structure/taxonomy/manage/{$this->vocabularyId}/add", ['query' => ['parent[0]' => $term_1->id(), 'parent[1]' => $term_2->id()]]); + $this->drupalGet( + "/admin/structure/taxonomy/manage/{$this->vocabularyId}/add", + ['query' => ['parent[0]' => $term_1->id(), 'parent[1]' => $term_2->id()]]); $this->assertParentOption('Test term 1', TRUE); $this->assertParentOption('Test term 2', TRUE); $this->assertParentOption('Test term 3', FALSE); // Add term form with no parents. - $this->drupalGet("/admin/structure/taxonomy/manage/{$this->vocabularyId}/add", ['query' => ['parent' => '']]); + $this->drupalGet( + "/admin/structure/taxonomy/manage/{$this->vocabularyId}/add", ['query' => ['parent' => '']]); $this->assertParentOption('Test term 1', FALSE); $this->assertParentOption('Test term 2', FALSE); $this->assertParentOption('Test term 3', FALSE); // Add term form with invalid parent. - $this->drupalGet("/admin/structure/taxonomy/manage/{$this->vocabularyId}/add", ['query' => ['parent' => -1]]); + $this->drupalGet( + "/admin/structure/taxonomy/manage/{$this->vocabularyId}/add", ['query' => ['parent' => -1]]); $this->assertParentOption('Test term 1', FALSE); $this->assertParentOption('Test term 2', FALSE); $this->assertParentOption('Test term 3', FALSE); @@ -285,7 +290,8 @@ public function testParentFromQuery(): void { $this->assertParentOption('Test term 2', TRUE); $this->assertParentOption('Test term 3', FALSE); // Edit term form with two parents. - $this->drupalGet($term_1->toUrl('edit-form'), ['query' => ['parent[0]' => $term_2->id(), 'parent[1]' => $term_3->id()]]); + $this->drupalGet( + $term_1->toUrl('edit-form'), ['query' => ['parent[0]' => $term_2->id(), 'parent[1]' => $term_3->id()]]); $this->assertParentOption('Test term 2', TRUE); $this->assertParentOption('Test term 3', TRUE); // Edit term form with no parents. diff --git a/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php b/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php index ceb2907511a9..ba89e56e1325 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php @@ -127,7 +127,8 @@ public function testTranslationUI(): void { * Tests translate link on vocabulary term list. */ public function testTranslateLinkVocabularyAdminPage(): void { - $this->drupalLogin($this->drupalCreateUser(array_merge(parent::getTranslatorPermissions(), ['access administration pages', 'administer taxonomy']))); + $this->drupalLogin($this->drupalCreateUser(array_merge( + parent::getTranslatorPermissions(), ['access administration pages', 'administer taxonomy']))); $values = [ 'name' => $this->randomMachineName(), diff --git a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldFilterTest.php b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldFilterTest.php index 36d6444b7801..b3346941eae8 100644 --- a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldFilterTest.php +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldFilterTest.php @@ -98,7 +98,12 @@ protected function setUp($import_test_views = TRUE, $modules = []): void { ])->save(); // Create term with translations. - $taxonomy = $this->createTermWithProperties(['name' => $this->termNames['en'], 'langcode' => 'en', 'description' => $this->termNames['en'], 'field_foo' => $this->termNames['en']]); + $taxonomy = $this->createTermWithProperties([ + 'name' => $this->termNames['en'], + 'langcode' => 'en', + 'description' => $this->termNames['en'], + 'field_foo' => $this->termNames['en'], + ]); foreach (['es', 'fr'] as $langcode) { $translation = $taxonomy->addTranslation($langcode, ['name' => $this->termNames[$langcode]]); $translation->description->value = $this->termNames[$langcode]; diff --git a/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php b/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php index d4648aa24214..720d6728d77a 100644 --- a/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php +++ b/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php @@ -389,7 +389,17 @@ public function testSubtreesJsonRequest(): void { $this->drupalGet('toolbar/subtrees/' . $subtrees_hash, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']], ['X-Requested-With' => 'XMLHttpRequest']); $ajax_result = json_decode($this->getSession()->getPage()->getContent(), TRUE); $this->assertEquals('setToolbarSubtrees', $ajax_result[0]['command'], 'Subtrees response uses the correct command.'); - $this->assertEquals(['system-admin_content', 'system-admin_structure', 'system-themes_page', 'system-modules_list', 'system-admin_config', 'entity-user-collection', 'front'], array_keys($ajax_result[0]['subtrees']), 'Correct subtrees returned.'); + $this->assertEquals( + [ + 'system-admin_content', + 'system-admin_structure', + 'system-themes_page', + 'system-modules_list', + 'system-admin_config', + 'entity-user-collection', + 'front', + ], + array_keys($ajax_result[0]['subtrees']), 'Correct subtrees returned.'); } /** diff --git a/core/modules/user/tests/src/Functional/Rest/UserResourceTestBase.php b/core/modules/user/tests/src/Functional/Rest/UserResourceTestBase.php index c671b632c7f4..83c3ff21a451 100644 --- a/core/modules/user/tests/src/Functional/Rest/UserResourceTestBase.php +++ b/core/modules/user/tests/src/Functional/Rest/UserResourceTestBase.php @@ -174,7 +174,9 @@ public function testPatchDxForSecuritySensitiveBaseFields(): void { /** @var \Drupal\user\UserInterface $user */ $user = static::$auth ? $this->account : User::load(0); // @todo Remove the array_diff_key() call in https://www.drupal.org/node/2821077. - $original_normalization = array_diff_key($this->serializer->normalize($user, static::$format), ['created' => TRUE, 'changed' => TRUE, 'name' => TRUE]); + $original_normalization = array_diff_key( + $this->serializer->normalize($user, static::$format), + ['created' => TRUE, 'changed' => TRUE, 'name' => TRUE]); // Since this test must be performed by the user that is being modified, // we cannot use $this->getUrl(). diff --git a/core/modules/user/tests/src/Functional/UserTokenReplaceTest.php b/core/modules/user/tests/src/Functional/UserTokenReplaceTest.php index f41476bbf372..c97854ab83a5 100644 --- a/core/modules/user/tests/src/Functional/UserTokenReplaceTest.php +++ b/core/modules/user/tests/src/Functional/UserTokenReplaceTest.php @@ -150,24 +150,37 @@ public function testUserTokenReplacement(): void { // Generate tokens with interface language. $link = Url::fromRoute('user.page', [], ['absolute' => TRUE])->toString(); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, ['user' => $account], ['langcode' => $language_interface->getId(), 'callback' => 'user_mail_tokens', 'clear' => TRUE]); + $output = $token_service->replace( + $input, + ['user' => $account], + ['langcode' => $language_interface->getId(), 'callback' => 'user_mail_tokens', 'clear' => TRUE]); $this->assertStringStartsWith($link, $output, 'Generated URL is in interface language.'); } // Generate tokens with the user's preferred language. $account->preferred_langcode = 'de'; $account->save(); - $link = Url::fromRoute('user.page', [], ['language' => \Drupal::languageManager()->getLanguage($account->getPreferredLangcode()), 'absolute' => TRUE])->toString(); + $link = Url::fromRoute( + 'user.page', + [], + ['language' => \Drupal::languageManager()->getLanguage($account->getPreferredLangcode()), 'absolute' => TRUE])->toString(); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, ['user' => $account], ['callback' => 'user_mail_tokens', 'clear' => TRUE]); + $output = $token_service->replace( + $input, + ['user' => $account], + ['callback' => 'user_mail_tokens', 'clear' => TRUE]); $this->assertStringStartsWith($link, $output, "Generated URL is in the user's preferred language."); } // Generate tokens with one specific language. - $link = Url::fromRoute('user.page', [], ['language' => \Drupal::languageManager()->getLanguage('de'), 'absolute' => TRUE])->toString(); + $link = Url::fromRoute( + 'user.page', + [], + ['language' => \Drupal::languageManager()->getLanguage('de'), 'absolute' => TRUE])->toString(); foreach ($tests as $input => $expected) { foreach ([$user1, $user2] as $account) { - $output = $token_service->replace($input, ['user' => $account], ['langcode' => 'de', 'callback' => 'user_mail_tokens', 'clear' => TRUE]); + $output = $token_service->replace( + $input, ['user' => $account], ['langcode' => 'de', 'callback' => 'user_mail_tokens', 'clear' => TRUE]); $this->assertStringStartsWith($link, $output, "Generated URL in the requested language."); } } diff --git a/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php b/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php index 72fd5a0cd297..80203b8cbcd3 100644 --- a/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php +++ b/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php @@ -28,7 +28,13 @@ class FieldWebTest extends ViewTestBase { * * @var array */ - public static $testViews = ['test_view', 'test_field_classes', 'test_field_output', 'test_click_sort', 'test_distinct_click_sorting']; + public static $testViews = [ + 'test_view', + 'test_field_classes', + 'test_field_output', + 'test_click_sort', + 'test_distinct_click_sorting', + ]; /** * {@inheritdoc} @@ -75,9 +81,18 @@ public function testClickSorting(): void { $this->assertSession()->statusCodeEquals(200); // Only the id and name should be click sortable, but not the name. - $this->assertSession()->linkByHrefExists(Url::fromRoute('<none>', [], ['query' => ['order' => 'id', 'sort' => 'asc']])->toString()); - $this->assertSession()->linkByHrefExists(Url::fromRoute('<none>', [], ['query' => ['order' => 'name', 'sort' => 'desc']])->toString()); - $this->assertSession()->linkByHrefNotExists(Url::fromRoute('<none>', [], ['query' => ['order' => 'created']])->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute( + '<none>', + [], + ['query' => ['order' => 'id', 'sort' => 'asc']])->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute( + '<none>', + [], + ['query' => ['order' => 'name', 'sort' => 'desc']])->toString()); + $this->assertSession()->linkByHrefNotExists(Url::fromRoute( + '<none>', + [], + ['query' => ['order' => 'created']])->toString()); // Check that the view returns the click sorting cache contexts. $expected_contexts = [ @@ -114,7 +129,10 @@ public function testClickSortingDistinct(): void { // Check that the results are ordered by id in ascending order and that the // title click filter is for descending. - $this->assertSession()->linkByHrefExists(Url::fromRoute('<none>', [], ['query' => ['order' => 'changed', 'sort' => 'desc']])->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute( + '<none>', + [], + ['query' => ['order' => 'changed', 'sort' => 'desc']])->toString()); $this->assertSession()->pageTextContains($node->getTitle()); $this->clickLink('Changed'); $this->assertSession()->statusCodeEquals(200); @@ -262,21 +280,30 @@ public function testAlterUrl(): void { }); $this->assertSubString($result, $expected_result); - $expected_result = Url::fromRoute('entity.node.canonical', ['node' => '123'], ['fragment' => 'foo', 'absolute' => $absolute])->toString(); + $expected_result = Url::fromRoute( + 'entity.node.canonical', + ['node' => '123'], + ['fragment' => 'foo', 'absolute' => $absolute])->toString(); $alter['path'] = 'node/123#foo'; $result = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) { return $id_field->theme($row); }); $this->assertSubString($result, $expected_result); - $expected_result = Url::fromRoute('entity.node.canonical', ['node' => '123'], ['query' => ['foo' => NULL], 'absolute' => $absolute])->toString(); + $expected_result = Url::fromRoute( + 'entity.node.canonical', + ['node' => '123'], + ['query' => ['foo' => NULL], 'absolute' => $absolute])->toString(); $alter['path'] = 'node/123?foo'; $result = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) { return $id_field->theme($row); }); $this->assertSubString($result, $expected_result); - $expected_result = Url::fromRoute('entity.node.canonical', ['node' => '123'], ['query' => ['foo' => 'bar', 'bar' => 'baz'], 'absolute' => $absolute])->toString(); + $expected_result = Url::fromRoute( + 'entity.node.canonical', + ['node' => '123'], + ['query' => ['foo' => 'bar', 'bar' => 'baz'], 'absolute' => $absolute])->toString(); $alter['path'] = 'node/123?foo=bar&bar=baz'; $result = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) { return $id_field->theme($row); @@ -286,7 +313,9 @@ public function testAlterUrl(): void { // @todo The route-based URL generator strips out NULL attributes. // phpcs:ignore // $expected_result = Url::fromRoute('entity.node.canonical', ['node' => '123'], ['query' => ['foo' => NULL], 'fragment' => 'bar', 'absolute' => $absolute])->toString(); - $expected_result = Url::fromUserInput('/node/123', ['query' => ['foo' => NULL], 'fragment' => 'bar', 'absolute' => $absolute])->toString(); + $expected_result = Url::fromUserInput( + '/node/123', + ['query' => ['foo' => NULL], 'fragment' => 'bar', 'absolute' => $absolute])->toString(); $alter['path'] = 'node/123?foo#bar'; $result = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) { return $id_field->theme($row); diff --git a/core/modules/views/tests/src/Functional/Handler/HandlerTest.php b/core/modules/views/tests/src/Functional/Handler/HandlerTest.php index fa9af239ca3e..81b7385c8aef 100644 --- a/core/modules/views/tests/src/Functional/Handler/HandlerTest.php +++ b/core/modules/views/tests/src/Functional/Handler/HandlerTest.php @@ -27,7 +27,13 @@ class HandlerTest extends ViewTestBase { * * @var array */ - public static $testViews = ['test_view', 'test_view_handler_weight', 'test_handler_relationships', 'test_handler_test_access', 'test_filter_in_operator_ui']; + public static $testViews = [ + 'test_view', + 'test_view_handler_weight', + 'test_handler_relationships', + 'test_handler_test_access', + 'test_filter_in_operator_ui', + ]; /** * {@inheritdoc} diff --git a/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php b/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php index d1f72fc9cbcb..06964878cc22 100644 --- a/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php @@ -22,7 +22,12 @@ class DisplayPageWebTest extends ViewTestBase { * * @var array */ - public static $testViews = ['test_page_display', 'test_page_display_arguments', 'test_page_display_menu', 'test_page_display_path']; + public static $testViews = [ + 'test_page_display', + 'test_page_display_arguments', + 'test_page_display_menu', + 'test_page_display_path', + ]; /** * {@inheritdoc} diff --git a/core/modules/views/tests/src/Functional/Plugin/DisplayTest.php b/core/modules/views/tests/src/Functional/Plugin/DisplayTest.php index 7b5b1a8fd7b9..d406b9faf3e9 100644 --- a/core/modules/views/tests/src/Functional/Plugin/DisplayTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/DisplayTest.php @@ -22,7 +22,16 @@ class DisplayTest extends ViewTestBase { * * @var array */ - public static $testViews = ['test_filter_groups', 'test_get_attach_displays', 'test_view', 'test_display_more', 'test_display_invalid', 'test_display_empty', 'test_exposed_relationship_admin_ui', 'test_simple_argument']; + public static $testViews = [ + 'test_filter_groups', + 'test_get_attach_displays', + 'test_view', + 'test_display_more', + 'test_display_invalid', + 'test_display_empty', + 'test_exposed_relationship_admin_ui', + 'test_simple_argument', + ]; /** * {@inheritdoc} @@ -389,8 +398,22 @@ public function testMissingRelationship(): void { $errors = $view->validate(); // Check that the error messages are shown. $this->assertCount(2, $errors['default'], 'Error messages found for required relationship'); - $this->assertEquals(new FormattableMarkup('The %relationship_name relationship used in %handler_type %handler is not present in the %display_name display.', ['%relationship_name' => 'uid', '%handler_type' => 'field', '%handler' => 'User: Last login', '%display_name' => 'Default']), $errors['default'][0]); - $this->assertEquals(new FormattableMarkup('The %relationship_name relationship used in %handler_type %handler is not present in the %display_name display.', ['%relationship_name' => 'uid', '%handler_type' => 'field', '%handler' => 'User: Created', '%display_name' => 'Default']), $errors['default'][1]); + $this->assertEquals(new FormattableMarkup( + 'The %relationship_name relationship used in %handler_type %handler is not present in the %display_name display.', + [ + '%relationship_name' => 'uid', + '%handler_type' => 'field', + '%handler' => 'User: Last login', + '%display_name' => 'Default', + ]), $errors['default'][0]); + $this->assertEquals( + new FormattableMarkup('The %relationship_name relationship used in %handler_type %handler is not present in the %display_name display.', + [ + '%relationship_name' => 'uid', + '%handler_type' => 'field', + '%handler' => 'User: Created', + '%display_name' => 'Default', + ]), $errors['default'][1]); } /** diff --git a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php index 7d2af0f1a4dd..26c576330e36 100644 --- a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php @@ -28,7 +28,13 @@ class ExposedFormTest extends ViewTestBase { * * @var array */ - public static $testViews = ['test_exposed_form_buttons', 'test_exposed_block', 'test_exposed_form_sort_items_per_page', 'test_exposed_form_pager', 'test_remember_selected']; + public static $testViews = [ + 'test_exposed_form_buttons', + 'test_exposed_block', + 'test_exposed_form_sort_items_per_page', + 'test_exposed_form_pager', + 'test_remember_selected', + ]; /** * {@inheritdoc} @@ -414,11 +420,15 @@ public function testExposedSortAndItemsPerPage(): void { $this->assertCacheContexts($contexts); $this->assertIds(range(50, 41, 1)); - $this->drupalGet('test_exposed_form_sort_items_per_page', ['query' => ['sort_order' => 'DESC', 'items_per_page' => 25]]); + $this->drupalGet( + 'test_exposed_form_sort_items_per_page', + ['query' => ['sort_order' => 'DESC', 'items_per_page' => 25]]); $this->assertCacheContexts($contexts); $this->assertIds(range(50, 26, 1)); - $this->drupalGet('test_exposed_form_sort_items_per_page', ['query' => ['sort_order' => 'DESC', 'items_per_page' => 25, 'offset' => 10]]); + $this->drupalGet( + 'test_exposed_form_sort_items_per_page', + ['query' => ['sort_order' => 'DESC', 'items_per_page' => 25, 'offset' => 10]]); $this->assertCacheContexts($contexts); $this->assertIds(range(40, 16, 1)); diff --git a/core/modules/views/tests/src/Functional/Plugin/PagerTest.php b/core/modules/views/tests/src/Functional/Plugin/PagerTest.php index cf381282443f..b39bc01d8a90 100644 --- a/core/modules/views/tests/src/Functional/Plugin/PagerTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/PagerTest.php @@ -24,7 +24,15 @@ class PagerTest extends ViewTestBase { * * @var array */ - public static $testViews = ['test_store_pager_settings', 'test_pager_none', 'test_pager_some', 'test_pager_full', 'test_view_pager_full_zero_items_per_page', 'test_view', 'content']; + public static $testViews = [ + 'test_store_pager_settings', + 'test_pager_none', + 'test_pager_some', + 'test_pager_full', + 'test_view_pager_full_zero_items_per_page', + 'test_view', + 'content', + ]; /** * {@inheritdoc} @@ -361,7 +369,13 @@ public function testNormalPager(): void { // Test pager cache contexts. $this->drupalGet('test_pager_full'); - $this->assertCacheContexts(['languages:language_interface', 'theme', 'timezone', 'url.query_args', 'user.node_grants:view']); + $this->assertCacheContexts([ + 'languages:language_interface', + 'theme', + 'timezone', + 'url.query_args', + 'user.node_grants:view', + ]); // Set "Number of pager links visible" to 1 and check the active page number // on the last page. diff --git a/core/modules/workflows/tests/src/Functional/WorkflowUiTest.php b/core/modules/workflows/tests/src/Functional/WorkflowUiTest.php index df13fac20658..bc7f8b0a444f 100644 --- a/core/modules/workflows/tests/src/Functional/WorkflowUiTest.php +++ b/core/modules/workflows/tests/src/Functional/WorkflowUiTest.php @@ -154,7 +154,14 @@ public function testWorkflowCreation(): void { $this->clickLink('Add a new transition'); $this->assertCount(2, $this->cssSelect('input[name="to"][type="radio"]')); $this->assertCount(0, $this->cssSelect('input[name="to"][checked="checked"][type="radio"]')); - $this->submitForm(['id' => 'create_new_draft', 'label' => 'Create new draft', 'from[draft]' => 'draft', 'to' => 'draft'], 'Save'); + $this->submitForm( + [ + 'id' => 'create_new_draft', + 'label' => 'Create new draft', + 'from[draft]' => 'draft', + 'to' => 'draft', + ], + 'Save'); $this->assertSession()->pageTextContains('Created Create new draft transition.'); $workflow = $workflow_storage->loadUnchanged('test'); $this->assertTrue($workflow->getTypePlugin()->getState('draft')->canTransitionTo('draft'), 'Can transition from draft to draft'); @@ -175,14 +182,37 @@ public function testWorkflowCreation(): void { // Try creating a duplicate transition. $this->clickLink('Add a new transition'); - $this->submitForm(['id' => 'create_new_draft', 'label' => 'Create new draft', 'from[published]' => 'published', 'to' => 'draft'], 'Save'); - $this->assertSession()->pageTextContains('The machine-readable name is already in use. It must be unique.'); + $this->submitForm( + [ + 'id' => 'create_new_draft', + 'label' => 'Create new draft', + 'from[published]' => 'published', + 'to' => 'draft', + ], + 'Save'); + $this->assertSession() + ->pageTextContains('The machine-readable name is already in use. It must be unique.'); // Try creating a transition which duplicates the states of another. - $this->submitForm(['id' => 'create_new_draft2', 'label' => 'Create new draft again', 'from[published]' => 'published', 'to' => 'draft'], 'Save'); - $this->assertSession()->pageTextContains('The transition from Live to Draft already exists.'); + $this->submitForm( + [ + 'id' => 'create_new_draft2', + 'label' => 'Create new draft again', + 'from[published]' => 'published', + 'to' => 'draft', + ], + 'Save'); + $this->assertSession() + ->pageTextContains('The transition from Live to Draft already exists.'); // Create a new transition. - $this->submitForm(['id' => 'save_and_publish', 'label' => 'Save and publish', 'from[published]' => 'published', 'to' => 'published'], 'Save'); + $this->submitForm( + [ + 'id' => 'save_and_publish', + 'label' => 'Save and publish', + 'from[published]' => 'published', + 'to' => 'published', + ], + 'Save'); $this->assertSession()->pageTextContains('Created Save and publish transition.'); // Edit the new transition and try to add an existing transition. $this->clickLink('Edit', 4); diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist index 50039ecc1717..cc66c41eedec 100644 --- a/core/phpcs.xml.dist +++ b/core/phpcs.xml.dist @@ -34,6 +34,7 @@ <include-pattern>core/*/Unit/*</include-pattern> <include-pattern>core/*/FunctionalJavascript/*</include-pattern> <include-pattern>core/*/Kernel/*</include-pattern> + <include-pattern>core/*/Functional/*</include-pattern> <include-pattern>core/lib/*</include-pattern> <include-pattern>core/modules/*/tests/modules/*</include-pattern> </rule> -- GitLab From bb86fe38e801f994844a80fb8d0b4b0067ee133f Mon Sep 17 00:00:00 2001 From: quietone <quietone@2572884.no-reply.drupal.org> Date: Sat, 15 Mar 2025 13:34:27 +1300 Subject: [PATCH 2/2] remove ignore from DisplayBlockTest --- .../src/Functional/Views/DisplayBlockTest.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php b/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php index 8044fffa1f07..2c6fd91cbfcd 100644 --- a/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php +++ b/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php @@ -430,10 +430,18 @@ public function testBlockContextualLinks(): void { $cached_id_token = Crypt::hmacBase64($cached_id, Settings::getHashSalt() . $this->container->get('private_key')->get()); // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder() // Check existence of the contextual link placeholders. - // phpcs:disable Drupal.Arrays.Array.LongLineDeclaration - $this->assertSession()->responseContains('<div' . new Attribute(['data-contextual-id' => $id, 'data-contextual-token' => $id_token, 'data-drupal-ajax-container' => '']) . '></div>'); - $this->assertSession()->responseContains('<div' . new Attribute(['data-contextual-id' => $cached_id, 'data-contextual-token' => $cached_id_token, 'data-drupal-ajax-container' => '']) . '></div>'); - // phpcs:enable + $attribute = new Attribute([ + 'data-contextual-id' => $id, + 'data-contextual-token' => $id_token, + 'data-drupal-ajax-container' => '', + ]); + $this->assertSession()->responseContains('<div' . $attribute . '></div>'); + $attribute = new Attribute([ + 'data-contextual-id' => $cached_id, + 'data-contextual-token' => $cached_id_token, + 'data-drupal-ajax-container' => '', + ]); + $this->assertSession()->responseContains('<div' . $attribute . '></div>'); // Get server-rendered contextual links. // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:renderContextualLinks() -- GitLab