From d298e0045684194ede621d4c61257d6cd5e25944 Mon Sep 17 00:00:00 2001 From: catch <6915-catch@users.noreply.drupalcode.org> Date: Mon, 17 Mar 2025 16:09:17 +0000 Subject: [PATCH] Issue #3512960 by quietone: Fix LongLineDeclaration in Kernel tests --- .../tests/src/Kernel/BlockRebuildTest.php | 9 +- .../src/Kernel/CKEditor5PluginManagerTest.php | 5 +- .../src/Kernel/CommentFieldAccessTest.php | 16 ++- .../src/Kernel/ViewsDataIntegrationTest.php | 8 +- .../Kernel/ViewsModerationStateFilterTest.php | 6 +- .../WorkspacesContentModerationStateTest.php | 54 +++++++-- .../d6/MigrateTaxonomyTermTranslationTest.php | 77 ++++++++++-- .../dblog/tests/src/Kernel/DbLogTest.php | 7 +- .../field/tests/src/Kernel/BulkDeleteTest.php | 90 +++++++++++--- .../EntityReferenceItemTest.php | 50 ++++++-- .../field/tests/src/Kernel/FieldCrudTest.php | 18 ++- .../tests/src/Kernel/FieldStorageCrudTest.php | 24 +++- .../d6/MigrateFieldFormatterSettingsTest.php | 7 +- .../tests/src/Kernel/EntityDisplayTest.php | 14 ++- .../Formatter/FileEntityFormatterTest.php | 15 ++- .../filter/tests/src/Kernel/FilterAPITest.php | 9 +- .../Migrate/d7/MigrateFilterFormatTest.php | 12 +- .../src/Kernel/ImageThemeFunctionTest.php | 41 ++++++- .../Migrate/d7/MigrateImageStylesTest.php | 55 ++++++++- .../src/Kernel/Context/FieldResolverTest.php | 95 ++++++++++++--- .../Normalizer/RelationshipNormalizerTest.php | 5 +- .../LayoutBuilderEntityViewDisplayTest.php | 4 +- .../Kernel/OverridesSectionStorageTest.php | 8 +- .../src/Kernel/LocaleConfigSubscriberTest.php | 18 ++- .../LocaleConfigurableLanguageManagerTest.php | 12 +- .../tests/src/Kernel/LocaleStringTest.php | 24 +++- .../tests/src/Kernel/MediaSourceTest.php | 6 +- .../src/Kernel/MediaLibraryAccessTest.php | 67 +++++++++-- .../Kernel/Migrate/d6/MigrateMenuLinkTest.php | 106 +++++++++++++++-- .../d7/MigrateMenuLinkLocalizedTest.php | 45 ++++++- .../Kernel/Migrate/d7/MigrateMenuLinkTest.php | 102 +++++++++++++--- .../MigrateEntityContentValidationTest.php | 9 +- .../src/Kernel/NavigationMenuLinkTreeTest.php | 27 ++++- .../tests/src/Kernel/NodeListBuilderTest.php | 9 +- .../Kernel/NodeTemplateSuggestionsTest.php | 20 +++- .../tests/src/Kernel/NodeTokenReplaceTest.php | 8 +- .../Kernel/ComposerPatchesValidatorTest.php | 7 +- .../EnvironmentSupportValidatorTest.php | 11 +- .../src/Kernel/pgsql/NonPublicSchemaTest.php | 19 ++- .../tests/src/Kernel/RequestHandlerTest.php | 20 +++- .../src/Kernel/Block/SystemMenuBlockTest.php | 67 +++++++++-- .../tests/src/Kernel/Common/UrlTest.php | 69 +++++++++-- .../Kernel/Token/TokenReplaceKernelTest.php | 8 +- .../d6/MigrateVocabularyEntityDisplayTest.php | 5 +- ...MigrateVocabularyEntityFormDisplayTest.php | 13 +- .../d6/MigrateVocabularyFieldInstanceTest.php | 5 +- .../tests/src/Kernel/TermValidationTest.php | 8 +- .../Condition/UserRoleConditionTest.php | 13 +- .../d6/MigrateUserProfileFieldTest.php | 12 +- .../tests/src/Kernel/UserPassRehashTest.php | 22 +++- .../src/Kernel/Views/UserKernelTestBase.php | 8 +- .../Entity/ViewEntityDependenciesTest.php | 7 +- ...sEntitySchemaSubscriberIntegrationTest.php | 7 +- .../Kernel/Handler/FieldEntityLinkTest.php | 16 ++- .../src/Kernel/Handler/FieldFieldTest.php | 112 ++++++++++++++++-- .../tests/src/Kernel/Plugin/CacheTest.php | 12 +- .../Plugin/CastedIntFieldJoinTestBase.php | 5 +- .../src/Kernel/Plugin/DisplayPageTest.php | 7 +- .../Kernel/Plugin/FieldOrLanguageJoinTest.php | 5 +- .../src/Kernel/Plugin/RowRenderCacheTest.php | 7 +- .../tests/src/Kernel/Plugin/SqlQueryTest.php | 5 +- .../tests/src/Kernel/Plugin/StyleGridTest.php | 15 ++- .../src/Kernel/RenderCacheIntegrationTest.php | 11 +- .../views/tests/src/Kernel/ViewsHooksTest.php | 10 +- .../src/Kernel/WorkspaceEntityDeleteTest.php | 6 +- .../src/Kernel/WorkspaceIntegrationTest.php | 44 +++++-- core/phpcs.xml.dist | 1 + 67 files changed, 1432 insertions(+), 207 deletions(-) diff --git a/core/modules/block/tests/src/Kernel/BlockRebuildTest.php b/core/modules/block/tests/src/Kernel/BlockRebuildTest.php index 9b203681bb81..c604477b9a24 100644 --- a/core/modules/block/tests/src/Kernel/BlockRebuildTest.php +++ b/core/modules/block/tests/src/Kernel/BlockRebuildTest.php @@ -103,7 +103,14 @@ public function testRebuildInvalidBlocks(): void { $messages = \Drupal::messenger()->all(); \Drupal::messenger()->deleteAll(); - $expected = ['warning' => [new TranslatableMarkup('The block %info was assigned to the invalid region %region and has been disabled.', ['%info' => $block1->id(), '%region' => 'INVALID'])]]; + $expected = [ + 'warning' => [ + new TranslatableMarkup('The block %info was assigned to the invalid region %region and has been disabled.', [ + '%info' => $block1->id(), + '%region' => 'INVALID', + ]), + ], + ]; $this->assertEquals($expected, $messages); $default_region = system_default_region('stark'); diff --git a/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php b/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php index c18a8724f653..30cd8fe3b60d 100644 --- a/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php +++ b/core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php @@ -1216,7 +1216,10 @@ public function testEnabledPlugins(): void { $settings['toolbar']['items'][] = 'insertTable'; $editor->setSettings($settings); $plugin_ids = array_keys($this->manager->getEnabledDefinitions($editor)); - $expected_plugins = array_merge($expected_plugins, ['ckeditor5_table', 'ckeditor5_plugin_conditions_test_plugins_condition']); + $expected_plugins = array_merge($expected_plugins, [ + 'ckeditor5_table', + 'ckeditor5_plugin_conditions_test_plugins_condition', + ]); sort($expected_plugins); $this->assertSame(array_values($expected_plugins), $plugin_ids); $expected_libraries = array_merge($default_libraries, [ diff --git a/core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php b/core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php index 99bbd7e2a5a7..9095d6f40321 100644 --- a/core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php +++ b/core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php @@ -222,8 +222,20 @@ public function testAccessToAdministrativeFields(): void { // Generate permutations. $combinations = [ - 'comment' => [$comment1, $comment2, $comment3, $comment4, $comment5], - 'user' => [$comment_admin_user, $comment_enabled_user, $comment_no_edit_user, $comment_disabled_user, $anonymous_user], + 'comment' => [ + $comment1, + $comment2, + $comment3, + $comment4, + $comment5, + ], + 'user' => [ + $comment_admin_user, + $comment_enabled_user, + $comment_no_edit_user, + $comment_disabled_user, + $anonymous_user, + ], ]; $permutations = $this->generatePermutations($combinations); diff --git a/core/modules/content_moderation/tests/src/Kernel/ViewsDataIntegrationTest.php b/core/modules/content_moderation/tests/src/Kernel/ViewsDataIntegrationTest.php index 60e65b5f5f71..aef7eefffd8c 100644 --- a/core/modules/content_moderation/tests/src/Kernel/ViewsDataIntegrationTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/ViewsDataIntegrationTest.php @@ -76,7 +76,13 @@ public function testContentModerationStateField(): void { 'moderation_state' => 'published', ], ]; - $this->assertIdenticalResultset($view, $expected_result, ['title' => 'title', 'moderation_state' => 'moderation_state']); + $this->assertIdenticalResultset( + $view, + $expected_result, + [ + 'title' => 'title', + 'moderation_state' => 'moderation_state', + ]); } } diff --git a/core/modules/content_moderation/tests/src/Kernel/ViewsModerationStateFilterTest.php b/core/modules/content_moderation/tests/src/Kernel/ViewsModerationStateFilterTest.php index 9b3771e98e0c..17fd9630c472 100644 --- a/core/modules/content_moderation/tests/src/Kernel/ViewsModerationStateFilterTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/ViewsModerationStateFilterTest.php @@ -313,7 +313,11 @@ public function testStateFilterStatesList(): void { // Adding a new content moderation workflow will add additional states to // filter. - $workflow = Workflow::create(['id' => 'moderation_test', 'type' => 'content_moderation', 'label' => 'Moderation test']); + $workflow = Workflow::create([ + 'id' => 'moderation_test', + 'type' => 'content_moderation', + 'label' => 'Moderation test', + ]); $workflow->getTypePlugin()->addState('foo', 'Foo State'); $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'example'); $workflow->save(); diff --git a/core/modules/content_moderation/tests/src/Kernel/WorkspacesContentModerationStateTest.php b/core/modules/content_moderation/tests/src/Kernel/WorkspacesContentModerationStateTest.php index 844bfc8b688f..bbd2aa443c6c 100644 --- a/core/modules/content_moderation/tests/src/Kernel/WorkspacesContentModerationStateTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/WorkspacesContentModerationStateTest.php @@ -112,18 +112,42 @@ public function testContentModerationIntegrationWithWorkspaces(): void { // Create three entities for each bundle, covering all the available // moderation states. - $page_archived = Node::create(['type' => 'page', 'title' => 'Test page - archived', 'moderation_state' => 'archived']); + $page_archived = Node::create([ + 'type' => 'page', + 'title' => 'Test page - archived', + 'moderation_state' => 'archived', + ]); $page_archived->save(); - $page_draft = Node::create(['type' => 'page', 'title' => 'Test page - draft', 'moderation_state' => 'draft']); + $page_draft = Node::create([ + 'type' => 'page', + 'title' => 'Test page - draft', + 'moderation_state' => 'draft', + ]); $page_draft->save(); - $page_published = Node::create(['type' => 'page', 'title' => 'Test page - published', 'moderation_state' => 'published']); + $page_published = Node::create([ + 'type' => 'page', + 'title' => 'Test page - published', + 'moderation_state' => 'published', + ]); $page_published->save(); - $article_archived = Node::create(['type' => 'article', 'title' => 'Test article - archived', 'moderation_state' => 'archived']); + $article_archived = Node::create([ + 'type' => 'article', + 'title' => 'Test article - archived', + 'moderation_state' => 'archived', + ]); $article_archived->save(); - $article_draft = Node::create(['type' => 'article', 'title' => 'Test article - draft', 'moderation_state' => 'draft']); + $article_draft = Node::create([ + 'type' => 'article', + 'title' => 'Test article - draft', + 'moderation_state' => 'draft', + ]); $article_draft->save(); - $article_published = Node::create(['type' => 'article', 'title' => 'Test article - published', 'moderation_state' => 'published']); + $article_published = Node::create([ + 'type' => 'article', + 'title' => 'Test article - published', + 'moderation_state' => 'published', + ]); $article_published->save(); // We have three items in a non-default moderation state: @@ -193,11 +217,23 @@ public function testContentModerationWithoutDefaultRevisionsInWorkspaces(): void $this->createContentType(['type' => 'note']); // Create content in all states none with default revisions. - $note_archived = Node::create(['type' => 'note', 'title' => 'Test note - archived', 'moderation_state' => 'archived']); + $note_archived = Node::create([ + 'type' => 'note', + 'title' => 'Test note - archived', + 'moderation_state' => 'archived', + ]); $note_archived->save(); - $note_draft = Node::create(['type' => 'note', 'title' => 'Test note - draft', 'moderation_state' => 'draft']); + $note_draft = Node::create([ + 'type' => 'note', + 'title' => 'Test note - draft', + 'moderation_state' => 'draft', + ]); $note_draft->save(); - $note_published = Node::create(['type' => 'note', 'title' => 'Test note - published', 'moderation_state' => 'published']); + $note_published = Node::create([ + 'type' => 'note', + 'title' => 'Test note - published', + 'moderation_state' => 'published', + ]); $note_published->save(); // Check workspace can be published. diff --git a/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTranslationTest.php b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTranslationTest.php index 914473cf68eb..05560c770b5f 100644 --- a/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTranslationTest.php +++ b/core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTranslationTest.php @@ -125,13 +125,76 @@ protected function assertHierarchy(string $vid, int $tid, array $parent_ids): vo * Tests the Drupal 6 i18n taxonomy term to Drupal 8 migration. */ public function testTranslatedTaxonomyTerms(): void { - $this->assertEntity(1, 'zu', 'zu - term 1 of vocabulary 1', 'vocabulary_1_i_0_', 'zu - description of term 1 of vocabulary 1', NULL, 0, []); - $this->assertEntity(2, 'fr', 'fr - term 2 of vocabulary 2', 'vocabulary_2_i_1_', 'fr - description of term 2 of vocabulary 2', NULL, 3, []); - $this->assertEntity(3, 'fr', 'fr - term 3 of vocabulary 2', 'vocabulary_2_i_1_', 'fr - description of term 3 of vocabulary 2', NULL, 4, ['2']); - $this->assertEntity(4, 'en', 'term 4 of vocabulary 3', 'vocabulary_3_i_2_', 'description of term 4 of vocabulary 3', NULL, 6, []); - $this->assertEntity(5, 'en', 'term 5 of vocabulary 3', 'vocabulary_3_i_2_', 'description of term 5 of vocabulary 3', NULL, 7, ['4']); - $this->assertEntity(6, 'en', 'term 6 of vocabulary 3', 'vocabulary_3_i_2_', 'description of term 6 of vocabulary 3', NULL, 8, ['4', '5']); - $this->assertEntity(7, 'fr', 'fr - term 2 of vocabulary 1', 'vocabulary_1_i_0_', 'fr - desc of term 2 vocab 1', NULL, 0, []); + $this->assertEntity( + 1, + 'zu', + 'zu - term 1 of vocabulary 1', + 'vocabulary_1_i_0_', + 'zu - description of term 1 of vocabulary 1', + NULL, + 0, + [] + ); + $this->assertEntity( + 2, + 'fr', + 'fr - term 2 of vocabulary 2', + 'vocabulary_2_i_1_', + 'fr - description of term 2 of vocabulary 2', + NULL, + 3, + [] + ); + $this->assertEntity( + 3, + 'fr', + 'fr - term 3 of vocabulary 2', + 'vocabulary_2_i_1_', + 'fr - description of term 3 of vocabulary 2', + NULL, + 4, + ['2'] + ); + $this->assertEntity( + 4, + 'en', + 'term 4 of vocabulary 3', + 'vocabulary_3_i_2_', + 'description of term 4 of vocabulary 3', + NULL, + 6, + [] + ); + $this->assertEntity( + 5, + 'en', + 'term 5 of vocabulary 3', + 'vocabulary_3_i_2_', + 'description of term 5 of vocabulary 3', + NULL, + 7, + ['4'] + ); + $this->assertEntity( + 6, + 'en', + 'term 6 of vocabulary 3', + 'vocabulary_3_i_2_', + 'description of term 6 of vocabulary 3', + NULL, + 8, + ['4', '5'] + ); + $this->assertEntity( + 7, + 'fr', + 'fr - term 2 of vocabulary 1', + 'vocabulary_1_i_0_', + 'fr - desc of term 2 vocab 1', + NULL, + 0, + [] + ); } } diff --git a/core/modules/dblog/tests/src/Kernel/DbLogTest.php b/core/modules/dblog/tests/src/Kernel/DbLogTest.php index 6ff79f7aff46..1d37c7bdf465 100644 --- a/core/modules/dblog/tests/src/Kernel/DbLogTest.php +++ b/core/modules/dblog/tests/src/Kernel/DbLogTest.php @@ -66,7 +66,12 @@ function (callable $hook, string $module) use (&$implementation_count) { * Tests that only valid placeholders are stored in the variables column. */ public function testInvalidPlaceholders(): void { - \Drupal::logger('my_module')->warning('Hello @string @array @object', ['@string' => '', '@array' => [], '@object' => new \stdClass()]); + \Drupal::logger('my_module') + ->warning('Hello @string @array @object', [ + '@string' => '', + '@array' => [], + '@object' => new \stdClass(), + ]); $variables = \Drupal::database() ->select('watchdog', 'w') ->fields('w', ['variables']) diff --git a/core/modules/field/tests/src/Kernel/BulkDeleteTest.php b/core/modules/field/tests/src/Kernel/BulkDeleteTest.php index 8e3062215197..e75a151c2f92 100644 --- a/core/modules/field/tests/src/Kernel/BulkDeleteTest.php +++ b/core/modules/field/tests/src/Kernel/BulkDeleteTest.php @@ -188,7 +188,13 @@ public function testDeleteField(): void { $field->delete(); // The field still exists, deleted. - $fields = \Drupal::entityTypeManager()->getStorage('field_config')->loadByProperties(['field_storage_uuid' => $field_storage->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE]); + $fields = \Drupal::entityTypeManager() + ->getStorage('field_config') + ->loadByProperties([ + 'field_storage_uuid' => $field_storage->uuid(), + 'deleted' => TRUE, + 'include_deleted' => TRUE, + ]); $this->assertCount(1, $fields, 'There is one deleted field'); $field = $fields[$field->uuid()]; $this->assertEquals($bundle, $field->getTargetBundle(), 'The deleted field is for the correct bundle'); @@ -261,7 +267,12 @@ public function testPurgeWithDeletedAndActiveField(): void { $deleted_field_uuid = $deleted_field->uuid(); // Reload the field storage. - $field_storages = \Drupal::entityTypeManager()->getStorage('field_storage_config')->loadByProperties(['uuid' => $deleted_field_storage->uuid(), 'include_deleted' => TRUE]); + $field_storages = \Drupal::entityTypeManager() + ->getStorage('field_storage_config') + ->loadByProperties([ + 'uuid' => $deleted_field_storage->uuid(), + 'include_deleted' => TRUE, + ]); $deleted_field_storage = reset($field_storages); // Create the field again. @@ -278,7 +289,12 @@ public function testPurgeWithDeletedAndActiveField(): void { ])->save(); // The field still exists, deleted, with the same field name. - $fields = \Drupal::entityTypeManager()->getStorage('field_config')->loadByProperties(['uuid' => $deleted_field_uuid, 'include_deleted' => TRUE]); + $fields = \Drupal::entityTypeManager() + ->getStorage('field_config') + ->loadByProperties([ + 'uuid' => $deleted_field_uuid, + 'include_deleted' => TRUE, + ]); $this->assertArrayHasKey($deleted_field_uuid, $fields); $this->assertTrue($fields[$deleted_field_uuid]->isDeleted()); $this->assertSame($field_name, $fields[$deleted_field_uuid]->getName()); @@ -306,7 +322,13 @@ public function testPurgeWithDeletedAndActiveField(): void { $this->assertFalse(\Drupal::database()->schema()->tableExists($deleted_table_name)); // The field has been removed from the system. - $fields = \Drupal::entityTypeManager()->getStorage('field_config')->loadByProperties(['field_storage_uuid' => $deleted_field_storage->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE]); + $fields = \Drupal::entityTypeManager() + ->getStorage('field_config') + ->loadByProperties([ + 'field_storage_uuid' => $deleted_field_storage->uuid(), + 'deleted' => TRUE, + 'include_deleted' => TRUE, + ]); $this->assertCount(0, $fields, 'The field is gone'); // Verify there are still 10 entries in the main table. @@ -365,19 +387,36 @@ public function testPurgeField(): void { $this->checkHooksInvocations($hooks, $actual_hooks); // The field still exists, deleted. - $fields = \Drupal::entityTypeManager()->getStorage('field_config')->loadByProperties(['field_storage_uuid' => $field_storage->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE]); + $fields = \Drupal::entityTypeManager() + ->getStorage('field_config') + ->loadByProperties([ + 'field_storage_uuid' => $field_storage->uuid(), + 'deleted' => TRUE, + 'include_deleted' => TRUE, + ]); $this->assertCount(1, $fields, 'There is one deleted field'); // Purge the field. field_purge_batch($batch_size); // The field is gone. - $fields = \Drupal::entityTypeManager()->getStorage('field_config')->loadByProperties(['field_storage_uuid' => $field_storage->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE]); + $fields = \Drupal::entityTypeManager() + ->getStorage('field_config') + ->loadByProperties([ + 'field_storage_uuid' => $field_storage->uuid(), + 'deleted' => TRUE, + 'include_deleted' => TRUE, + ]); $this->assertCount(0, $fields, 'The field is gone'); // The field storage still exists, not deleted, because it has a second // field. - $storages = \Drupal::entityTypeManager()->getStorage('field_storage_config')->loadByProperties(['uuid' => $field_storage->uuid(), 'include_deleted' => TRUE]); + $storages = \Drupal::entityTypeManager() + ->getStorage('field_storage_config') + ->loadByProperties([ + 'uuid' => $field_storage->uuid(), + 'include_deleted' => TRUE, + ]); $this->assertTrue(isset($storages[$field_storage->uuid()]), 'The field storage exists and is not deleted'); } @@ -415,7 +454,9 @@ public function testPurgeFieldStorage(): void { $this->checkHooksInvocations($hooks, $actual_hooks); // The field still exists, deleted. - $fields = \Drupal::entityTypeManager()->getStorage('field_config')->loadByProperties(['uuid' => $field->uuid(), 'include_deleted' => TRUE]); + $fields = \Drupal::entityTypeManager() + ->getStorage('field_config') + ->loadByProperties(['uuid' => $field->uuid(), 'include_deleted' => TRUE]); $this->assertArrayHasKey($field->uuid(), $fields); $this->assertTrue($fields[$field->uuid()]->isDeleted()); @@ -423,10 +464,17 @@ public function testPurgeFieldStorage(): void { field_purge_batch(0); // The field is gone. - $fields = \Drupal::entityTypeManager()->getStorage('field_config')->loadByProperties(['uuid' => $field->uuid(), 'include_deleted' => TRUE]); + $fields = \Drupal::entityTypeManager() + ->getStorage('field_config') + ->loadByProperties(['uuid' => $field->uuid(), 'include_deleted' => TRUE]); $this->assertCount(0, $fields, 'The field is purged.'); // The field storage still exists, not deleted. - $storages = \Drupal::entityTypeManager()->getStorage('field_storage_config')->loadByProperties(['uuid' => $field_storage->uuid(), 'include_deleted' => TRUE]); + $storages = \Drupal::entityTypeManager() + ->getStorage('field_storage_config') + ->loadByProperties([ + 'uuid' => $field_storage->uuid(), + 'include_deleted' => TRUE, + ]); $this->assertArrayHasKey($field_storage->uuid(), $storages); $this->assertFalse($storages[$field_storage->uuid()]->isDeleted()); @@ -449,10 +497,17 @@ public function testPurgeFieldStorage(): void { $this->checkHooksInvocations($hooks, $actual_hooks); // The field and the storage still exist, deleted. - $fields = \Drupal::entityTypeManager()->getStorage('field_config')->loadByProperties(['uuid' => $field->uuid(), 'include_deleted' => TRUE]); + $fields = \Drupal::entityTypeManager() + ->getStorage('field_config') + ->loadByProperties(['uuid' => $field->uuid(), 'include_deleted' => TRUE]); $this->assertArrayHasKey($field->uuid(), $fields); $this->assertTrue($fields[$field->uuid()]->isDeleted()); - $storages = \Drupal::entityTypeManager()->getStorage('field_storage_config')->loadByProperties(['uuid' => $field_storage->uuid(), 'include_deleted' => TRUE]); + $storages = \Drupal::entityTypeManager() + ->getStorage('field_storage_config') + ->loadByProperties([ + 'uuid' => $field_storage->uuid(), + 'include_deleted' => TRUE, + ]); $this->assertArrayHasKey($field_storage->uuid(), $storages); $this->assertTrue($storages[$field_storage->uuid()]->isDeleted()); @@ -460,9 +515,16 @@ public function testPurgeFieldStorage(): void { field_purge_batch(0); // The field and the storage are gone. - $fields = \Drupal::entityTypeManager()->getStorage('field_config')->loadByProperties(['uuid' => $field->uuid(), 'include_deleted' => TRUE]); + $fields = \Drupal::entityTypeManager() + ->getStorage('field_config') + ->loadByProperties(['uuid' => $field->uuid(), 'include_deleted' => TRUE]); $this->assertCount(0, $fields, 'The field is purged.'); - $storages = \Drupal::entityTypeManager()->getStorage('field_storage_config')->loadByProperties(['uuid' => $field_storage->uuid(), 'include_deleted' => TRUE]); + $storages = \Drupal::entityTypeManager() + ->getStorage('field_storage_config') + ->loadByProperties([ + 'uuid' => $field_storage->uuid(), + 'include_deleted' => TRUE, + ]); $this->assertCount(0, $storages, 'The field storage is purged.'); } diff --git a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php index 6c2047f6d00f..d55528fed21f 100644 --- a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php +++ b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php @@ -469,7 +469,13 @@ public function testAutocreateValidation(): void { $errors = $entity->validate(); $this->assertCount(1, $errors); - $this->assertEquals(new FormattableMarkup('This entity (%type: %label) cannot be referenced.', ['%type' => 'node', '%label' => $title]), $errors[0]->getMessage()); + $this->assertEquals( + new FormattableMarkup('This entity (%type: %label) cannot be referenced.', + [ + '%type' => 'node', + '%label' => $title, + ]), + $errors[0]->getMessage()); $this->assertEquals('field_test_node.0.entity', $errors[0]->getPropertyPath()); // Publish the node and try again. @@ -517,9 +523,19 @@ public function testAutocreateValidation(): void { $errors = $entity->validate(); $this->assertCount(2, $errors); - $this->assertEquals(new FormattableMarkup('This entity (%type: %label) cannot be referenced.', ['%type' => 'node', '%label' => $unsaved_unpublished_node_title]), $errors[0]->getMessage()); + $this->assertEquals( + new FormattableMarkup('This entity (%type: %label) cannot be referenced.', [ + '%type' => 'node', + '%label' => $unsaved_unpublished_node_title, + ]), + $errors[0]->getMessage()); $this->assertEquals('field_test_node.0.entity', $errors[0]->getPropertyPath()); - $this->assertEquals(new FormattableMarkup('This entity (%type: %label) cannot be referenced.', ['%type' => 'node', '%label' => $saved_unpublished_node->id()]), $errors[1]->getMessage()); + $this->assertEquals( + new FormattableMarkup('This entity (%type: %label) cannot be referenced.', [ + '%type' => 'node', + '%label' => $saved_unpublished_node->id(), + ]), + $errors[1]->getMessage()); $this->assertEquals('field_test_node.1.target_id', $errors[1]->getPropertyPath()); // Publish one of the nodes and try again. @@ -527,7 +543,12 @@ public function testAutocreateValidation(): void { $saved_unpublished_node->save(); $errors = $entity->validate(); $this->assertCount(1, $errors); - $this->assertEquals(new FormattableMarkup('This entity (%type: %label) cannot be referenced.', ['%type' => 'node', '%label' => $unsaved_unpublished_node_title]), $errors[0]->getMessage()); + $this->assertEquals( + new FormattableMarkup('This entity (%type: %label) cannot be referenced.', [ + '%type' => 'node', + '%label' => $unsaved_unpublished_node_title, + ]), + $errors[0]->getMessage()); $this->assertEquals('field_test_node.0.entity', $errors[0]->getPropertyPath()); // Publish the last invalid node and try again. @@ -551,7 +572,12 @@ public function testAutocreateValidation(): void { $errors = $entity->validate(); $this->assertCount(1, $errors); - $this->assertEquals(new FormattableMarkup('This entity (%type: %label) cannot be referenced.', ['%type' => 'comment', '%label' => $title]), $errors[0]->getMessage()); + $this->assertEquals( + new FormattableMarkup('This entity (%type: %label) cannot be referenced.', [ + '%type' => 'comment', + '%label' => $title, + ]), + $errors[0]->getMessage()); $this->assertEquals('field_test_comment.0.entity', $errors[0]->getPropertyPath()); // Publish the comment and try again. @@ -574,7 +600,12 @@ public function testAutocreateValidation(): void { $errors = $entity->validate(); $this->assertCount(1, $errors); - $this->assertEquals(new FormattableMarkup('This entity (%type: %label) cannot be referenced.', ['%type' => 'user', '%label' => $name]), $errors[0]->getMessage()); + $this->assertEquals( + new FormattableMarkup('This entity (%type: %label) cannot be referenced.', [ + '%type' => 'user', + '%label' => $name, + ]), + $errors[0]->getMessage()); $this->assertEquals('field_test_user.0.entity', $errors[0]->getPropertyPath()); // Activate the user and try again. @@ -597,7 +628,12 @@ public function testAutocreateValidation(): void { $errors = $entity->validate(); $this->assertCount(1, $errors); - $this->assertEquals(new FormattableMarkup('This entity (%type: %label) cannot be referenced.', ['%type' => 'file', '%label' => $filename]), $errors[0]->getMessage()); + $this->assertEquals( + new FormattableMarkup('This entity (%type: %label) cannot be referenced.', [ + '%type' => 'file', + '%label' => $filename, + ]), + $errors[0]->getMessage()); $this->assertEquals('field_test_file.0.entity', $errors[0]->getPropertyPath()); // Set the file as permanent and try again. diff --git a/core/modules/field/tests/src/Kernel/FieldCrudTest.php b/core/modules/field/tests/src/Kernel/FieldCrudTest.php index e51a2db9d6e8..278f8dbc87c3 100644 --- a/core/modules/field/tests/src/Kernel/FieldCrudTest.php +++ b/core/modules/field/tests/src/Kernel/FieldCrudTest.php @@ -289,13 +289,27 @@ public function testDeleteFieldNoData(): void { FieldConfig::create($another_field_definition)->save(); // Test that the first field is not deleted, and then delete it. - $field = current(\Drupal::entityTypeManager()->getStorage('field_config')->loadByProperties(['entity_type' => 'entity_test', 'field_name' => $this->fieldDefinition['field_name'], 'bundle' => $this->fieldDefinition['bundle'], 'include_deleted' => TRUE])); + $field = current(\Drupal::entityTypeManager() + ->getStorage('field_config') + ->loadByProperties([ + 'entity_type' => 'entity_test', + 'field_name' => $this->fieldDefinition['field_name'], + 'bundle' => $this->fieldDefinition['bundle'], + 'include_deleted' => TRUE, + ])); $this->assertFalse($field->isDeleted()); $field->delete(); // Make sure the field was deleted without being marked for purging as there // was no data. - $fields = \Drupal::entityTypeManager()->getStorage('field_config')->loadByProperties(['entity_type' => 'entity_test', 'field_name' => $this->fieldDefinition['field_name'], 'bundle' => $this->fieldDefinition['bundle'], 'include_deleted' => TRUE]); + $fields = \Drupal::entityTypeManager() + ->getStorage('field_config') + ->loadByProperties([ + 'entity_type' => 'entity_test', + 'field_name' => $this->fieldDefinition['field_name'], + 'bundle' => $this->fieldDefinition['bundle'], + 'include_deleted' => TRUE, + ]); $this->assertCount(0, $fields, 'A deleted field is marked for deletion.'); // Try to load the field normally and make sure it does not show up. diff --git a/core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php b/core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php index 1d21ebd34b2a..f845abeba457 100644 --- a/core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php +++ b/core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php @@ -227,7 +227,10 @@ public function testRead(): void { ]); $this->assertCount(1, $fields, 'The field was properly read.'); $this->assertArrayHasKey($id, $fields, 'The field has the correct key.'); - $fields = $field_storage_config_storage->loadByProperties(['field_name' => $field_storage_definition['field_name'], 'type' => 'foo']); + $fields = $field_storage_config_storage->loadByProperties([ + 'field_name' => $field_storage_definition['field_name'], + 'type' => 'foo', + ]); $this->assertEmpty($fields, 'No field was found.'); // Create a field from the field storage. @@ -323,17 +326,30 @@ public function testDeleteNoData(): void { // Test that the first field is not deleted, and then delete it. $field_storage_config_storage = \Drupal::entityTypeManager()->getStorage('field_storage_config'); - $field_storage = current($field_storage_config_storage->loadByProperties(['field_name' => $field_storage_definition['field_name'], 'include_deleted' => TRUE])); + $field_storage = current($field_storage_config_storage->loadByProperties([ + 'field_name' => $field_storage_definition['field_name'], + 'include_deleted' => TRUE, + ])); $this->assertFalse($field_storage->isDeleted()); FieldStorageConfig::loadByName('entity_test', $field_storage_definition['field_name'])->delete(); // Make sure that the field storage is deleted as it had no data. - $field_storages = $field_storage_config_storage->loadByProperties(['field_name' => $field_storage_definition['field_name'], 'include_deleted' => TRUE]); + $field_storages = $field_storage_config_storage->loadByProperties([ + 'field_name' => $field_storage_definition['field_name'], + 'include_deleted' => TRUE, + ]); $this->assertCount(0, $field_storages, 'Field storage was deleted'); // Make sure that this field is marked as deleted when it is // specifically loaded. - $fields = \Drupal::entityTypeManager()->getStorage('field_config')->loadByProperties(['entity_type' => 'entity_test', 'field_name' => $field_definition['field_name'], 'bundle' => $field_definition['bundle'], 'include_deleted' => TRUE]); + $fields = \Drupal::entityTypeManager() + ->getStorage('field_config') + ->loadByProperties([ + 'entity_type' => 'entity_test', + 'field_name' => $field_definition['field_name'], + 'bundle' => $field_definition['bundle'], + 'include_deleted' => TRUE, + ]); $this->assertCount(0, $fields, 'Field storage was deleted'); // Try to load the storage normally and make sure it does not show up. diff --git a/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldFormatterSettingsTest.php b/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldFormatterSettingsTest.php index c2955f2d1123..2c35099cdf92 100644 --- a/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldFormatterSettingsTest.php +++ b/core/modules/field/tests/src/Kernel/Migrate/d6/MigrateFieldFormatterSettingsTest.php @@ -208,7 +208,12 @@ public function testEntityDisplaySettings(): void { $component = $display->getComponent('field_test_datetime'); $this->assertSame($expected, $component); // Test that our Id map has the correct data. - $this->assertSame([['node', 'story', 'teaser', 'field_test']], $this->getMigration('d6_field_formatter_settings')->getIdMap()->lookupDestinationIds(['story', 'teaser', 'node', 'field_test'])); + $this->assertSame( + [['node', 'story', 'teaser', 'field_test']], + $this->getMigration('d6_field_formatter_settings') + ->getIdMap() + ->lookupDestinationIds(['story', 'teaser', 'node', 'field_test']) + ); // Test hidden field. $this->assertComponentNotExists('node.test_planet.teaser', 'field_test_text_single_checkbox'); diff --git a/core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php b/core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php index e6e48ebf7dc9..98a42576b2f3 100644 --- a/core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php +++ b/core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php @@ -73,7 +73,11 @@ public function testEntityDisplayCRUD(): void { $this->assertEquals($expected['component_2'], $display->getComponent('component_2')); // Check that arbitrary options are correctly stored. - $expected['component_3'] = ['weight' => 10, 'third_party_settings' => ['field_test' => ['foo' => 'bar']], 'settings' => []]; + $expected['component_3'] = [ + 'weight' => 10, + 'third_party_settings' => ['field_test' => ['foo' => 'bar']], + 'settings' => [], + ]; $display->setComponent('component_3', $expected['component_3']); $this->assertEquals($expected['component_3'], $display->getComponent('component_3')); @@ -281,7 +285,13 @@ public function testFieldComponent(): void { // Check that the display has dependencies on the field and the module that // provides the formatter. $dependencies = $display->calculateDependencies()->getDependencies(); - $this->assertEquals(['config' => ['field.field.entity_test.entity_test.test_field'], 'module' => ['entity_test', 'field_test']], $dependencies); + $this->assertEquals( + [ + 'config' => ['field.field.entity_test.entity_test.test_field'], + 'module' => ['entity_test', 'field_test'], + ], + $dependencies + ); } /** diff --git a/core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php b/core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php index f805bd1c4422..0e31d56aa002 100644 --- a/core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php +++ b/core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php @@ -108,7 +108,13 @@ public function testFormatterFileUri(): void { $build = $entity_display->buildMultiple($this->files)[0]['uri'][0]; $this->assertEquals($this->fileUrlGenerator->generateString('public://file.png'), $build['#markup']); - $entity_display->setComponent('uri', ['type' => 'file_uri', 'settings' => ['file_download_path' => TRUE, 'link_to_file' => TRUE]]); + $entity_display->setComponent( + 'uri', + [ + 'type' => 'file_uri', + 'settings' => ['file_download_path' => TRUE, 'link_to_file' => TRUE], + ] + ); $build = $entity_display->buildMultiple($this->files)[0]['uri'][0]; $this->assertEquals($this->fileUrlGenerator->generateString('public://file.png'), $build['#title']); $this->assertEquals($this->fileUrlGenerator->generate('public://file.png'), $build['#url']); @@ -130,7 +136,12 @@ public function testFormatterFileExtension(): void { $this->assertEquals($expected[$i], $build['filename'][0]['#markup']); } - $entity_display->setComponent('filename', ['type' => 'file_extension', 'settings' => ['extension_detect_tar' => TRUE]]); + $entity_display->setComponent( + 'filename', + [ + 'type' => 'file_extension', + 'settings' => ['extension_detect_tar' => TRUE], + ]); $expected = ['png', 'tar', 'tar.gz', '']; foreach (array_values($this->files) as $i => $file) { diff --git a/core/modules/filter/tests/src/Kernel/FilterAPITest.php b/core/modules/filter/tests/src/Kernel/FilterAPITest.php index e5caa5d83e85..5f7702b3127a 100644 --- a/core/modules/filter/tests/src/Kernel/FilterAPITest.php +++ b/core/modules/filter/tests/src/Kernel/FilterAPITest.php @@ -82,7 +82,14 @@ public function testCheckMarkupFilterSubset(): void { // this check focuses on the ability to filter multiple filter types at // once. Drupal core only ships with these two types of filters, so this is // the most extensive test possible. - $actual_filtered_text_without_html_generators = check_markup($text, 'filtered_html', '', [FilterInterface::TYPE_HTML_RESTRICTOR, FilterInterface::TYPE_MARKUP_LANGUAGE]); + $actual_filtered_text_without_html_generators = check_markup( + $text, + 'filtered_html', + '', + [ + FilterInterface::TYPE_HTML_RESTRICTOR, + FilterInterface::TYPE_MARKUP_LANGUAGE, + ]); $this->assertSame($expected_filter_text_without_html_generators, (string) $actual_filtered_text_without_html_generators, 'Expected filter result when skipping FilterInterface::TYPE_MARKUP_LANGUAGE filters, even when trying to disable filters of the FilterInterface::TYPE_HTML_RESTRICTOR type.'); } diff --git a/core/modules/filter/tests/src/Kernel/Migrate/d7/MigrateFilterFormatTest.php b/core/modules/filter/tests/src/Kernel/Migrate/d7/MigrateFilterFormatTest.php index 15e1a77339a8..fd5967d66ec6 100644 --- a/core/modules/filter/tests/src/Kernel/Migrate/d7/MigrateFilterFormatTest.php +++ b/core/modules/filter/tests/src/Kernel/Migrate/d7/MigrateFilterFormatTest.php @@ -91,7 +91,17 @@ protected function assertEntity(string $id, string $label, array $enabled_filter */ public function testFilterFormat(): void { $this->assertEntity('custom_text_format', 'Custom Text format', ['filter_autop' => 0, 'filter_html' => -10], 0, TRUE); - $this->assertEntity('filtered_html', 'Filtered HTML', ['filter_autop' => 2, 'filter_html' => 1, 'filter_htmlcorrector' => 10, 'filter_url' => 0], 0, TRUE); + $this->assertEntity( + 'filtered_html', + 'Filtered HTML', + [ + 'filter_autop' => 2, + 'filter_html' => 1, + 'filter_htmlcorrector' => 10, + 'filter_url' => 0, + ], + 0, + TRUE); $this->assertEntity('full_html', 'Full HTML', ['filter_autop' => 1, 'filter_htmlcorrector' => 10, 'filter_url' => 0], 1, TRUE); $this->assertEntity('plain_text', 'Plain text', ['filter_autop' => 2, 'filter_html_escape' => 0, 'filter_url' => 1], 10, TRUE); // This assertion covers issue #2555089. Drupal 7 formats are identified diff --git a/core/modules/image/tests/src/Kernel/ImageThemeFunctionTest.php b/core/modules/image/tests/src/Kernel/ImageThemeFunctionTest.php index 90141333a311..a7d8328768a0 100644 --- a/core/modules/image/tests/src/Kernel/ImageThemeFunctionTest.php +++ b/core/modules/image/tests/src/Kernel/ImageThemeFunctionTest.php @@ -118,7 +118,15 @@ public function testImageFormatterTheme(): void { // Test using theme_image_formatter() with a NULL value for the alt option. $element = $base_element; $this->setRawContent($renderer->renderRoot($element)); - $elements = $this->xpath('//a[@href=:path]/img[@src=:url and @width=:width and @height=:height]', [':path' => base_path() . $path, ':url' => $url, ':width' => $image->getWidth(), ':height' => $image->getHeight()]); + $elements = $this->xpath( + '//a[@href=:path]/img[@src=:url and @width=:width and @height=:height]', + [ + ':path' => base_path() . $path, + ':url' => $url, + ':width' => $image->getWidth(), + ':height' => $image->getHeight(), + ] + ); $this->assertCount(1, $elements, 'theme_image_formatter() correctly renders with a NULL value for the alt option.'); // Test using theme_image_formatter() without an image title, alt text, or @@ -126,7 +134,15 @@ public function testImageFormatterTheme(): void { $element = $base_element; $element['#item']->alt = ''; $this->setRawContent($renderer->renderRoot($element)); - $elements = $this->xpath('//a[@href=:path]/img[@src=:url and @width=:width and @height=:height and @alt=""]', [':path' => base_path() . $path, ':url' => $url, ':width' => $image->getWidth(), ':height' => $image->getHeight()]); + $elements = $this->xpath( + '//a[@href=:path]/img[@src=:url and @width=:width and @height=:height and @alt=""]', + [ + ':path' => base_path() . $path, + ':url' => $url, + ':width' => $image->getWidth(), + ':height' => $image->getHeight(), + ] + ); $this->assertCount(1, $elements, 'theme_image_formatter() correctly renders without title, alt, or path options.'); // Link the image to a fragment on the page, and not a full URL. @@ -199,7 +215,12 @@ public function testImageAltFunctionality(): void { ]; $this->setRawContent($renderer->renderRoot($image_with_alt_property)); - $elements = $this->xpath('//img[contains(@class, class) and contains(@alt, :alt)]', [":class" => "image-with-regular-alt", ":alt" => "Regular alt"]); + $elements = $this->xpath( + '//img[contains(@class, class) and contains(@alt, :alt)]', + [ + ":class" => "image-with-regular-alt", + ":alt" => "Regular alt", + ]); $this->assertCount(1, $elements, 'Regular alt displays correctly'); // Test using alt attribute inside attributes. @@ -217,7 +238,12 @@ public function testImageAltFunctionality(): void { ]; $this->setRawContent($renderer->renderRoot($image_with_alt_attribute_alt_attribute)); - $elements = $this->xpath('//img[contains(@class, class) and contains(@alt, :alt)]', [":class" => "image-with-attribute-alt", ":alt" => "Attribute alt"]); + $elements = $this->xpath( + '//img[contains(@class, class) and contains(@alt, :alt)]', + [ + ":class" => "image-with-attribute-alt", + ":alt" => "Attribute alt", + ]); $this->assertCount(1, $elements, 'Attribute alt displays correctly'); // Test using alt attribute as property and inside attributes. @@ -236,7 +262,12 @@ public function testImageAltFunctionality(): void { ]; $this->setRawContent($renderer->renderRoot($image_with_alt_attribute_both)); - $elements = $this->xpath('//img[contains(@class, class) and contains(@alt, :alt)]', [":class" => "image-with-attribute-alt", ":alt" => "Attribute alt"]); + $elements = $this->xpath( + '//img[contains(@class, class) and contains(@alt, :alt)]', + [ + ":class" => "image-with-attribute-alt", + ":alt" => "Attribute alt", + ]); $this->assertCount(1, $elements, 'Attribute alt overrides alt property if both set.'); } diff --git a/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php b/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php index cbd07fab5ed7..7f273c15d533 100644 --- a/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php +++ b/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php @@ -34,9 +34,58 @@ protected function setUp(): void { * Tests the image styles migration. */ public function testImageStylesMigration(): void { - $this->assertEntity('custom_image_style_1', "Custom image style 1", ['image_scale_and_crop', 'image_desaturate'], [['width' => 55, 'height' => 55, 'anchor' => 'center-center'], []]); - $this->assertEntity('custom_image_style_2', "Custom image style 2", ['image_resize', 'image_rotate'], [['width' => 55, 'height' => 100], ['degrees' => 45, 'bgcolor' => '#FFFFFF', 'random' => FALSE]]); - $this->assertEntity('custom_image_style_3', "Custom image style 3", ['image_scale', 'image_crop'], [['width' => 150, 'height' => NULL, 'upscale' => FALSE], ['width' => 50, 'height' => 50, 'anchor' => 'left-top']]); + $this->assertEntity( + 'custom_image_style_1', + "Custom image style 1", + [ + 'image_scale_and_crop', + 'image_desaturate', + ], + [ + [ + 'width' => 55, + 'height' => 55, + 'anchor' => 'center-center', + ], + [], + ]); + $this->assertEntity( + 'custom_image_style_2', + "Custom image style 2", + [ + 'image_resize', + 'image_rotate', + ], + [ + [ + 'width' => 55, + 'height' => 100, + ], + [ + 'degrees' => 45, + 'bgcolor' => '#FFFFFF', + 'random' => FALSE, + ], + ]); + $this->assertEntity( + 'custom_image_style_3', + "Custom image style 3", + [ + 'image_scale', + 'image_crop', + ], + [ + [ + 'width' => 150, + 'height' => NULL, + 'upscale' => FALSE, + ], + [ + 'width' => 50, + 'height' => 50, + 'anchor' => 'left-top', + ], + ]); } /** diff --git a/core/modules/jsonapi/tests/src/Kernel/Context/FieldResolverTest.php b/core/modules/jsonapi/tests/src/Kernel/Context/FieldResolverTest.php index 5118736120c7..b0c4c34b8cf7 100644 --- a/core/modules/jsonapi/tests/src/Kernel/Context/FieldResolverTest.php +++ b/core/modules/jsonapi/tests/src/Kernel/Context/FieldResolverTest.php @@ -192,30 +192,84 @@ public static function resolveInternalEntityQueryPathProvider() { 'primitive field; variation A' => ['field_test1', 'field_test1'], 'primitive field; variation B' => ['field_test2', 'field_test2'], - 'entity reference then a primitive field; variation A' => ['field_test_ref2.entity:entity_test_with_bundle.field_test1', 'field_test_ref2.field_test1'], - 'entity reference then a primitive field; variation B' => ['field_test_ref2.entity:entity_test_with_bundle.field_test2', 'field_test_ref2.field_test2'], + 'entity reference then a primitive field; variation A' => [ + 'field_test_ref2.entity:entity_test_with_bundle.field_test1', + 'field_test_ref2.field_test1', + ], + 'entity reference then a primitive field; variation B' => [ + 'field_test_ref2.entity:entity_test_with_bundle.field_test2', + 'field_test_ref2.field_test2', + ], - 'entity reference then a complex field with property specifier `value`' => ['field_test_ref2.entity:entity_test_with_bundle.field_test_text.value', 'field_test_ref2.field_test_text.value'], - 'entity reference then a complex field with property specifier `format`' => ['field_test_ref2.entity:entity_test_with_bundle.field_test_text.format', 'field_test_ref2.field_test_text.format'], + 'entity reference then a complex field with property specifier `value`' => [ + 'field_test_ref2.entity:entity_test_with_bundle.field_test_text.value', + 'field_test_ref2.field_test_text.value', + ], + 'entity reference then a complex field with property specifier `format`' => [ + 'field_test_ref2.entity:entity_test_with_bundle.field_test_text.format', + 'field_test_ref2.field_test_text.format', + ], - 'entity reference then no delta with property specifier `id`' => ['field_test_ref1.entity:entity_test_with_bundle.uuid', 'field_test_ref1.id'], - 'entity reference then delta 0 with property specifier `id`' => ['field_test_ref1.0.entity:entity_test_with_bundle.uuid', 'field_test_ref1.0.id'], - 'entity reference then delta 1 with property specifier `id`' => ['field_test_ref1.1.entity:entity_test_with_bundle.uuid', 'field_test_ref1.1.id'], + 'entity reference then no delta with property specifier `id`' => [ + 'field_test_ref1.entity:entity_test_with_bundle.uuid', + 'field_test_ref1.id', + ], + 'entity reference then delta 0 with property specifier `id`' => [ + 'field_test_ref1.0.entity:entity_test_with_bundle.uuid', + 'field_test_ref1.0.id', + ], + 'entity reference then delta 1 with property specifier `id`' => [ + 'field_test_ref1.1.entity:entity_test_with_bundle.uuid', + 'field_test_ref1.1.id', + ], - 'entity reference then no reference property and a complex field with property specifier `value`' => ['field_test_ref1.entity:entity_test_with_bundle.field_test_text.value', 'field_test_ref1.field_test_text.value'], - 'entity reference then a reference property and a complex field with property specifier `value`' => ['field_test_ref1.entity.field_test_text.value', 'field_test_ref1.entity.field_test_text.value'], - 'entity reference then no reference property and a complex field with property specifier `format`' => ['field_test_ref1.entity:entity_test_with_bundle.field_test_text.format', 'field_test_ref1.field_test_text.format'], - 'entity reference then a reference property and a complex field with property specifier `format`' => ['field_test_ref1.entity.field_test_text.format', 'field_test_ref1.entity.field_test_text.format'], + 'entity reference then no reference property and a complex field with property specifier `value`' => [ + 'field_test_ref1.entity:entity_test_with_bundle.field_test_text.value', + 'field_test_ref1.field_test_text.value', + ], + 'entity reference then a reference property and a complex field with property specifier `value`' => [ + 'field_test_ref1.entity.field_test_text.value', + 'field_test_ref1.entity.field_test_text.value', + ], + 'entity reference then no reference property and a complex field with property specifier `format`' => [ + 'field_test_ref1.entity:entity_test_with_bundle.field_test_text.format', + 'field_test_ref1.field_test_text.format', + ], + 'entity reference then a reference property and a complex field with property specifier `format`' => [ + 'field_test_ref1.entity.field_test_text.format', + 'field_test_ref1.entity.field_test_text.format', + ], - 'entity reference then property specifier `entity:entity_test_with_bundle` then a complex field with property specifier `value`' => ['field_test_ref1.entity:entity_test_with_bundle.field_test_text.value', 'field_test_ref1.entity:entity_test_with_bundle.field_test_text.value'], + 'entity reference then property specifier `entity:entity_test_with_bundle` then a complex field with property specifier `value`' => [ + 'field_test_ref1.entity:entity_test_with_bundle.field_test_text.value', + 'field_test_ref1.entity:entity_test_with_bundle.field_test_text.value', + ], - 'entity reference with a delta and no reference property then a complex field and property specifier `value`' => ['field_test_ref1.0.entity:entity_test_with_bundle.field_test_text.value', 'field_test_ref1.0.field_test_text.value'], - 'entity reference with a delta and a reference property then a complex field and property specifier `value`' => ['field_test_ref1.0.entity.field_test_text.value', 'field_test_ref1.0.entity.field_test_text.value'], + 'entity reference with a delta and no reference property then a complex field and property specifier `value`' => [ + 'field_test_ref1.0.entity:entity_test_with_bundle.field_test_text.value', + 'field_test_ref1.0.field_test_text.value', + ], + 'entity reference with a delta and a reference property then a complex field and property specifier `value`' => [ + 'field_test_ref1.0.entity.field_test_text.value', + 'field_test_ref1.0.entity.field_test_text.value', + ], - 'entity reference with no reference property then another entity reference with no reference property a complex field with property specifier `value`' => ['field_test_ref1.entity:entity_test_with_bundle.field_test_ref3.entity:entity_test_with_bundle.field_test_text.value', 'field_test_ref1.field_test_ref3.field_test_text.value'], - 'entity reference with a reference property then another entity reference with no reference property a complex field with property specifier `value`' => ['field_test_ref1.entity.field_test_ref3.entity:entity_test_with_bundle.field_test_text.value', 'field_test_ref1.entity.field_test_ref3.field_test_text.value'], - 'entity reference with no reference property then another entity reference with a reference property a complex field with property specifier `value`' => ['field_test_ref1.entity:entity_test_with_bundle.field_test_ref3.entity.field_test_text.value', 'field_test_ref1.field_test_ref3.entity.field_test_text.value'], - 'entity reference with a reference property then another entity reference with a reference property a complex field with property specifier `value`' => ['field_test_ref1.entity.field_test_ref3.entity.field_test_text.value', 'field_test_ref1.entity.field_test_ref3.entity.field_test_text.value'], + 'entity reference with no reference property then another entity reference with no reference property a complex field with property specifier `value`' => [ + 'field_test_ref1.entity:entity_test_with_bundle.field_test_ref3.entity:entity_test_with_bundle.field_test_text.value', + 'field_test_ref1.field_test_ref3.field_test_text.value', + ], + 'entity reference with a reference property then another entity reference with no reference property a complex field with property specifier `value`' => [ + 'field_test_ref1.entity.field_test_ref3.entity:entity_test_with_bundle.field_test_text.value', + 'field_test_ref1.entity.field_test_ref3.field_test_text.value', + ], + 'entity reference with no reference property then another entity reference with a reference property a complex field with property specifier `value`' => [ + 'field_test_ref1.entity:entity_test_with_bundle.field_test_ref3.entity.field_test_text.value', + 'field_test_ref1.field_test_ref3.entity.field_test_text.value', + ], + 'entity reference with a reference property then another entity reference with a reference property a complex field with property specifier `value`' => [ + 'field_test_ref1.entity.field_test_ref3.entity.field_test_text.value', + 'field_test_ref1.entity.field_test_ref3.entity.field_test_text.value', + ], 'entity reference with target bundles then property specifier `entity:entity_test_with_bundle` then a primitive field on multiple bundles' => [ 'field_test_ref1.entity:entity_test_with_bundle.field_test3', @@ -236,7 +290,10 @@ public static function resolveInternalEntityQueryPathProvider() { 'entity_test_with_bundle', 'bundle3', ], - 'entity reference then property specifier `entity:entity_test_with_bundle` then another entity reference before a primitive field' => ['field_test_ref1.entity:entity_test_with_bundle.field_test_ref3.entity:entity_test_with_bundle.field_test2', 'field_test_ref1.entity:entity_test_with_bundle.field_test_ref3.field_test2'], + 'entity reference then property specifier `entity:entity_test_with_bundle` then another entity reference before a primitive field' => [ + 'field_test_ref1.entity:entity_test_with_bundle.field_test_ref3.entity:entity_test_with_bundle.field_test2', + 'field_test_ref1.entity:entity_test_with_bundle.field_test_ref3.field_test2', + ], ]; } diff --git a/core/modules/jsonapi/tests/src/Kernel/Normalizer/RelationshipNormalizerTest.php b/core/modules/jsonapi/tests/src/Kernel/Normalizer/RelationshipNormalizerTest.php index e5abd16c4be4..fda19e7840e8 100644 --- a/core/modules/jsonapi/tests/src/Kernel/Normalizer/RelationshipNormalizerTest.php +++ b/core/modules/jsonapi/tests/src/Kernel/Normalizer/RelationshipNormalizerTest.php @@ -165,7 +165,10 @@ protected function setUp(): void { 'entity_type' => 'node', ]; FieldStorageConfig::create(['field_name' => 'field_image', 'cardinality' => 1] + $field_storage_config)->save(); - FieldStorageConfig::create(['field_name' => 'field_images', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED] + $field_storage_config)->save(); + FieldStorageConfig::create([ + 'field_name' => 'field_images', + 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, + ] + $field_storage_config)->save(); $field_config = [ 'entity_type' => 'node', 'bundle' => 'referencer', diff --git a/core/modules/layout_builder/tests/src/Kernel/LayoutBuilderEntityViewDisplayTest.php b/core/modules/layout_builder/tests/src/Kernel/LayoutBuilderEntityViewDisplayTest.php index ee7d89ac6e87..8b81f5e11ee5 100644 --- a/core/modules/layout_builder/tests/src/Kernel/LayoutBuilderEntityViewDisplayTest.php +++ b/core/modules/layout_builder/tests/src/Kernel/LayoutBuilderEntityViewDisplayTest.php @@ -39,7 +39,9 @@ protected function getSectionList(array $section_data) { */ public function testInvalidConfiguration(): void { $this->expectException(SchemaIncompleteException::class); - $this->sectionList->getSection(0)->getComponent('10000000-0000-1000-a000-000000000000')->setConfiguration(['id' => 'foo', 'bar' => 'baz']); + $this->sectionList->getSection(0) + ->getComponent('10000000-0000-1000-a000-000000000000') + ->setConfiguration(['id' => 'foo', 'bar' => 'baz']); $this->sectionList->save(); } diff --git a/core/modules/layout_builder/tests/src/Kernel/OverridesSectionStorageTest.php b/core/modules/layout_builder/tests/src/Kernel/OverridesSectionStorageTest.php index f6eb7fae7da7..240ade20434f 100644 --- a/core/modules/layout_builder/tests/src/Kernel/OverridesSectionStorageTest.php +++ b/core/modules/layout_builder/tests/src/Kernel/OverridesSectionStorageTest.php @@ -165,7 +165,13 @@ public static function providerTestAccess() { TRUE, TRUE, [], ['configure editable entity_test entity_test layout overrides', 'administer entity_test content'], ]; $data['enabled, data, bundle edit overrides, edit access'] = [ - TRUE, TRUE, $section_data, ['configure editable entity_test entity_test layout overrides', 'administer entity_test content'], + TRUE, + TRUE, + $section_data, + [ + 'configure editable entity_test entity_test layout overrides', + 'administer entity_test content', + ], ]; return $data; } diff --git a/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php b/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php index bcf2b7738816..9ce978fcc105 100644 --- a/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php +++ b/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php @@ -120,8 +120,22 @@ public function testCreateTranslation(): void { public function testCreateTranslationMultiValue(): void { $config_name = 'locale_test.translation_multiple'; - $this->saveLanguageOverride($config_name, 'test_multiple', ['string' => 'String (German)', 'another_string' => 'Another string (German)'], 'de'); - $this->saveLanguageOverride($config_name, 'test_after_multiple', ['string' => 'After string (German)', 'another_string' => 'After another string (German)'], 'de'); + $this->saveLanguageOverride( + $config_name, + 'test_multiple', + [ + 'string' => 'String (German)', + 'another_string' => 'Another string (German)', + ], + 'de'); + $this->saveLanguageOverride( + $config_name, + 'test_after_multiple', + [ + 'string' => 'After string (German)', + 'another_string' => 'After another string (German)', + ], + 'de'); $strings = $this->stringStorage->getTranslations([ 'type' => 'configuration', 'name' => $config_name, diff --git a/core/modules/locale/tests/src/Kernel/LocaleConfigurableLanguageManagerTest.php b/core/modules/locale/tests/src/Kernel/LocaleConfigurableLanguageManagerTest.php index 5a2a07706b19..6c4ec95dccbe 100644 --- a/core/modules/locale/tests/src/Kernel/LocaleConfigurableLanguageManagerTest.php +++ b/core/modules/locale/tests/src/Kernel/LocaleConfigurableLanguageManagerTest.php @@ -27,7 +27,11 @@ class LocaleConfigurableLanguageManagerTest extends KernelTestBase { */ public function testGetLanguages(): void { $this->installSchema('locale', ['locales_source', 'locales_target', 'locales_location']); - $default_language = ConfigurableLanguage::create(['label' => $this->randomMachineName(), 'id' => 'default', 'weight' => 0]); + $default_language = ConfigurableLanguage::create([ + 'label' => $this->randomMachineName(), + 'id' => 'default', + 'weight' => 0, + ]); $default_language->save(); // Set new default language. @@ -37,7 +41,11 @@ public function testGetLanguages(): void { $languages = \Drupal::service('language_manager')->getLanguages(LanguageInterface::STATE_ALL); $this->assertEquals(['default', 'und', 'zxx'], array_keys($languages)); - $configurableLanguage = ConfigurableLanguage::create(['label' => $this->randomMachineName(), 'id' => 'test', 'weight' => 1]); + $configurableLanguage = ConfigurableLanguage::create([ + 'label' => $this->randomMachineName(), + 'id' => 'test', + 'weight' => 1, + ]); // Simulate a configuration sync by setting the flag otherwise the locked // language weights would be updated whilst saving. // @see \Drupal\language\Entity\ConfigurableLanguage::postSave() diff --git a/core/modules/locale/tests/src/Kernel/LocaleStringTest.php b/core/modules/locale/tests/src/Kernel/LocaleStringTest.php index 01a5b66f5283..f5f27b01a627 100644 --- a/core/modules/locale/tests/src/Kernel/LocaleStringTest.php +++ b/core/modules/locale/tests/src/Kernel/LocaleStringTest.php @@ -76,7 +76,11 @@ public function testStringCrudApi(): void { $this->assertEquals(LOCALE_NOT_CUSTOMIZED, $translation->customized); $string1 = $this->storage->findTranslation(['language' => $langcode, 'lid' => $source->lid]); $this->assertEquals($translation->translation, $string1->translation); - $string2 = $this->storage->findTranslation(['language' => $langcode, 'source' => $source->source, 'context' => $source->context]); + $string2 = $this->storage->findTranslation([ + 'language' => $langcode, + 'source' => $source->source, + 'context' => $source->context, + ]); $this->assertEquals($translation->translation, $string2->translation); $translation ->setCustomized() @@ -148,14 +152,22 @@ public function testStringSearchApi(): void { $this->createAllTranslations($source2, ['customized' => LOCALE_CUSTOMIZED]); // Try quick search function with different field combinations. $langcode = 'es'; - $found = $this->storage->findTranslation(['language' => $langcode, 'source' => $source1->source, 'context' => $source1->context]); + $found = $this->storage->findTranslation([ + 'language' => $langcode, + 'source' => $source1->source, + 'context' => $source1->context, + ]); $this->assertNotNull($found, 'Translation not found searching by source and context.'); $this->assertNotNull($found->language); $this->assertNotNull($found->translation); $this->assertFalse($found->isNew()); $this->assertEquals($translate1[$langcode]->translation, $found->translation); // Now try a translation not found. - $found = $this->storage->findTranslation(['language' => $langcode, 'source' => $source3->source, 'context' => $source3->context]); + $found = $this->storage->findTranslation([ + 'language' => $langcode, + 'source' => $source3->source, + 'context' => $source3->context, + ]); $this->assertNotNull($found); $this->assertSame($source3->lid, $found->lid); $this->assertNull($found->translation); @@ -171,7 +183,11 @@ public function testStringSearchApi(): void { $this->assertCount($language_count, $translations); // Load all Spanish customized translations. - $translations = $this->storage->getTranslations(['language' => 'es', 'customized' => LOCALE_CUSTOMIZED, 'translated' => TRUE]); + $translations = $this->storage->getTranslations([ + 'language' => 'es', + 'customized' => LOCALE_CUSTOMIZED, + 'translated' => TRUE, + ]); $this->assertCount(1, $translations); // Load all source strings without translation (1). diff --git a/core/modules/media/tests/src/Kernel/MediaSourceTest.php b/core/modules/media/tests/src/Kernel/MediaSourceTest.php index 16bd2102223b..03956d964de4 100644 --- a/core/modules/media/tests/src/Kernel/MediaSourceTest.php +++ b/core/modules/media/tests/src/Kernel/MediaSourceTest.php @@ -122,8 +122,10 @@ public function testDefaultName(): void { // Change the default name attribute and see if it is used to set the name. $name = 'Old Major'; - \Drupal::state()->set('media_source_test_attributes', ['alternative_name' => ['title' => 'Alternative name', 'value' => $name]]); - \Drupal::state()->set('media_source_test_definition', ['default_name_metadata_attribute' => 'alternative_name']); + \Drupal::state() + ->set('media_source_test_attributes', ['alternative_name' => ['title' => 'Alternative name', 'value' => $name]]); + \Drupal::state() + ->set('media_source_test_definition', ['default_name_metadata_attribute' => 'alternative_name']); /** @var \Drupal\media\MediaInterface $media */ $media = Media::create(['bundle' => $this->testMediaType->id()]); $media_source = $media->getSource(); diff --git a/core/modules/media_library/tests/src/Kernel/MediaLibraryAccessTest.php b/core/modules/media_library/tests/src/Kernel/MediaLibraryAccessTest.php index 31dba044ae90..ff8bfba10e15 100644 --- a/core/modules/media_library/tests/src/Kernel/MediaLibraryAccessTest.php +++ b/core/modules/media_library/tests/src/Kernel/MediaLibraryAccessTest.php @@ -100,7 +100,16 @@ public function testFieldWidgetEntityCreateAccess(): void { ]); $access_result = $ui_builder->checkAccess($this->createUser(), $state); - $this->assertAccess($access_result, FALSE, "The following permissions are required: 'administer entity_test content' OR 'administer entity_test_with_bundle content' OR 'create test entity_test_with_bundle entities'.", [], ['url.query_args', 'user.permissions']); + $this->assertAccess( + $access_result, + FALSE, + "The following permissions are required: 'administer entity_test content' OR 'administer entity_test_with_bundle content' OR 'create test entity_test_with_bundle entities'.", + [], + [ + 'url.query_args', + 'user.permissions', + ] + ); // Create a user with the appropriate permissions and assert that access is // granted. @@ -109,7 +118,16 @@ public function testFieldWidgetEntityCreateAccess(): void { 'view media', ]); $access_result = $ui_builder->checkAccess($account, $state); - $this->assertAccess($access_result, TRUE, NULL, Views::getView('media_library')->storage->getCacheTags(), ['url.query_args', 'user.permissions']); + $this->assertAccess( + $access_result, + TRUE, + NULL, + Views::getView('media_library')->storage->getCacheTags(), + [ + 'url.query_args', + 'user.permissions', + ] + ); } /** @@ -237,7 +255,13 @@ public function testFieldWidgetEntityEditAccess(): void { 'view media', ]); $access_result = $ui_builder->checkAccess($account, $state); - $this->assertAccess($access_result, TRUE, NULL, Views::getView('media_library')->storage->getCacheTags(), ['url.query_args', 'user.permissions']); + $this->assertAccess( + $access_result, + TRUE, + NULL, + Views::getView('media_library')->storage->getCacheTags(), + ['url.query_args', 'user.permissions'] + ); } /** @@ -293,7 +317,13 @@ public function testFieldWidgetEntityFieldAccess(string $field_type): void { 'field_name' => $field_storage->getName(), ]); $access_result = $ui_builder->checkAccess($account, $state); - $this->assertAccess($access_result, FALSE, 'Field access denied by test module', [], ['url.query_args', 'user.permissions']); + $this->assertAccess( + $access_result, + FALSE, + 'Field access denied by test module', + [], + ['url.query_args', 'user.permissions'] + ); // Assert that field access is also checked with a real entity. $entity = EntityTestWithBundle::create([ @@ -313,7 +343,15 @@ public function testFieldWidgetEntityFieldAccess(string $field_type): void { $parameters ); $access_result = $ui_builder->checkAccess($account, $state); - $this->assertAccess($access_result, FALSE, 'Field access denied by test module', [], ['url.query_args', 'user.permissions']); + $this->assertAccess( + $access_result, + FALSE, + 'Field access denied by test module', + [], + [ + 'url.query_args', + 'user.permissions', + ]); } /** @@ -347,7 +385,12 @@ public function testViewAccess(): void { // Assert the 'view media' permission is needed to access the library and // validate the cache dependencies. $access_result = $ui_builder->checkAccess($forbidden_account, $state); - $this->assertAccess($access_result, FALSE, "The 'view media' permission is required.", $view_original->storage->getCacheTags(), ['url.query_args', 'user.permissions']); + $this->assertAccess( + $access_result, + FALSE, + "The 'view media' permission is required.", + $view_original->storage->getCacheTags(), + ['url.query_args', 'user.permissions']); // Assert that the media library access is denied when the view widget // display is deleted. @@ -363,13 +406,21 @@ public function testViewAccess(): void { // works again. $view_original->storage->save(); $access_result = $ui_builder->checkAccess($allowed_account, $state); - $this->assertAccess($access_result, TRUE, NULL, $view_original->storage->getCacheTags(), ['url.query_args', 'user.permissions']); + $this->assertAccess( + $access_result, + TRUE, + NULL, + $view_original->storage->getCacheTags(), + ['url.query_args', 'user.permissions']); // Assert that the media library access is denied when the entire media // library view is deleted. Views::getView('media_library')->storage->delete(); $access_result = $ui_builder->checkAccess($allowed_account, $state); - $this->assertAccess($access_result, FALSE, 'The media library view does not exist.'); + $this->assertAccess( + $access_result, + FALSE, + 'The media library view does not exist.'); } /** diff --git a/core/modules/menu_link_content/tests/src/Kernel/Migrate/d6/MigrateMenuLinkTest.php b/core/modules/menu_link_content/tests/src/Kernel/Migrate/d6/MigrateMenuLinkTest.php index 81cbcdcbdb3a..76fd35eecf90 100644 --- a/core/modules/menu_link_content/tests/src/Kernel/Migrate/d6/MigrateMenuLinkTest.php +++ b/core/modules/menu_link_content/tests/src/Kernel/Migrate/d6/MigrateMenuLinkTest.php @@ -88,18 +88,108 @@ protected function assertEntity(string $id, string $title, string $menu, ?string * Tests migration of menu links. */ public function testMenuLinks(): void { - $this->assertEntity('138', 'Test 1', 'secondary-links', 'Test menu link 1', TRUE, FALSE, ['attributes' => ['title' => 'Test menu link 1'], 'langcode' => 'en'], 'internal:/user/login', -50); - $this->assertEntity('139', 'Test 2', 'secondary-links', 'Test menu link 2', TRUE, TRUE, ['query' => ['foo' => 'bar'], 'attributes' => ['title' => 'Test menu link 2']], 'internal:/admin', -49); - $this->assertEntity('140', 'Drupal.org', 'secondary-links', NULL, TRUE, FALSE, ['attributes' => ['title' => '']], 'https://www.drupal.org', -50); + $this->assertEntity( + '138', + 'Test 1', + 'secondary-links', + 'Test menu link 1', + TRUE, + FALSE, + [ + 'attributes' => ['title' => 'Test menu link 1'], + 'langcode' => 'en', + ], + 'internal:/user/login', + -50); + $this->assertEntity( + '139', + 'Test 2', + 'secondary-links', + 'Test menu link 2', + TRUE, + TRUE, + [ + 'query' => ['foo' => 'bar'], + 'attributes' => ['title' => 'Test menu link 2'], + ], + 'internal:/admin', + -49); + $this->assertEntity( + '140', + 'Drupal.org', + 'secondary-links', + NULL, + TRUE, + FALSE, + ['attributes' => ['title' => '']], + 'https://www.drupal.org', + -50); // Assert that missing title attributes don't stop or break migration. - $this->assertEntity('393', 'Test 3', 'secondary-links', NULL, TRUE, FALSE, [], 'internal:/user/login', -47); + $this->assertEntity( + '393', + 'Test 3', + 'secondary-links', + NULL, + TRUE, + FALSE, + [], + 'internal:/user/login', + -47); // Test the migration of menu links for translated nodes. - $this->assertEntity('459', 'The Real McCoy', 'primary-links', NULL, TRUE, FALSE, ['attributes' => ['title' => ''], 'alter' => TRUE], 'entity:node/10', 0); - $this->assertEntity('460', 'Le Vrai McCoy', 'primary-links', NULL, TRUE, FALSE, ['attributes' => ['title' => ''], 'alter' => TRUE], 'entity:node/10', 0); - $this->assertEntity('461', 'Abantu zulu', 'primary-links', NULL, TRUE, FALSE, ['attributes' => ['title' => ''], 'alter' => TRUE], 'entity:node/12', 0); - $this->assertEntity('462', 'The Zulu People', 'primary-links', NULL, TRUE, FALSE, ['attributes' => ['title' => ''], 'alter' => TRUE], 'entity:node/12', 0); + $this->assertEntity( + '459', + 'The Real McCoy', + 'primary-links', + NULL, + TRUE, + FALSE, + [ + 'attributes' => ['title' => ''], + 'alter' => TRUE, + ], + 'entity:node/10', + 0); + $this->assertEntity( + '460', + 'Le Vrai McCoy', + 'primary-links', + NULL, + TRUE, + FALSE, + [ + 'attributes' => ['title' => ''], + 'alter' => TRUE, + ], + 'entity:node/10', + 0); + $this->assertEntity( + '461', + 'Abantu zulu', + 'primary-links', + NULL, + TRUE, + FALSE, + [ + 'attributes' => ['title' => ''], + 'alter' => TRUE, + ], + 'entity:node/12', + 0); + $this->assertEntity( + '462', + 'The Zulu People', + 'primary-links', + NULL, + TRUE, + FALSE, + [ + 'attributes' => ['title' => ''], + 'alter' => TRUE, + ], + 'entity:node/12', + 0); } } diff --git a/core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkLocalizedTest.php b/core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkLocalizedTest.php index 45f47c24a94f..69804a2ddd5a 100644 --- a/core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkLocalizedTest.php +++ b/core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkLocalizedTest.php @@ -48,9 +48,48 @@ protected function setUp(): void { */ public function testMenuLinkLocalized(): void { // A translate and localize menu, menu-test-menu. - $this->assertEntity(468, 'en', 'Yahoo', 'menu-test-menu', 'english description', TRUE, FALSE, ['attributes' => ['title' => 'english description'], 'alter' => TRUE], 'http://yahoo.com', 0); - $this->assertEntity(468, 'fr', 'fr - Yahoo', 'menu-test-menu', 'fr - description', TRUE, FALSE, ['attributes' => ['title' => 'english description'], 'alter' => TRUE], 'http://yahoo.com', 0); - $this->assertEntity(468, 'is', 'is - Yahoo', 'menu-test-menu', 'is - description', TRUE, FALSE, ['attributes' => ['title' => 'english description'], 'alter' => TRUE], 'http://yahoo.com', 0); + $this->assertEntity( + 468, + 'en', + 'Yahoo', + 'menu-test-menu', + 'english description', + TRUE, + FALSE, + [ + 'attributes' => ['title' => 'english description'], + 'alter' => TRUE, + ], + 'http://yahoo.com', + 0); + $this->assertEntity( + 468, + 'fr', + 'fr - Yahoo', + 'menu-test-menu', + 'fr - description', + TRUE, + FALSE, + [ + 'attributes' => ['title' => 'english description'], + 'alter' => TRUE, + ], + 'http://yahoo.com', + 0); + $this->assertEntity( + 468, + 'is', + 'is - Yahoo', + 'menu-test-menu', + 'is - description', + TRUE, + FALSE, + [ + 'attributes' => ['title' => 'english description'], + 'alter' => TRUE, + ], + 'http://yahoo.com', + 0); } } diff --git a/core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkTest.php b/core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkTest.php index fa6575736891..9a35be48c951 100644 --- a/core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkTest.php +++ b/core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkTest.php @@ -61,25 +61,97 @@ protected function setUp(): void { * Tests migration of menu links. */ public function testMenuLinks(): void { - $this->assertEntity(469, 'und', 'Bing', static::MENU_NAME, 'Bing', TRUE, FALSE, ['attributes' => ['title' => 'Bing']], 'http://bing.com', 0); + $this->assertEntity( + 469, + 'und', + 'Bing', + static::MENU_NAME, + 'Bing', + TRUE, + FALSE, + ['attributes' => ['title' => 'Bing']], + 'http://bing.com', + 0); // This link has an i18n translation so the language is changed to the // default language of the source site. - $this->assertEntity(467, 'en', 'Google', static::MENU_NAME, 'Google', TRUE, FALSE, ['attributes' => ['title' => 'Google']], 'http://google.com', 0); - $this->assertEntity(468, 'en', 'Yahoo', static::MENU_NAME, 'english description', TRUE, FALSE, ['attributes' => ['title' => 'english description'], 'alter' => TRUE], 'http://yahoo.com', 0); + $this->assertEntity( + 467, + 'en', + 'Google', + static::MENU_NAME, + 'Google', + TRUE, + FALSE, + ['attributes' => ['title' => 'Google']], + 'http://google.com', + 0); + $this->assertEntity( + 468, + 'en', + 'Yahoo', + static::MENU_NAME, + 'english description', + TRUE, + FALSE, + [ + 'attributes' => ['title' => 'english description'], + 'alter' => TRUE, + ], + 'http://yahoo.com', + 0); // Tests migrating an external link with an undefined title attribute. - $this->assertEntity(470, 'und', 'Ask', static::MENU_NAME, NULL, TRUE, FALSE, [], 'http://ask.com', 0); - - $this->assertEntity(245, 'und', 'Home', 'main', NULL, TRUE, FALSE, [], 'internal:/', 0); - $this->assertEntity(478, 'und', 'custom link test', 'admin', NULL, TRUE, FALSE, ['attributes' => ['title' => '']], 'internal:/admin/content', 0); - $this->assertEntity(479, 'und', 'node link test', 'tools', 'node 2', TRUE, FALSE, [ - 'attributes' => ['title' => 'node 2'], - 'query' => [ - 'name' => 'ferret', - 'color' => 'purple', - ], - ], - 'entity:node/2', 3); + $this->assertEntity( + 470, + 'und', + 'Ask', + static::MENU_NAME, + NULL, + TRUE, + FALSE, + [], + 'http://ask.com', + 0); + + $this->assertEntity( + 245, + 'und', + 'Home', + 'main', + NULL, + TRUE, + FALSE, + [], + 'internal:/', + 0); + $this->assertEntity( + 478, + 'und', + 'custom link test', + 'admin', + NULL, + TRUE, + FALSE, + ['attributes' => ['title' => '']], + 'internal:/admin/content', + 0); + $this->assertEntity( + 479, + 'und', + 'node link test', + 'tools', + 'node 2', + TRUE, + FALSE, + [ + 'attributes' => ['title' => 'node 2'], + 'query' => [ + 'name' => 'ferret', + 'color' => 'purple', + ], + ], + 'entity:node/2', + 3); $menu_link_tree_service = \Drupal::service('menu.link_tree'); $parameters = new MenuTreeParameters(); diff --git a/core/modules/migrate/tests/src/Kernel/MigrateEntityContentValidationTest.php b/core/modules/migrate/tests/src/Kernel/MigrateEntityContentValidationTest.php index c3cc5bbc74ee..774173631911 100644 --- a/core/modules/migrate/tests/src/Kernel/MigrateEntityContentValidationTest.php +++ b/core/modules/migrate/tests/src/Kernel/MigrateEntityContentValidationTest.php @@ -153,7 +153,14 @@ public function test2(): void { 'validate' => TRUE, ], ]); - $this->assertSame(sprintf('1: [user]: name=%s||name=%s||mail=Email field is required.', $username_constraint->illegalMessage, new FormattableMarkup($username_constraint->tooLongMessage, ['%name' => $long_username, '%max' => 60])), $this->messages[0], 'First message should have 3 validation errors.'); + $this->assertSame(sprintf('1: [user]: name=%s||name=%s||mail=Email field is required.', + $username_constraint->illegalMessage, + new FormattableMarkup($username_constraint->tooLongMessage, [ + '%name' => $long_username, + '%max' => 60, + ])), + $this->messages[0], + 'First message should have 3 validation errors.'); $this->assertSame(sprintf('2: [user]: name=%s||mail=Email field is required.', $username_constraint->illegalMessage), $this->messages[1], 'Second message should have 2 validation errors.'); $this->assertSame(sprintf('3: [user]: name=%s||mail=Email field is required.', $username_constraint->illegalMessage), $this->messages[2], 'Third message should have 2 validation errors.'); $this->assertArrayNotHasKey(3, $this->messages, 'Fourth message should not exist.'); diff --git a/core/modules/navigation/tests/src/Kernel/NavigationMenuLinkTreeTest.php b/core/modules/navigation/tests/src/Kernel/NavigationMenuLinkTreeTest.php index b03f0f6b1f25..d78fec541d09 100644 --- a/core/modules/navigation/tests/src/Kernel/NavigationMenuLinkTreeTest.php +++ b/core/modules/navigation/tests/src/Kernel/NavigationMenuLinkTreeTest.php @@ -60,9 +60,30 @@ public function testNavigationMenuLinkTreeAlter(): void { $storage->create(['id' => 'menu1', 'label' => 'Menu 1'])->save(); $storage->create(['id' => 'menu2', 'label' => 'Menu 2'])->save(); - \Drupal::entityTypeManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content', 'title' => 'Link test'])->save(); - \Drupal::entityTypeManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content', 'title' => 'Link test'])->save(); - \Drupal::entityTypeManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu2', 'bundle' => 'menu_link_content', 'title' => 'Link test'])->save(); + \Drupal::entityTypeManager() + ->getStorage('menu_link_content') + ->create([ + 'link' => ['uri' => 'internal:/menu_name_test'], + 'menu_name' => 'menu1', + 'bundle' => 'menu_link_content', + 'title' => 'Link test', + ])->save(); + \Drupal::entityTypeManager() + ->getStorage('menu_link_content') + ->create([ + 'link' => ['uri' => 'internal:/menu_name_test'], + 'menu_name' => 'menu1', + 'bundle' => 'menu_link_content', + 'title' => 'Link test', + ])->save(); + \Drupal::entityTypeManager() + ->getStorage('menu_link_content') + ->create([ + 'link' => ['uri' => 'internal:/menu_name_test'], + 'menu_name' => 'menu2', + 'bundle' => 'menu_link_content', + 'title' => 'Link test', + ])->save(); $output = $this->linkTree->load('menu1', new MenuTreeParameters()); $this->assertCount(2, $output); diff --git a/core/modules/node/tests/src/Kernel/NodeListBuilderTest.php b/core/modules/node/tests/src/Kernel/NodeListBuilderTest.php index 82303fe1df5b..c671caf3a1b9 100644 --- a/core/modules/node/tests/src/Kernel/NodeListBuilderTest.php +++ b/core/modules/node/tests/src/Kernel/NodeListBuilderTest.php @@ -38,7 +38,14 @@ public function testCacheContexts(): void { $build = $list_builder->render(); $this->container->get('renderer')->renderRoot($build); - $this->assertEqualsCanonicalizing(['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme', 'url.query_args.pagers:0', 'user.node_grants:view', 'user.permissions'], $build['#cache']['contexts']); + $this->assertEqualsCanonicalizing([ + 'languages:' . LanguageInterface::TYPE_INTERFACE, + 'theme', + 'url.query_args.pagers:0', + 'user.node_grants:view', + 'user.permissions', + ], + $build['#cache']['contexts']); } } diff --git a/core/modules/node/tests/src/Kernel/NodeTemplateSuggestionsTest.php b/core/modules/node/tests/src/Kernel/NodeTemplateSuggestionsTest.php index 2f3cab4d6949..0b06e6022c2b 100644 --- a/core/modules/node/tests/src/Kernel/NodeTemplateSuggestionsTest.php +++ b/core/modules/node/tests/src/Kernel/NodeTemplateSuggestionsTest.php @@ -50,7 +50,15 @@ public function testNodeThemeHookSuggestions(): void { $variables['elements'] = $build; $suggestions = \Drupal::moduleHandler()->invokeAll('theme_suggestions_node', [$variables]); - $this->assertEquals(['node__full', 'node__page', 'node__page__full', 'node__' . $node->id(), 'node__' . $node->id() . '__full'], $suggestions, 'Found expected node suggestions.'); + $this->assertEquals([ + 'node__full', + 'node__page', + 'node__page__full', + 'node__' . $node->id(), + 'node__' . $node->id() . '__full', + ], + $suggestions, + 'Found expected node suggestions.'); // Change the view mode. $view_mode = 'node.my_custom_view_mode'; @@ -59,7 +67,15 @@ public function testNodeThemeHookSuggestions(): void { $variables['elements'] = $build; $suggestions = \Drupal::moduleHandler()->invokeAll('theme_suggestions_node', [$variables]); - $this->assertEquals(['node__node_my_custom_view_mode', 'node__page', 'node__page__node_my_custom_view_mode', 'node__' . $node->id(), 'node__' . $node->id() . '__node_my_custom_view_mode'], $suggestions, 'Found expected node suggestions.'); + $this->assertEquals([ + 'node__node_my_custom_view_mode', + 'node__page', + 'node__page__node_my_custom_view_mode', + 'node__' . $node->id(), + 'node__' . $node->id() . '__node_my_custom_view_mode', + ], + $suggestions, + 'Found expected node suggestions.'); } } diff --git a/core/modules/node/tests/src/Kernel/NodeTokenReplaceTest.php b/core/modules/node/tests/src/Kernel/NodeTokenReplaceTest.php index 8b16298c0a12..82ab187a1cf4 100644 --- a/core/modules/node/tests/src/Kernel/NodeTokenReplaceTest.php +++ b/core/modules/node/tests/src/Kernel/NodeTokenReplaceTest.php @@ -50,7 +50,13 @@ public function testNodeTokenReplacement(): void { 'type' => 'article', 'uid' => $account->id(), 'title' => '<blink>Blinking Text</blink>', - 'body' => [['value' => 'Regular NODE body for the test.', 'summary' => 'Fancy NODE summary.', 'format' => 'plain_text']], + 'body' => [ + [ + 'value' => 'Regular NODE body for the test.', + 'summary' => 'Fancy NODE summary.', + 'format' => 'plain_text', + ], + ], ]); $node->save(); diff --git a/core/modules/package_manager/tests/src/Kernel/ComposerPatchesValidatorTest.php b/core/modules/package_manager/tests/src/Kernel/ComposerPatchesValidatorTest.php index 27ce47ab3733..ea50a65422d0 100644 --- a/core/modules/package_manager/tests/src/Kernel/ComposerPatchesValidatorTest.php +++ b/core/modules/package_manager/tests/src/Kernel/ComposerPatchesValidatorTest.php @@ -286,7 +286,12 @@ public function testErrorDuringPreApplyWithHelp(int $in_active, int $in_stage, a ->toString(); // Reformat the provided results so that they all have the link to the // online documentation appended to them. - $messages[$message_index] = $this->t('@message See <a href=":url">the help page</a> for information on how to resolve the problem.', ['@message' => $message, ':url' => $url]); + $messages[$message_index] = $this->t( + '@message See <a href=":url">the help page</a> for information on how to resolve the problem.', + [ + '@message' => $message, + ':url' => $url, + ]); } } $expected_results[$result_index] = ValidationResult::createError($messages, $result->summary); diff --git a/core/modules/package_manager/tests/src/Kernel/EnvironmentSupportValidatorTest.php b/core/modules/package_manager/tests/src/Kernel/EnvironmentSupportValidatorTest.php index 7ae3424270f8..b8aefbc04c52 100644 --- a/core/modules/package_manager/tests/src/Kernel/EnvironmentSupportValidatorTest.php +++ b/core/modules/package_manager/tests/src/Kernel/EnvironmentSupportValidatorTest.php @@ -30,7 +30,12 @@ public function testInvalidUrl(): void { $this->t('Package Manager is not supported by your environment.'), ]); foreach ([PreCreateEvent::class, StatusCheckEvent::class] as $event_class) { - $this->assertEventPropagationStopped($event_class, [$this->container->get(EnvironmentSupportValidator::class), 'validate']); + $this->assertEventPropagationStopped( + $event_class, + [ + $this->container->get(EnvironmentSupportValidator::class), + 'validate', + ]); } $this->assertStatusCheckResults([$result]); $this->assertResults([$result], PreCreateEvent::class); @@ -48,7 +53,9 @@ public function testInvalidUrlDuringPreApply(): void { $this->t('Package Manager is not supported by your environment.'), ]); - $this->assertEventPropagationStopped(PreApplyEvent::class, [$this->container->get(EnvironmentSupportValidator::class), 'validate']); + $this->assertEventPropagationStopped( + PreApplyEvent::class, + [$this->container->get(EnvironmentSupportValidator::class), 'validate']); $this->assertResults([$result], PreApplyEvent::class); } diff --git a/core/modules/pgsql/tests/src/Kernel/pgsql/NonPublicSchemaTest.php b/core/modules/pgsql/tests/src/Kernel/pgsql/NonPublicSchemaTest.php index 73f861d0b66a..2f7386b4306b 100644 --- a/core/modules/pgsql/tests/src/Kernel/pgsql/NonPublicSchemaTest.php +++ b/core/modules/pgsql/tests/src/Kernel/pgsql/NonPublicSchemaTest.php @@ -128,10 +128,25 @@ public function testExtensionExists(): void { * @covers ::changeField */ public function testField(): void { - $this->testingFakeConnection->schema()->addField('faking_table', 'added_field', ['type' => 'int', 'not null' => FALSE]); + $this->testingFakeConnection->schema() + ->addField( + 'faking_table', + 'added_field', + [ + 'type' => 'int', + 'not null' => FALSE, + ]); $this->assertTrue($this->testingFakeConnection->schema()->fieldExists('faking_table', 'added_field')); - $this->testingFakeConnection->schema()->changeField('faking_table', 'added_field', 'changed_field', ['type' => 'int', 'not null' => FALSE]); + $this->testingFakeConnection->schema() + ->changeField( + 'faking_table', + 'added_field', + 'changed_field', + [ + 'type' => 'int', + 'not null' => FALSE, + ]); $this->assertFalse($this->testingFakeConnection->schema()->fieldExists('faking_table', 'added_field')); $this->assertTrue($this->testingFakeConnection->schema()->fieldExists('faking_table', 'changed_field')); diff --git a/core/modules/rest/tests/src/Kernel/RequestHandlerTest.php b/core/modules/rest/tests/src/Kernel/RequestHandlerTest.php index 3e5606b8645e..387f309ec4ec 100644 --- a/core/modules/rest/tests/src/Kernel/RequestHandlerTest.php +++ b/core/modules/rest/tests/src/Kernel/RequestHandlerTest.php @@ -59,7 +59,14 @@ protected function setUp(): void { */ public function testHandle(): void { $request = new Request([], [], [], [], [], ['CONTENT_TYPE' => 'application/json'], Json::encode(['this is an array'])); - $route_match = new RouteMatch('test', (new Route('/rest/test', ['_rest_resource_config' => 'rest_plugin', 'example' => ''], ['_format' => 'json']))->setMethods(['GET'])); + $route_match = new RouteMatch( + 'test', + (new Route( + '/rest/test', + ['_rest_resource_config' => 'rest_plugin', 'example' => ''], + ['_format' => 'json'] + ))->setMethods(['GET']) + ); $resource = $this->prophesize(StubRequestHandlerResourcePlugin::class); $resource->get('', $request) @@ -88,7 +95,16 @@ public function testHandle(): void { $this->assertEquals($response, $handler_response); // We will call the patch method this time. - $route_match = new RouteMatch('test', (new Route('/rest/test', ['_rest_resource_config' => 'rest_plugin', 'example_original' => ''], ['_content_type_format' => 'json']))->setMethods(['PATCH'])); + $route_match = new RouteMatch( + 'test', + (new Route( + '/rest/test', + [ + '_rest_resource_config' => 'rest_plugin', + 'example_original' => '', + ], + ['_content_type_format' => 'json'] + ))->setMethods(['PATCH'])); $request->setMethod('PATCH'); $response = new ResourceResponse([]); $resource->patch(['this is an array'], $request) diff --git a/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php b/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php index 48f7df788a1c..3c8ade61831e 100644 --- a/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php +++ b/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php @@ -134,14 +134,65 @@ protected function setUp(): void { // - 8 // With link 6 being the only external link. $links = [ - 1 => MenuLinkMock::create(['id' => 'test.example1', 'route_name' => 'example1', 'title' => 'foo', 'parent' => '', 'weight' => 0]), - 2 => MenuLinkMock::create(['id' => 'test.example2', 'route_name' => 'example2', 'title' => 'bar', 'parent' => '', 'route_parameters' => ['foo' => 'bar'], 'weight' => 1]), - 3 => MenuLinkMock::create(['id' => 'test.example3', 'route_name' => 'example3', 'title' => 'baz', 'parent' => 'test.example2', 'weight' => 2]), - 4 => MenuLinkMock::create(['id' => 'test.example4', 'route_name' => 'example4', 'title' => 'qux', 'parent' => 'test.example3', 'weight' => 3]), - 5 => MenuLinkMock::create(['id' => 'test.example5', 'route_name' => 'example5', 'title' => 'title5', 'parent' => '', 'expanded' => TRUE, 'weight' => 4]), - 6 => MenuLinkMock::create(['id' => 'test.example6', 'route_name' => '', 'url' => 'https://www.drupal.org/', 'title' => 'bar_bar', 'parent' => '', 'weight' => 5]), - 7 => MenuLinkMock::create(['id' => 'test.example7', 'route_name' => 'example7', 'title' => 'title7', 'parent' => 'test.example5', 'weight' => 6]), - 8 => MenuLinkMock::create(['id' => 'test.example8', 'route_name' => 'example8', 'title' => 'title8', 'parent' => '', 'weight' => 7]), + 1 => MenuLinkMock::create([ + 'id' => 'test.example1', + 'route_name' => 'example1', + 'title' => 'foo', + 'parent' => '', + 'weight' => 0, + ]), + 2 => MenuLinkMock::create([ + 'id' => 'test.example2', + 'route_name' => 'example2', + 'title' => 'bar', + 'parent' => '', + 'route_parameters' => ['foo' => 'bar'], + 'weight' => 1, + ]), + 3 => MenuLinkMock::create([ + 'id' => 'test.example3', + 'route_name' => 'example3', + 'title' => 'baz', + 'parent' => 'test.example2', + 'weight' => 2, + ]), + 4 => MenuLinkMock::create([ + 'id' => 'test.example4', + 'route_name' => 'example4', + 'title' => 'qux', + 'parent' => 'test.example3', + 'weight' => 3, + ]), + 5 => MenuLinkMock::create([ + 'id' => 'test.example5', + 'route_name' => 'example5', + 'title' => 'title5', + 'parent' => '', + 'expanded' => TRUE, + 'weight' => 4, + ]), + 6 => MenuLinkMock::create([ + 'id' => 'test.example6', + 'route_name' => '', + 'url' => 'https://www.drupal.org/', + 'title' => 'bar_bar', + 'parent' => '', + 'weight' => 5, + ]), + 7 => MenuLinkMock::create([ + 'id' => 'test.example7', + 'route_name' => 'example7', + 'title' => 'title7', + 'parent' => 'test.example5', + 'weight' => 6, + ]), + 8 => MenuLinkMock::create([ + 'id' => 'test.example8', + 'route_name' => 'example8', + 'title' => 'title8', + 'parent' => '', + 'weight' => 7, + ]), ]; foreach ($links as $instance) { $this->menuLinkManager->addDefinition($instance->getPluginId(), $instance->getPluginDefinition()); diff --git a/core/modules/system/tests/src/Kernel/Common/UrlTest.php b/core/modules/system/tests/src/Kernel/Common/UrlTest.php index 6c50fe94325d..dfaeefa880f2 100644 --- a/core/modules/system/tests/src/Kernel/Common/UrlTest.php +++ b/core/modules/system/tests/src/Kernel/Common/UrlTest.php @@ -53,17 +53,72 @@ public function testLinkBubbleableMetadata(): void { \Drupal::service('module_installer')->install(['user']); $cases = [ - ['Regular link', 'internal:/user', [], ['contexts' => [], 'tags' => [], 'max-age' => Cache::PERMANENT], []], - ['Regular link, absolute', 'internal:/user', ['absolute' => TRUE], ['contexts' => ['url.site'], 'tags' => [], 'max-age' => Cache::PERMANENT], []], - ['Route processor link', 'route:system.run_cron', [], ['contexts' => ['session'], 'tags' => [], 'max-age' => Cache::PERMANENT], ['placeholders' => []]], - ['Route processor link, absolute', 'route:system.run_cron', ['absolute' => TRUE], ['contexts' => ['url.site', 'session'], 'tags' => [], 'max-age' => Cache::PERMANENT], ['placeholders' => []]], - ['Path processor link', 'internal:/user/1', [], ['contexts' => [], 'tags' => ['user:1'], 'max-age' => Cache::PERMANENT], []], - ['Path processor link, absolute', 'internal:/user/1', ['absolute' => TRUE], ['contexts' => ['url.site'], 'tags' => ['user:1'], 'max-age' => Cache::PERMANENT], []], + [ + 'Regular link', + 'internal:/user', + [], + ['contexts' => [], 'tags' => [], 'max-age' => Cache::PERMANENT], + [], + ], + [ + 'Regular link, absolute', + 'internal:/user', + ['absolute' => TRUE], + [ + 'contexts' => ['url.site'], + 'tags' => [], + 'max-age' => Cache::PERMANENT, + ], + [], + ], + [ + 'Route processor link', + 'route:system.run_cron', + [], + [ + 'contexts' => ['session'], + 'tags' => [], + 'max-age' => Cache::PERMANENT, + ], + ['placeholders' => []], + ], + [ + 'Route processor link, absolute', + 'route:system.run_cron', + ['absolute' => TRUE], + [ + 'contexts' => ['url.site', 'session'], + 'tags' => [], + 'max-age' => Cache::PERMANENT, + ], + ['placeholders' => []], + ], + [ + 'Path processor link', + 'internal:/user/1', + [], + ['contexts' => [], 'tags' => ['user:1'], 'max-age' => Cache::PERMANENT], + [], + ], + [ + 'Path processor link, absolute', + 'internal:/user/1', + ['absolute' => TRUE], + [ + 'contexts' => ['url.site'], + 'tags' => ['user:1'], + 'max-age' => Cache::PERMANENT, + ], + [], + ], ]; foreach ($cases as $case) { [$title, $uri, $options, $expected_cacheability, $expected_attachments] = $case; - $expected_cacheability['contexts'] = Cache::mergeContexts($expected_cacheability['contexts'], ['languages:language_interface', 'theme', 'user.permissions']); + $expected_cacheability['contexts'] = Cache::mergeContexts( + $expected_cacheability['contexts'], + ['languages:language_interface', 'theme', 'user.permissions'] + ); $link = [ '#type' => 'link', '#title' => $title, diff --git a/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php index d46e2ed4f4d9..2318a97ae211 100644 --- a/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php +++ b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php @@ -71,7 +71,13 @@ public function testClear(): void { // Replace with the clear parameter, only the valid token should remain. $target = Html::escape($this->config('system.site')->get('name')); - $result = $this->tokenService->replace($source, [], ['langcode' => $this->interfaceLanguage->getId(), 'clear' => TRUE]); + $result = $this->tokenService->replace( + $source, + [], + [ + 'langcode' => $this->interfaceLanguage->getId(), + 'clear' => TRUE, + ]); $this->assertEquals($target, $result, 'Valid tokens replaced while invalid tokens ignored.'); $target .= '[user:name]'; diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php index bf0df9b31221..4cbb4c024afb 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php @@ -47,7 +47,10 @@ public function testVocabularyEntityDisplay(): void { $this->assertSame('entity_reference_label', $component['type']); $this->assertSame(20, $component['weight']); // Test the Id map. - $this->assertSame([['node', 'article', 'default', 'field_tags']], $this->getMigration('d6_vocabulary_entity_display')->getIdMap()->lookupDestinationIds([4, 'article'])); + $this->assertSame( + [['node', 'article', 'default', 'field_tags']], + $this->getMigration('d6_vocabulary_entity_display')->getIdMap()->lookupDestinationIds([4, 'article']) + ); // Tests that a vocabulary named like a D8 base field will be migrated and // prefixed with 'field_' to avoid conflicts. diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php index 10a0d991fc34..3075a365b4f4 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityFormDisplayTest.php @@ -47,7 +47,18 @@ public function testVocabularyEntityFormDisplay(): void { $this->assertSame('options_select', $component['type']); $this->assertSame(20, $component['weight']); // Test the Id map. - $this->assertSame([['node', 'article', 'default', 'field_tags']], $this->getMigration('d6_vocabulary_entity_form_display')->getIdMap()->lookupDestinationIds([4, 'article'])); + $this->assertSame([ + [ + 'node', + 'article', + 'default', + 'field_tags', + ], + ], + $this->getMigration('d6_vocabulary_entity_form_display') + ->getIdMap() + ->lookupDestinationIds([4, 'article']) + ); // Test the term widget tags setting. $entity_form_display = EntityFormDisplay::load('node.story.default'); diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldInstanceTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldInstanceTest.php index ff5e7136611e..0fb3ebaee5fa 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldInstanceTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldInstanceTest.php @@ -63,7 +63,10 @@ public function testVocabularyFieldInstance(): void { $this->assertTargetBundles($field_id, ['tags' => 'tags']); $this->assertTrue($settings['handler_settings']['auto_create'], 'The "auto_create" setting is correct.'); - $this->assertSame([['node', 'article', 'field_tags']], $this->getMigration('d6_vocabulary_field_instance')->getIdMap()->lookupDestinationIds([4, 'article'])); + $this->assertSame( + [['node', 'article', 'field_tags']], + $this->getMigration('d6_vocabulary_field_instance')->getIdMap()->lookupDestinationIds([4, 'article']) + ); // Test the field vocabulary_1_i_0_ with multilingual option, // 'per language terms'. diff --git a/core/modules/taxonomy/tests/src/Kernel/TermValidationTest.php b/core/modules/taxonomy/tests/src/Kernel/TermValidationTest.php index 169100aac3ac..d585b7d41153 100644 --- a/core/modules/taxonomy/tests/src/Kernel/TermValidationTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/TermValidationTest.php @@ -59,7 +59,13 @@ public function testValidation(): void { $term->set('parent', 9999); $violations = $term->validate(); $this->assertCount(1, $violations, 'Violation found when term parent is invalid.'); - $this->assertEquals(new FormattableMarkup('The referenced entity (%type: %id) does not exist.', ['%type' => 'taxonomy_term', '%id' => 9999]), $violations[0]->getMessage()); + $this->assertEquals(new FormattableMarkup( + 'The referenced entity (%type: %id) does not exist.', + [ + '%type' => 'taxonomy_term', + '%id' => 9999, + ]), + $violations[0]->getMessage()); $term->set('parent', 0); $violations = $term->validate(); diff --git a/core/modules/user/tests/src/Kernel/Condition/UserRoleConditionTest.php b/core/modules/user/tests/src/Kernel/Condition/UserRoleConditionTest.php index c15ee63a9542..2a3c4c487bb2 100644 --- a/core/modules/user/tests/src/Kernel/Condition/UserRoleConditionTest.php +++ b/core/modules/user/tests/src/Kernel/Condition/UserRoleConditionTest.php @@ -120,7 +120,13 @@ public function testConditions(): void { $this->assertEquals('The user is a member of Anonymous user', $condition->summary()); // Set the user role to check anonymous or authenticated. - $condition->setConfig('roles', [RoleInterface::ANONYMOUS_ID => RoleInterface::ANONYMOUS_ID, RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID]); + $condition->setConfig( + 'roles', + [ + RoleInterface::ANONYMOUS_ID => RoleInterface::ANONYMOUS_ID, + RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID, + ] + ); $this->assertTrue($condition->execute(), 'Anonymous users pass role checks for anonymous or authenticated.'); // Check for the proper summary. $this->assertEquals('The user is a member of Anonymous user, Authenticated user', $condition->summary()); @@ -139,7 +145,10 @@ public function testConditions(): void { $this->assertEquals('The user is not a member of Authenticated user', $condition->summary()); // Check the complex negated summary. - $condition->setConfig('roles', [RoleInterface::ANONYMOUS_ID => RoleInterface::ANONYMOUS_ID, RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID]); + $condition->setConfig('roles', [ + RoleInterface::ANONYMOUS_ID => RoleInterface::ANONYMOUS_ID, + RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID, + ]); $this->assertEquals('The user is not a member of Anonymous user, Authenticated user', $condition->summary()); // Check a custom role. diff --git a/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserProfileFieldTest.php b/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserProfileFieldTest.php index d9f344a9df8b..26d714a401cb 100644 --- a/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserProfileFieldTest.php +++ b/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserProfileFieldTest.php @@ -43,7 +43,17 @@ public function testUserProfileFields(): void { $field_storage = FieldStorageConfig::load('user.profile_sold_to'); $this->assertSame('list_string', $field_storage->getType(), 'Field type is list_string.'); $settings = $field_storage->getSettings(); - $this->assertEquals(['Pill spammers' => 'Pill spammers', 'Fitness spammers' => 'Fitness spammers', 'Back\\slash' => 'Back\\slash', 'Forward/slash' => 'Forward/slash', 'Dot.in.the.middle' => 'Dot.in.the.middle', 'Faithful servant' => 'Faithful servant', 'Anonymous donor' => 'Anonymous donor'], $settings['allowed_values']); + $this->assertEquals([ + 'Pill spammers' => 'Pill spammers', + 'Fitness spammers' => 'Fitness spammers', + 'Back\\slash' => 'Back\\slash', + 'Forward/slash' => 'Forward/slash', + 'Dot.in.the.middle' => 'Dot.in.the.middle', + 'Faithful servant' => 'Faithful servant', + 'Anonymous donor' => 'Anonymous donor', + ], + $settings['allowed_values'] + ); $this->assertSame('list_string', $field_storage->getType(), 'Field type is list_string.'); // Migrated list field. diff --git a/core/modules/user/tests/src/Kernel/UserPassRehashTest.php b/core/modules/user/tests/src/Kernel/UserPassRehashTest.php index 716a56573b85..80ac5e566bd1 100644 --- a/core/modules/user/tests/src/Kernel/UserPassRehashTest.php +++ b/core/modules/user/tests/src/Kernel/UserPassRehashTest.php @@ -31,8 +31,26 @@ public function testUniqueHashNoPasswordValue(): void { $timestamp = \Drupal::time()->getRequestTime(); - $user_a = $this->createUser([], NULL, FALSE, ['uid' => 12, 'mail' => '3user@example.com', 'login' => $timestamp - 1000]); - $user_b = $this->createUser([], NULL, FALSE, ['uid' => 123, 'mail' => 'user@example.com', 'login' => $timestamp - 1000]); + $user_a = $this->createUser( + [], + NULL, + FALSE, + [ + 'uid' => 12, + 'mail' => '3user@example.com', + 'login' => $timestamp - 1000, + ] + ); + $user_b = $this->createUser( + [], + NULL, + FALSE, + [ + 'uid' => 123, + 'mail' => 'user@example.com', + 'login' => $timestamp - 1000, + ] + ); // Unset passwords after the users are created in order to avoid // (different) password hashes being generated for the empty strings. diff --git a/core/modules/user/tests/src/Kernel/Views/UserKernelTestBase.php b/core/modules/user/tests/src/Kernel/Views/UserKernelTestBase.php index 977b66cf077f..9c18c8dbedb7 100644 --- a/core/modules/user/tests/src/Kernel/Views/UserKernelTestBase.php +++ b/core/modules/user/tests/src/Kernel/Views/UserKernelTestBase.php @@ -69,7 +69,13 @@ protected function setupPermissionTestData() { // Setup a role with multiple permissions. $this->roleStorage->create(['id' => 'multiple_permissions', 'label' => 'Multiple permissions']) ->save(); - user_role_grant_permissions('multiple_permissions', ['administer permissions', 'administer users', 'access user profiles']); + user_role_grant_permissions( + 'multiple_permissions', + [ + 'administer permissions', + 'administer users', + 'access user profiles', + ]); // Setup a user without an extra role. $this->users[] = $account = $this->userStorage->create(['name' => $this->randomString()]); diff --git a/core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php b/core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php index 1e935be6a4b9..0afaf84823d0 100644 --- a/core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php +++ b/core/modules/views/tests/src/Kernel/Entity/ViewEntityDependenciesTest.php @@ -24,7 +24,12 @@ class ViewEntityDependenciesTest extends ViewsKernelTestBase { * * @var array */ - public static $testViews = ['test_field_get_entity', 'test_relationship_dependency', 'test_plugin_dependencies', 'test_argument_dependency']; + public static $testViews = [ + 'test_field_get_entity', + 'test_relationship_dependency', + 'test_plugin_dependencies', + 'test_argument_dependency', + ]; /** * {@inheritdoc} diff --git a/core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php b/core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php index 85134be56569..a3bcc66be585 100644 --- a/core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php +++ b/core/modules/views/tests/src/Kernel/EventSubscriber/ViewsEntitySchemaSubscriberIntegrationTest.php @@ -42,7 +42,12 @@ class ViewsEntitySchemaSubscriberIntegrationTest extends ViewsKernelTestBase { * * @var array */ - public static $testViews = ['test_view_entity_test', 'test_view_entity_test_revision', 'test_view_entity_test_data', 'test_view_entity_test_additional_base_field']; + public static $testViews = [ + 'test_view_entity_test', + 'test_view_entity_test_revision', + 'test_view_entity_test_data', + 'test_view_entity_test_additional_base_field', + ]; /** * The event dispatcher. diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php b/core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php index c162d68d677c..1147d2028eeb 100644 --- a/core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php +++ b/core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php @@ -69,11 +69,23 @@ protected function setUpFixtures(): void { */ public function testEntityLink(): void { // Anonymous users cannot see edit/delete links. - $expected_results = ['canonical' => TRUE, 'edit-form' => FALSE, 'delete-form' => FALSE, 'canonical_raw' => TRUE, 'canonical_raw_absolute' => TRUE]; + $expected_results = [ + 'canonical' => TRUE, + 'edit-form' => FALSE, + 'delete-form' => FALSE, + 'canonical_raw' => TRUE, + 'canonical_raw_absolute' => TRUE, + ]; $this->doTestEntityLink(\Drupal::currentUser(), $expected_results); // Admin users cannot see all links. - $expected_results = ['canonical' => TRUE, 'edit-form' => TRUE, 'delete-form' => TRUE, 'canonical_raw' => TRUE, 'canonical_raw_absolute' => TRUE]; + $expected_results = [ + 'canonical' => TRUE, + 'edit-form' => TRUE, + 'delete-form' => TRUE, + 'canonical_raw' => TRUE, + 'canonical_raw_absolute' => TRUE, + ]; $this->doTestEntityLink($this->adminUser, $expected_results); } diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php b/core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php index bc694363c181..3ac82471a292 100644 --- a/core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php +++ b/core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php @@ -42,7 +42,14 @@ class FieldFieldTest extends ViewsKernelTestBase { /** * {@inheritdoc} */ - public static $testViews = ['test_field_field_test', 'test_field_alias_test', 'test_field_field_complex_test', 'test_field_field_attachment_test', 'test_field_field_revision_test', 'test_field_field_revision_complex_test']; + public static $testViews = [ + 'test_field_field_test', + 'test_field_alias_test', + 'test_field_field_complex_test', + 'test_field_field_attachment_test', + 'test_field_field_revision_test', + 'test_field_field_revision_complex_test', + ]; /** * The stored test entities. @@ -391,13 +398,43 @@ public function testComplexExecute(): void { $this->assertIdenticalResultset($executable, [ - ['timezone' => $timezones[0], 'field_test_multiple' => [1, 3], 'field_test_multiple_1' => [1, 3], 'field_test_multiple_2' => [1, 3]], - ['timezone' => $timezones[1], 'field_test_multiple' => [7, 0], 'field_test_multiple_1' => [7, 0], 'field_test_multiple_2' => [7, 0]], - ['timezone' => $timezones[2], 'field_test_multiple' => [3, 5], 'field_test_multiple_1' => [3, 5], 'field_test_multiple_2' => [3, 5]], - ['timezone' => $timezones[3], 'field_test_multiple' => [9, 9], 'field_test_multiple_1' => [9, 9], 'field_test_multiple_2' => [9, 9]], - ['timezone' => $timezones[4], 'field_test_multiple' => [9, 0], 'field_test_multiple_1' => [9, 0], 'field_test_multiple_2' => [9, 0]], + [ + 'timezone' => $timezones[0], + 'field_test_multiple' => [1, 3], + 'field_test_multiple_1' => [1, 3], + 'field_test_multiple_2' => [1, 3], + ], + [ + 'timezone' => $timezones[1], + 'field_test_multiple' => [7, 0], + 'field_test_multiple_1' => [7, 0], + 'field_test_multiple_2' => [7, 0], + ], + [ + 'timezone' => $timezones[2], + 'field_test_multiple' => [3, 5], + 'field_test_multiple_1' => [3, 5], + 'field_test_multiple_2' => [3, 5], + ], + [ + 'timezone' => $timezones[3], + 'field_test_multiple' => [9, 9], + 'field_test_multiple_1' => [9, 9], + 'field_test_multiple_2' => [9, 9], + ], + [ + 'timezone' => $timezones[4], + 'field_test_multiple' => [9, 0], + 'field_test_multiple_1' => [9, 0], + 'field_test_multiple_2' => [9, 0], + ], ], - ['timezone' => 'timezone', 'field_test_multiple' => 'field_test_multiple', 'field_test_multiple_1' => 'field_test_multiple_1', 'field_test_multiple_2' => 'field_test_multiple_2'] + [ + 'timezone' => 'timezone', + 'field_test_multiple' => 'field_test_multiple', + 'field_test_multiple_1' => 'field_test_multiple_1', + 'field_test_multiple_2' => 'field_test_multiple_2', + ] ); } @@ -467,7 +504,12 @@ public function testRevisionExecute(): void { ['id' => 1, 'field_test' => 3, 'revision_id' => 3, 'name' => 'revision value2'], ['id' => 2, 'field_test' => 4, 'revision_id' => 4, 'name' => 'next entity value'], ], - ['entity_test_rev_revision_id' => 'id', 'revision_id' => 'revision_id', 'name' => 'name', 'field_test' => 'field_test'] + [ + 'entity_test_rev_revision_id' => 'id', + 'revision_id' => 'revision_id', + 'name' => 'name', + 'field_test' => 'field_test', + ] ); } @@ -533,12 +575,56 @@ public function testRevisionComplexExecute(): void { $this->assertIdenticalResultset($executable, [ - ['id' => 1, 'field_test' => 1, 'revision_id' => 1, 'uid' => $this->testUsers[0]->id(), 'timezone' => $timezones[0], 'field_test_multiple' => [1, 3, 7], 'field_test_multiple_1' => [1, 3, 7], 'field_test_multiple_2' => [1, 3, 7]], - ['id' => 1, 'field_test' => 2, 'revision_id' => 2, 'uid' => $this->testUsers[1]->id(), 'timezone' => $timezones[1], 'field_test_multiple' => [0, 3, 5], 'field_test_multiple_1' => [0, 3, 5], 'field_test_multiple_2' => [0, 3, 5]], - ['id' => 1, 'field_test' => 3, 'revision_id' => 3, 'uid' => $this->testUsers[2]->id(), 'timezone' => $timezones[2], 'field_test_multiple' => [9, 9, 9], 'field_test_multiple_1' => [9, 9, 9], 'field_test_multiple_2' => [9, 9, 9]], - ['id' => 2, 'field_test' => 4, 'revision_id' => 4, 'uid' => $this->testUsers[3]->id(), 'timezone' => $timezones[3], 'field_test_multiple' => [2, 9, 9], 'field_test_multiple_1' => [2, 9, 9], 'field_test_multiple_2' => [2, 9, 9]], + [ + 'id' => 1, + 'field_test' => 1, + 'revision_id' => 1, + 'uid' => $this->testUsers[0]->id(), + 'timezone' => $timezones[0], + 'field_test_multiple' => [1, 3, 7], + 'field_test_multiple_1' => [1, 3, 7], + 'field_test_multiple_2' => [1, 3, 7], + ], + [ + 'id' => 1, + 'field_test' => 2, + 'revision_id' => 2, + 'uid' => $this->testUsers[1]->id(), + 'timezone' => $timezones[1], + 'field_test_multiple' => [0, 3, 5], + 'field_test_multiple_1' => [0, 3, 5], + 'field_test_multiple_2' => [0, 3, 5], + ], + [ + 'id' => 1, + 'field_test' => 3, + 'revision_id' => 3, + 'uid' => $this->testUsers[2]->id(), + 'timezone' => $timezones[2], + 'field_test_multiple' => [9, 9, 9], + 'field_test_multiple_1' => [9, 9, 9], + 'field_test_multiple_2' => [9, 9, 9], + ], + [ + 'id' => 2, + 'field_test' => 4, + 'revision_id' => 4, + 'uid' => $this->testUsers[3]->id(), + 'timezone' => $timezones[3], + 'field_test_multiple' => [2, 9, 9], + 'field_test_multiple_1' => [2, 9, 9], + 'field_test_multiple_2' => [2, 9, 9], + ], ], - ['entity_test_rev_revision_id' => 'id', 'revision_id' => 'revision_id', 'users_field_data_entity_test_rev_revision_uid' => 'uid', 'timezone' => 'timezone', 'field_test_multiple' => 'field_test_multiple', 'field_test_multiple_1' => 'field_test_multiple_1', 'field_test_multiple_2' => 'field_test_multiple_2'] + [ + 'entity_test_rev_revision_id' => 'id', + 'revision_id' => 'revision_id', + 'users_field_data_entity_test_rev_revision_uid' => 'uid', + 'timezone' => 'timezone', + 'field_test_multiple' => 'field_test_multiple', + 'field_test_multiple_1' => 'field_test_multiple_1', + 'field_test_multiple_2' => 'field_test_multiple_2', + ] ); } diff --git a/core/modules/views/tests/src/Kernel/Plugin/CacheTest.php b/core/modules/views/tests/src/Kernel/Plugin/CacheTest.php index 146c39206ee2..0ed804638b71 100644 --- a/core/modules/views/tests/src/Kernel/Plugin/CacheTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/CacheTest.php @@ -295,7 +295,17 @@ public function testHeaderStorage(): void { $this->assertEquals(['foo' => 'bar'], $output['#attached']['drupalSettings'], 'Make sure drupalSettings are added for cached views.'); // Note: views_test_data_views_pre_render() adds some cache tags. $this->assertEquals(['config:views.view.test_cache_header_storage', 'views_test_data:1'], $output['#cache']['tags']); - $this->assertEquals(['non-existing-placeholder-just-for-testing-purposes' => ['#lazy_builder' => ['Drupal\views_test_data\Controller\ViewsTestDataController::placeholderLazyBuilder', ['bar']]]], $output['#attached']['placeholders']); + $this->assertEquals( + [ + 'non-existing-placeholder-just-for-testing-purposes' => [ + '#lazy_builder' => [ + 'Drupal\views_test_data\Controller\ViewsTestDataController::placeholderLazyBuilder', + ['bar'], + ], + ], + ], + $output['#attached']['placeholders'] + ); $this->assertArrayNotHasKey('pre_render_called', $view->build_info, 'Make sure hook_views_pre_render is not called for the cached view.'); } diff --git a/core/modules/views/tests/src/Kernel/Plugin/CastedIntFieldJoinTestBase.php b/core/modules/views/tests/src/Kernel/Plugin/CastedIntFieldJoinTestBase.php index fc356f757b11..34855d5f9dd4 100644 --- a/core/modules/views/tests/src/Kernel/Plugin/CastedIntFieldJoinTestBase.php +++ b/core/modules/views/tests/src/Kernel/Plugin/CastedIntFieldJoinTestBase.php @@ -169,7 +169,10 @@ public function testBuildJoin(): void { $this->assertStringContainsString("views_test_data.uid = CAST(users4.uid AS $this->castingType)", $join_info['condition']); $this->assertStringContainsString('users4.name = :views_join_condition_0', $join_info['condition']); $this->assertStringContainsString('users4.name IN ( :views_join_condition_1[] )', $join_info['condition']); - $this->assertSame($join_info['arguments'][':views_join_condition_1[]'], [$random_name_2, $random_name_3, $random_name_4]); + $this->assertSame( + $join_info['arguments'][':views_join_condition_1[]'], + [$random_name_2, $random_name_3, $random_name_4] + ); } /** diff --git a/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php b/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php index 51ed12158408..c20575afa272 100644 --- a/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php @@ -26,7 +26,12 @@ class DisplayPageTest extends ViewsKernelTestBase { * * @var array */ - public static $testViews = ['test_page_display', 'test_page_display_route', 'test_page_display_menu', 'test_display_more']; + public static $testViews = [ + 'test_page_display', + 'test_page_display_route', + 'test_page_display_menu', + 'test_display_more', + ]; /** * {@inheritdoc} diff --git a/core/modules/views/tests/src/Kernel/Plugin/FieldOrLanguageJoinTest.php b/core/modules/views/tests/src/Kernel/Plugin/FieldOrLanguageJoinTest.php index 8c7d8c44fc74..d81a27385832 100644 --- a/core/modules/views/tests/src/Kernel/Plugin/FieldOrLanguageJoinTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/FieldOrLanguageJoinTest.php @@ -124,7 +124,10 @@ public function testBase(): void { $this->assertStringContainsString('views_test_data.uid = users4.uid', $join_info['condition']); $this->assertStringContainsString('users4.name = :views_join_condition_0', $join_info['condition']); $this->assertStringContainsString('users4.name IN ( :views_join_condition_1[] )', $join_info['condition']); - $this->assertSame($join_info['arguments'][':views_join_condition_1[]'], [$random_name_2, $random_name_3, $random_name_4]); + $this->assertSame( + $join_info['arguments'][':views_join_condition_1[]'], + [$random_name_2, $random_name_3, $random_name_4] + ); } /** diff --git a/core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php b/core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php index 2161bc5c5fbe..8db00b34447d 100644 --- a/core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php @@ -72,7 +72,12 @@ protected function setUpFixtures(): void { ])->save(); $this->editorUser = $this->createUser(['bypass node access']); - $this->powerUser = $this->createUser(['access content', 'create test content', 'edit own test content', 'delete own test content']); + $this->powerUser = $this->createUser([ + 'access content', + 'create test content', + 'edit own test content', + 'delete own test content', + ]); $this->regularUser = $this->createUser(['access content']); // Create some test entities. diff --git a/core/modules/views/tests/src/Kernel/Plugin/SqlQueryTest.php b/core/modules/views/tests/src/Kernel/Plugin/SqlQueryTest.php index f5d39734aa64..271447fc8b1a 100644 --- a/core/modules/views/tests/src/Kernel/Plugin/SqlQueryTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/SqlQueryTest.php @@ -29,7 +29,10 @@ class SqlQueryTest extends ViewsKernelTestBase { protected function viewsData() { $data = parent::viewsData(); $data['views_test_data']['table']['base']['access query tag'] = 'test_tag'; - $data['views_test_data']['table']['base']['query metadata'] = ['key1' => 'test_metadata', 'key2' => 'test_metadata2']; + $data['views_test_data']['table']['base']['query metadata'] = [ + 'key1' => 'test_metadata', + 'key2' => 'test_metadata2', + ]; return $data; } diff --git a/core/modules/views/tests/src/Kernel/Plugin/StyleGridTest.php b/core/modules/views/tests/src/Kernel/Plugin/StyleGridTest.php index ad960d2357a4..d5fa59160a2d 100644 --- a/core/modules/views/tests/src/Kernel/Plugin/StyleGridTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/StyleGridTest.php @@ -67,7 +67,13 @@ protected function assertGrid(ViewExecutable $view, string $alignment, int $colu $output = \Drupal::service('renderer')->renderRoot($output); $this->setRawContent($output); if (!in_array($alignment, $this->alignmentsTested)) { - $result = $this->xpath('//div[contains(@class, "views-view-grid") and contains(@class, :alignment) and contains(@class, :columns)]', [':alignment' => $alignment, ':columns' => 'cols-' . $columns]); + $result = $this->xpath( + '//div[contains(@class, "views-view-grid") and contains(@class, :alignment) and contains(@class, :columns)]', + [ + ':alignment' => $alignment, + ':columns' => 'cols-' . $columns, + ] + ); $this->assertGreaterThan(0, count($result), ucfirst($alignment) . " grid markup detected."); $this->alignmentsTested[] = $alignment; } @@ -89,7 +95,12 @@ protected function assertGrid(ViewExecutable $view, string $alignment, int $colu break; } // Ensure last column exists. - $result = $this->xpath('//div[contains(@class, "views-col") and contains(@class, :columns) and starts-with(@style, :width)]', [':columns' => 'col-' . $columns, ':width' => 'width: ' . $width]); + $result = $this->xpath( + '//div[contains(@class, "views-col") and contains(@class, :columns) and starts-with(@style, :width)]', + [ + ':columns' => 'col-' . $columns, + ':width' => 'width: ' . $width, + ]); $this->assertGreaterThan(0, count($result), ucfirst($alignment) . " $columns column grid: last column exists and automatic width calculated correctly."); // Ensure no extra columns were generated. $result = $this->xpath('//div[contains(@class, "views-col") and contains(@class, :columns)]', [':columns' => 'col-' . ($columns + 1)]); diff --git a/core/modules/views/tests/src/Kernel/RenderCacheIntegrationTest.php b/core/modules/views/tests/src/Kernel/RenderCacheIntegrationTest.php index 8f3bfdbfbeef..4be248c552fb 100644 --- a/core/modules/views/tests/src/Kernel/RenderCacheIntegrationTest.php +++ b/core/modules/views/tests/src/Kernel/RenderCacheIntegrationTest.php @@ -292,7 +292,16 @@ public function testViewAddCacheMetadata(): void { $view = View::load('test_display'); $view->save(); - $this->assertEqualsCanonicalizing(['languages:' . LanguageInterface::TYPE_CONTENT, 'languages:' . LanguageInterface::TYPE_INTERFACE, 'url.query_args', 'user.node_grants:view', 'user.permissions'], $view->getDisplay('default')['cache_metadata']['contexts']); + $this->assertEqualsCanonicalizing( + [ + 'languages:' . LanguageInterface::TYPE_CONTENT, + 'languages:' . LanguageInterface::TYPE_INTERFACE, + 'url.query_args', + 'user.node_grants:view', + 'user.permissions', + ], + $view->getDisplay('default')['cache_metadata']['contexts'] + ); } } diff --git a/core/modules/views/tests/src/Kernel/ViewsHooksTest.php b/core/modules/views/tests/src/Kernel/ViewsHooksTest.php index 37d0d4aed777..0e04438983da 100644 --- a/core/modules/views/tests/src/Kernel/ViewsHooksTest.php +++ b/core/modules/views/tests/src/Kernel/ViewsHooksTest.php @@ -82,7 +82,15 @@ public function testHooks(): void { $this->assertTrue($this->moduleHandler->hasImplementations($hook, 'views_test_data'), "The hook $hook was registered."); if ($hook == 'views_post_render') { - $this->moduleHandler->invoke('views_test_data', $hook, [$view, &$view->display_handler->output, $view->display_handler->getPlugin('cache')]); + $this->moduleHandler->invoke( + 'views_test_data', + $hook, + [ + $view, + &$view->display_handler->output, + $view->display_handler->getPlugin('cache'), + ] + ); continue; } diff --git a/core/modules/workspaces/tests/src/Kernel/WorkspaceEntityDeleteTest.php b/core/modules/workspaces/tests/src/Kernel/WorkspaceEntityDeleteTest.php index 06bfec3db256..9fc1707fd0b8 100644 --- a/core/modules/workspaces/tests/src/Kernel/WorkspaceEntityDeleteTest.php +++ b/core/modules/workspaces/tests/src/Kernel/WorkspaceEntityDeleteTest.php @@ -89,7 +89,11 @@ public function testEntityDeletion(): void { $this->switchToWorkspace('stage'); $published_stage = $this->createNode(['title' => 'Test 3 published - stage', 'type' => 'page']); - $unpublished_stage = $this->createNode(['title' => 'Test 4 unpublished - stage', 'type' => 'page', 'status' => FALSE]); + $unpublished_stage = $this->createNode([ + 'title' => 'Test 4 unpublished - stage', + 'type' => 'page', + 'status' => FALSE, + ]); $this->assertEquals(['node' => [4 => 3, 5 => 4]], $workspace_association->getTrackedEntities('stage', 'node')); $this->assertTrue($published_stage->access('delete')); $this->assertTrue($unpublished_stage->access('delete')); diff --git a/core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php b/core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php index 28e6855d17f4..8a72bd35dfcf 100644 --- a/core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php +++ b/core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php @@ -105,8 +105,18 @@ protected function setUp(): void { // Create two nodes, a published and an unpublished one, so we can test the // behavior of the module with default/existing content. $this->createdTimestamp = \Drupal::time()->getRequestTime(); - $this->nodes[] = $this->createNode(['title' => 'live - 1 - r1 - published', 'body' => 'node 1', 'created' => $this->createdTimestamp++, 'status' => TRUE]); - $this->nodes[] = $this->createNode(['title' => 'live - 2 - r2 - unpublished', 'body' => 'node 2', 'created' => $this->createdTimestamp++, 'status' => FALSE]); + $this->nodes[] = $this->createNode([ + 'title' => 'live - 1 - r1 - published', + 'body' => 'node 1', + 'created' => $this->createdTimestamp++, + 'status' => TRUE, + ]); + $this->nodes[] = $this->createNode([ + 'title' => 'live - 2 - r2 - unpublished', + 'body' => 'node 2', + 'created' => $this->createdTimestamp++, + 'status' => FALSE, + ]); $translation = $this->nodes[0]->addTranslation('de'); $translation->setTitle('live - 1 - r1 - published - de'); @@ -331,13 +341,21 @@ public function testWorkspaces(): void { // Add a new unpublished node on 'stage'. $this->switchToWorkspace('stage'); - $this->createNode(['title' => 'stage - 3 - r5 - unpublished', 'created' => $this->createdTimestamp++, 'status' => FALSE]); + $this->createNode([ + 'title' => 'stage - 3 - r5 - unpublished', + 'created' => $this->createdTimestamp++, + 'status' => FALSE, + ]); $this->assertWorkspaceStatus($test_scenarios['add_unpublished_node_in_stage'], 'node'); $this->assertWorkspaceAssociation($expected_workspace_association['add_unpublished_node_in_stage'], 'node'); // Add a new published node on 'stage'. $this->switchToWorkspace('stage'); - $this->createNode(['title' => 'stage - 4 - r6 - published', 'created' => $this->createdTimestamp++, 'status' => TRUE]); + $this->createNode([ + 'title' => 'stage - 4 - r6 - published', + 'created' => $this->createdTimestamp++, + 'status' => TRUE, + ]); $this->assertWorkspaceStatus($test_scenarios['add_published_node_in_stage'], 'node'); $this->assertWorkspaceAssociation($expected_workspace_association['add_published_node_in_stage'], 'node'); @@ -389,7 +407,11 @@ public function testWorkspaceAssociationDataIntegrity(): void { // Add a new unpublished node in 'stage' and check that new revision is // tracked in the workspace association data. $this->switchToWorkspace('stage'); - $unpublished_node = $this->createNode(['title' => 'stage - 3 - r3 - unpublished', 'created' => $this->createdTimestamp++, 'status' => FALSE]); + $unpublished_node = $this->createNode([ + 'title' => 'stage - 3 - r3 - unpublished', + 'created' => $this->createdTimestamp++, + 'status' => FALSE, + ]); $expected_workspace_association = ['stage' => [3]]; $this->assertWorkspaceAssociation($expected_workspace_association, 'node'); @@ -409,7 +431,11 @@ public function testWorkspaceAssociationDataIntegrity(): void { // revision is tracked in the workspace association data. Note that revision // '5' has been created as an unpublished default revision in Live, so it is // not tracked. - $node = $this->createNode(['title' => 'stage - 4 - r6 - published', 'created' => $this->createdTimestamp++, 'status' => TRUE]); + $node = $this->createNode([ + 'title' => 'stage - 4 - r6 - published', + 'created' => $this->createdTimestamp++, + 'status' => TRUE, + ]); $expected_workspace_association = ['stage' => [6]]; $this->assertWorkspaceAssociation($expected_workspace_association, 'node'); @@ -461,7 +487,11 @@ public function testWorkspaceHierarchy(): void { // Create a new published node in 'stage' (which creates two revisions), and // check that it's tracked in all its descendants. $this->switchToWorkspace('stage'); - $this->createNode(['title' => 'stage - 3 - r5 - published', 'created' => $this->createdTimestamp++, 'status' => TRUE]); + $this->createNode([ + 'title' => 'stage - 3 - r5 - published', + 'created' => $this->createdTimestamp++, + 'status' => TRUE, + ]); $expected_workspace_association = [ 'stage' => [3, 5], 'dev' => [3, 5], diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist index 44940ee0ea74..fc56d4b607f9 100644 --- a/core/phpcs.xml.dist +++ b/core/phpcs.xml.dist @@ -33,6 +33,7 @@ <rule ref="Drupal.Arrays.Array.LongLineDeclaration"> <include-pattern>core/*/Unit/*</include-pattern> <include-pattern>core/*/FunctionalJavascript/*</include-pattern> + <include-pattern>core/*/Kernel/*</include-pattern> <include-pattern>core/lib/*</include-pattern> <include-pattern>core/modules/*/tests/modules/*</include-pattern> </rule> -- GitLab