diff --git a/core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php b/core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php index 23b06f8248bc7b95962a4ad21d0a5a3597435873..f6a50be88cc85058d80d70b178d00f82d2eeed88 100644 --- a/core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php +++ b/core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php @@ -162,8 +162,7 @@ public function testAccess(string $operation, bool $published, bool $reusable, a } $this->role->save(); } - $user->addRole($this->role->id()); - $user->save(); + $user->addRole($this->role->id())->save(); if ($parent_access !== NULL) { $parent_entity = $this->prophesize(AccessibleInterface::class); diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaPreviewTest.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaPreviewTest.php index 59cbf7f30748da6ae2f7c50eddefc06a89c660ca..6eb257958123bd425e9cfcdae9130a3fdf02d5cb 100644 --- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaPreviewTest.php +++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaPreviewTest.php @@ -94,8 +94,9 @@ public function testPreviewUsesDefaultThemeAndIsClientCacheable() { ->save(); // Allow the test user to view the admin theme. - $this->adminUser->addRole($this->drupalCreateRole(['view the administration theme'])); - $this->adminUser->save(); + $this->adminUser + ->addRole($this->drupalCreateRole(['view the administration theme'])) + ->save(); // Configure a different default and admin theme, like on most Drupal sites. $this->config('system.theme') diff --git a/core/modules/comment/tests/src/Kernel/Views/CommentViewsKernelTestBase.php b/core/modules/comment/tests/src/Kernel/Views/CommentViewsKernelTestBase.php index 3229f10f1f53868f66e80e47c1156f5ec0a2d664..4740346b8723eb0c273f578b9aba93ef793031ff 100644 --- a/core/modules/comment/tests/src/Kernel/Views/CommentViewsKernelTestBase.php +++ b/core/modules/comment/tests/src/Kernel/Views/CommentViewsKernelTestBase.php @@ -84,8 +84,7 @@ protected function setUp($import_test_views = TRUE): void { $anonymous_role->save(); $this->adminUser = $this->userStorage->create(['name' => $this->randomMachineName()]); - $this->adminUser->addRole('admin'); - $this->adminUser->save(); + $this->adminUser->addRole('admin')->save(); } } diff --git a/core/modules/filter/tests/src/Kernel/TextFormatElementFormTest.php b/core/modules/filter/tests/src/Kernel/TextFormatElementFormTest.php index 451a1b323b1513b9aceda35d16b6d412bfc1c5e3..3f412606c3abd2e39d9dc8c39c326a0699a2c574 100644 --- a/core/modules/filter/tests/src/Kernel/TextFormatElementFormTest.php +++ b/core/modules/filter/tests/src/Kernel/TextFormatElementFormTest.php @@ -73,8 +73,7 @@ protected function setUp(): void { 'name' => 'foobar', 'mail' => 'foobar@example.com', ]); - $this->testUser->addRole($role->id()); - $this->testUser->save(); + $this->testUser->addRole($role->id())->save(); \Drupal::service('current_user')->setAccount($this->testUser); } diff --git a/core/modules/jsonapi/tests/src/Functional/JsonApiFilterRegressionTest.php b/core/modules/jsonapi/tests/src/Functional/JsonApiFilterRegressionTest.php index 9a0faaac582c9a65ce7b7366bbe7c5344190001a..b715e1198343929c50421e5b6a4ad1c69771399e 100644 --- a/core/modules/jsonapi/tests/src/Functional/JsonApiFilterRegressionTest.php +++ b/core/modules/jsonapi/tests/src/Functional/JsonApiFilterRegressionTest.php @@ -191,8 +191,8 @@ public function testFilteringEntitiesByEntityReferenceTargetId() { for ($i = 0; $i < 3; $i++) { // Create 3 users, one with the first role and two with the second role. $users[$i] = $this->drupalCreateUser(); - $users[$i]->addRole($i === 0 ? $role_llamalovers : $role_catcuddlers); - $users[$i]->save(); + $users[$i]->addRole($i === 0 ? $role_llamalovers : $role_catcuddlers) + ->save(); // For each user, create a node that is owned by that user. The node's // `uid` field will be used to test filtering by a content entity ID. Node::create([ diff --git a/core/modules/media/tests/src/Functional/MediaAccessTest.php b/core/modules/media/tests/src/Functional/MediaAccessTest.php index bd6469590cfcda92c30210af8ff69dd72d930e59..4410a70a6278eb1afbb9f6280a3aee369043e8c5 100644 --- a/core/modules/media/tests/src/Functional/MediaAccessTest.php +++ b/core/modules/media/tests/src/Functional/MediaAccessTest.php @@ -219,8 +219,7 @@ public function testMediaAccess() { // Create a new role, which implicitly checks if the permission exists. $mediaOverviewRole = $this->createRole(['access content overview', 'access media overview']); - $this->nonAdminUser->addRole($mediaOverviewRole); - $this->nonAdminUser->save(); + $this->nonAdminUser->addRole($mediaOverviewRole)->save(); $this->drupalGet('admin/content'); $assert_session->linkByHrefExists('/admin/content/media'); diff --git a/core/modules/migrate/tests/src/Kernel/MigrateEntityContentValidationTest.php b/core/modules/migrate/tests/src/Kernel/MigrateEntityContentValidationTest.php index 1cd98af609b7de8fa7743efb3d8887c16423471a..8759491ceebe76ef111d0a409cef50ee00adc937 100644 --- a/core/modules/migrate/tests/src/Kernel/MigrateEntityContentValidationTest.php +++ b/core/modules/migrate/tests/src/Kernel/MigrateEntityContentValidationTest.php @@ -181,8 +181,7 @@ public function testEntityOwnerValidation() { 'name' => 'foobar', 'mail' => 'foobar@example.com', ]); - $admin_user->addRole($role->id()); - $admin_user->save(); + $admin_user->addRole($role->id())->save(); $normal_user = User::create([ 'name' => 'normal user', 'mail' => 'normal@example.com', diff --git a/core/modules/navigation/tests/src/Functional/ShortcutsNavigationBlockTest.php b/core/modules/navigation/tests/src/Functional/ShortcutsNavigationBlockTest.php index 1ae8307d9e0642a410944774986bbe82cff6174c..6ec194ffa7861eade77c0ac48c8b9074f4e359c6 100644 --- a/core/modules/navigation/tests/src/Functional/ShortcutsNavigationBlockTest.php +++ b/core/modules/navigation/tests/src/Functional/ShortcutsNavigationBlockTest.php @@ -109,11 +109,9 @@ public function testNavigationBlock() { // user has a cache hit despite the user cache context, as // the returned cache contexts include those from lazy-builder content. $site_configuration_user1 = $this->drupalCreateUser(); - $site_configuration_user1->addRole($site_configuration_role); - $site_configuration_user1->save(); + $site_configuration_user1->addRole($site_configuration_role)->save(); $site_configuration_user2 = $this->drupalCreateUser(); - $site_configuration_user2->addRole($site_configuration_role); - $site_configuration_user2->save(); + $site_configuration_user2->addRole($site_configuration_role)->save(); $this->drupalLogin($site_configuration_user1); $this->verifyDynamicPageCache($test_page_url, 'MISS'); diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutCacheTagsTest.php b/core/modules/shortcut/tests/src/Functional/ShortcutCacheTagsTest.php index 9e28e03879d4390bfb797685b8876cee6739ea7a..b343215fd07f0017df362213f8374c3244c0d694 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutCacheTagsTest.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutCacheTagsTest.php @@ -174,11 +174,9 @@ public function testToolbar() { // user has a cache hit despite the user cache context, as // the returned cache contexts include those from lazy-builder content. $site_configuration_user1 = $this->drupalCreateUser(); - $site_configuration_user1->addRole($site_configuration_role); - $site_configuration_user1->save(); + $site_configuration_user1->addRole($site_configuration_role)->save(); $site_configuration_user2 = $this->drupalCreateUser(); - $site_configuration_user2->addRole($site_configuration_role); - $site_configuration_user2->save(); + $site_configuration_user2->addRole($site_configuration_role)->save(); $this->drupalLogin($site_configuration_user1); $this->verifyDynamicPageCache($test_page_url, 'MISS'); @@ -350,11 +348,9 @@ public function testBlock(): void { // user has a cache hit despite the user cache context, as // the returned cache contexts include those from lazy-builder content. $site_configuration_user1 = $this->drupalCreateUser(); - $site_configuration_user1->addRole($site_configuration_role); - $site_configuration_user1->save(); + $site_configuration_user1->addRole($site_configuration_role)->save(); $site_configuration_user2 = $this->drupalCreateUser(); - $site_configuration_user2->addRole($site_configuration_role); - $site_configuration_user2->save(); + $site_configuration_user2->addRole($site_configuration_role)->save(); $this->drupalLogin($site_configuration_user1); $this->verifyDynamicPageCache($test_page_url, 'MISS'); diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php index b6afa13b53f303ae1e1cbfd2e35b8762482be0cd..dc9f9909296f41b6fea1caadcfd419c0ca7fb3e4 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php @@ -235,7 +235,9 @@ public function testShortcutQuickLink() { $this->assertSession()->pageTextContains("The shortcut $title has been deleted."); $this->assertShortcutQuickLink('Add to Default shortcuts'); \Drupal::service('module_installer')->install(['block_content']); - $this->adminUser->addRole($this->drupalCreateRole(['administer block types']))->save(); + $this->adminUser + ->addRole($this->drupalCreateRole(['administer block types'])) + ->save(); BlockContentType::create([ 'id' => 'basic', 'label' => 'Basic block', diff --git a/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php b/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php index f73ac06402ed75c5f64941f3b5cc15d553daa1d1..d54dcebfc60ef59c891fd9e37b4fab94166d27f9 100644 --- a/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php +++ b/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php @@ -132,8 +132,7 @@ public function testModuleStatusChangeSubtreesHashCacheClear() { $role = Role::load($this->createRole([])); $role->setIsAdmin(TRUE); $role->save(); - $this->adminUser->addRole($role->id()); - $this->adminUser->save(); + $this->adminUser->addRole($role->id())->save(); // Uninstall a module. $edit = []; diff --git a/core/modules/user/src/Plugin/Action/AddRoleUser.php b/core/modules/user/src/Plugin/Action/AddRoleUser.php index f8be14d9225836fd95d44d01daf51ec37e528918..d56ad5385dae3b3e59a441be0709aa2a3c766698 100644 --- a/core/modules/user/src/Plugin/Action/AddRoleUser.php +++ b/core/modules/user/src/Plugin/Action/AddRoleUser.php @@ -25,8 +25,7 @@ public function execute($account = NULL) { // For efficiency manually save the original account before applying // any changes. $account->original = clone $account; - $account->addRole($rid); - $account->save(); + $account->addRole($rid)->save(); } } diff --git a/core/modules/user/src/Plugin/Action/RemoveRoleUser.php b/core/modules/user/src/Plugin/Action/RemoveRoleUser.php index 1c6e1186702c6b086c9e8707acb27d0b0270caef..c3d2dbea9d17f2a7173cf836201bff4601f371e8 100644 --- a/core/modules/user/src/Plugin/Action/RemoveRoleUser.php +++ b/core/modules/user/src/Plugin/Action/RemoveRoleUser.php @@ -25,8 +25,7 @@ public function execute($account = NULL) { // For efficiency manually save the original account before applying // any changes. $account->original = clone $account; - $account->removeRole($rid); - $account->save(); + $account->removeRole($rid)->save(); } } diff --git a/core/modules/user/tests/src/Functional/UserAdminListingTest.php b/core/modules/user/tests/src/Functional/UserAdminListingTest.php index 0d73c3876fb8937bf18b40a83e617627ce620c7d..c356cc2f8ce21b5e3413a9aff25e452b50733d8c 100644 --- a/core/modules/user/tests/src/Functional/UserAdminListingTest.php +++ b/core/modules/user/tests/src/Functional/UserAdminListingTest.php @@ -51,9 +51,7 @@ public function testUserListing() { $rid_2 = $this->drupalCreateRole([], 'custom_role_2', 'custom_role_2'); $account = $this->drupalCreateUser(); - $account->addRole($rid_1); - $account->addRole($rid_2); - $account->save(); + $account->addRole($rid_1)->addRole($rid_2)->save(); $accounts[$account->label()] = $account; $role_account_name = $account->label(); diff --git a/core/modules/user/tests/src/Functional/UserSubAdminTest.php b/core/modules/user/tests/src/Functional/UserSubAdminTest.php index 5034ed9b61a8996cdbdbe0c903af669127bd5693..250ce6abcadae6421e89e9c1ee0773c8ea91c20f 100644 --- a/core/modules/user/tests/src/Functional/UserSubAdminTest.php +++ b/core/modules/user/tests/src/Functional/UserSubAdminTest.php @@ -62,8 +62,9 @@ public function testSubAdmin() { $this->assertSession()->pageTextContains('Account ' . $cancel_user->getAccountName() . ' has been disabled.'); // Repeat with permission to select account cancellation method. - $user->addRole($this->drupalCreateRole(['select account cancellation method'])); - $user->save(); + $user + ->addRole($this->drupalCreateRole(['select account cancellation method'])) + ->save(); $cancel_user = $this->createUser(); $this->drupalGet('user/' . $cancel_user->id() . '/cancel'); $this->assertSession()->pageTextContains('Cancellation method'); diff --git a/core/modules/user/tests/src/Functional/Views/AccessTestBase.php b/core/modules/user/tests/src/Functional/Views/AccessTestBase.php index 27041a1638280414ea2f356076f96e6978667b78..ad897ec9bae64b01c605b86c9c2c956b189929f8 100644 --- a/core/modules/user/tests/src/Functional/Views/AccessTestBase.php +++ b/core/modules/user/tests/src/Functional/Views/AccessTestBase.php @@ -61,8 +61,7 @@ protected function setUp($import_test_views = TRUE, $modules = []): void { $this->normalUser = $this->drupalCreateUser([ 'views_test_data test permission', ]); - $this->normalUser->addRole($this->normalRole); - $this->normalUser->save(); + $this->normalUser->addRole($this->normalRole)->save(); // @todo when all the plugin information is cached make a reset function and // call it here. } diff --git a/core/modules/user/tests/src/Functional/Views/HandlerFieldRoleTest.php b/core/modules/user/tests/src/Functional/Views/HandlerFieldRoleTest.php index df642919cdb49324f78f0a09030e4c3995aacb5b..99afa5dbe8cdfdd5c4df4cac3b6ed4696d258fe6 100644 --- a/core/modules/user/tests/src/Functional/Views/HandlerFieldRoleTest.php +++ b/core/modules/user/tests/src/Functional/Views/HandlerFieldRoleTest.php @@ -40,9 +40,7 @@ public function testRole() { // Add roles to user 1. $user = User::load(1); - $user->addRole($role_name_a); - $user->addRole($role_name_b); - $user->save(); + $user->addRole($role_name_a)->addRole($role_name_b)->save(); $this->drupalLogin($this->createUser(['access user profiles'])); $this->drupalGet('/test-views-handler-field-role'); diff --git a/core/modules/user/tests/src/Functional/Views/RolesRidArgumentTest.php b/core/modules/user/tests/src/Functional/Views/RolesRidArgumentTest.php index b76007ef5ec5ff40c987ca8c7f8578271c6092c2..c6359267e1e736d7cfb2853ced9ba3f16936a7a6 100644 --- a/core/modules/user/tests/src/Functional/Views/RolesRidArgumentTest.php +++ b/core/modules/user/tests/src/Functional/Views/RolesRidArgumentTest.php @@ -36,11 +36,9 @@ public function testArgumentTitle() { $role_id = $this->createRole([], 'markup_role_name', '<em>Role name with markup</em>'); $this->createRole([], 'second_role_name', 'Second role name'); $user = $this->createUser([], 'User with role one'); - $user->addRole($role_id); - $user->save(); + $user->addRole($role_id)->save(); $second_user = $this->createUser([], 'User with role two'); - $second_user->addRole('second_role_name'); - $second_user->save(); + $second_user->addRole('second_role_name')->save(); $this->drupalGet('/user_roles_rid_test/markup_role_name'); $this->assertSession()->assertEscaped('<em>Role name with markup</em>'); diff --git a/core/modules/user/tests/src/Kernel/UserEntityReferenceTest.php b/core/modules/user/tests/src/Kernel/UserEntityReferenceTest.php index 9451b8c7080a10954fe5ad15e9e16c02b32b4fea..9e84b43469b053ff73f14fde68e69c021917e92b 100644 --- a/core/modules/user/tests/src/Kernel/UserEntityReferenceTest.php +++ b/core/modules/user/tests/src/Kernel/UserEntityReferenceTest.php @@ -69,16 +69,13 @@ public function testUserSelectionByRole() { // cspell:ignore aabb aabbb aabbbb aabbbb $user1 = $this->createUser([], 'aabb'); - $user1->addRole($this->role1->id()); - $user1->save(); + $user1->addRole($this->role1->id())->save(); $user2 = $this->createUser([], 'aabbb'); - $user2->addRole($this->role1->id()); - $user2->save(); + $user2->addRole($this->role1->id())->save(); $user3 = $this->createUser([], 'aabbbb'); - $user3->addRole($this->role2->id()); - $user3->save(); + $user3->addRole($this->role2->id())->save(); /** @var \Drupal\Core\Entity\EntityAutocompleteMatcherInterface $autocomplete */ $autocomplete = \Drupal::service('entity.autocomplete_matcher'); diff --git a/core/modules/user/tests/src/Kernel/Views/UserKernelTestBase.php b/core/modules/user/tests/src/Kernel/Views/UserKernelTestBase.php index 2ed035c993bbcc9f6c45d883718e534799f869cc..22be32e301598caeff006dff201f92078debcf8a 100644 --- a/core/modules/user/tests/src/Kernel/Views/UserKernelTestBase.php +++ b/core/modules/user/tests/src/Kernel/Views/UserKernelTestBase.php @@ -79,17 +79,14 @@ protected function setupPermissionTestData() { // Setup a user with just the first role (so no permission beside the // ones from the authenticated role). $this->users[] = $account = $this->userStorage->create(['name' => 'first_role']); - $account->addRole('no_permission'); - $account->save(); + $account->addRole('no_permission')->save(); // Setup a user with just the second role (so one additional permission). $this->users[] = $account = $this->userStorage->create(['name' => 'second_role']); - $account->addRole('one_permission'); - $account->save(); + $account->addRole('one_permission')->save(); // Setup a user with both the second and the third role. $this->users[] = $account = $this->userStorage->create(['name' => 'second_third_role']); - $account->addRole('one_permission'); - $account->addRole('multiple_permissions'); - $account->save(); + $account->addRole('one_permission')->addRole('multiple_permissions') + ->save(); } } diff --git a/core/modules/user/tests/src/Unit/Plugin/Action/AddRoleUserTest.php b/core/modules/user/tests/src/Unit/Plugin/Action/AddRoleUserTest.php index 218587428e4f89a6921fe74dac0105d52e093c1c..fd48cfa3299ecfe99183192e333db1e4b572985b 100644 --- a/core/modules/user/tests/src/Unit/Plugin/Action/AddRoleUserTest.php +++ b/core/modules/user/tests/src/Unit/Plugin/Action/AddRoleUserTest.php @@ -17,7 +17,8 @@ class AddRoleUserTest extends RoleUserTestBase { */ public function testExecuteAddExistingRole() { $this->account->expects($this->never()) - ->method('addRole'); + ->method('addRole') + ->willReturn($this->account); $this->account->expects($this->any()) ->method('hasRole') @@ -35,7 +36,8 @@ public function testExecuteAddExistingRole() { */ public function testExecuteAddNonExistingRole() { $this->account->expects($this->once()) - ->method('addRole'); + ->method('addRole') + ->willReturn($this->account); $this->account->expects($this->any()) ->method('hasRole') diff --git a/core/modules/user/tests/src/Unit/Plugin/Action/RemoveRoleUserTest.php b/core/modules/user/tests/src/Unit/Plugin/Action/RemoveRoleUserTest.php index e52542b15b1a80bb4b9b6cb92a5b1808c444e92e..429f2428b481af6358b423ba971514a76d03b1ea 100644 --- a/core/modules/user/tests/src/Unit/Plugin/Action/RemoveRoleUserTest.php +++ b/core/modules/user/tests/src/Unit/Plugin/Action/RemoveRoleUserTest.php @@ -17,7 +17,8 @@ class RemoveRoleUserTest extends RoleUserTestBase { */ public function testExecuteRemoveExistingRole() { $this->account->expects($this->once()) - ->method('removeRole'); + ->method('removeRole') + ->willReturn($this->account); $this->account->expects($this->any()) ->method('hasRole') @@ -35,7 +36,8 @@ public function testExecuteRemoveExistingRole() { */ public function testExecuteRemoveNonExistingRole() { $this->account->expects($this->never()) - ->method('removeRole'); + ->method('removeRole') + ->willReturn($this->account); $this->account->expects($this->any()) ->method('hasRole') diff --git a/core/profiles/standard/tests/src/Traits/StandardTestTrait.php b/core/profiles/standard/tests/src/Traits/StandardTestTrait.php index e2e3c005219f68293907b4c343dd75c0ddc1ab42..180f062c4fc5039553e4293f8e8656899b4d4f90 100644 --- a/core/profiles/standard/tests/src/Traits/StandardTestTrait.php +++ b/core/profiles/standard/tests/src/Traits/StandardTestTrait.php @@ -158,8 +158,7 @@ function (ConstraintViolation $v) { ]); $role->grantPermission('view the administration theme'); $role->save(); - $this->adminUser->addRole($role->id()); - $this->adminUser->save(); + $this->adminUser->addRole($role->id())->save(); $this->drupalGet('node/add'); $this->assertSession()->statusCodeEquals(200); @@ -233,8 +232,7 @@ function (ConstraintViolation $v) { ]); $role->grantPermission('administer workflows'); $role->save(); - $this->adminUser->addRole($role->id()); - $this->adminUser->save(); + $this->adminUser->addRole($role->id())->save(); $this->rebuildContainer(); $this->drupalGet('admin/config/workflow/workflows/manage/editorial'); $this->assertSession()->pageTextContains('Draft'); @@ -254,8 +252,7 @@ function (ConstraintViolation $v) { $role->grantPermission('administer media'); $role->grantPermission('administer media display'); $role->save(); - $this->adminUser->addRole($role->id()); - $this->adminUser->save(); + $this->adminUser->addRole($role->id())->save(); $assert_session = $this->assertSession(); $page = $this->getSession()->getPage(); /** @var \Drupal\media\Entity\MediaType $media_type */ diff --git a/core/tests/Drupal/KernelTests/Core/Cache/CacheContextOptimizationTest.php b/core/tests/Drupal/KernelTests/Core/Cache/CacheContextOptimizationTest.php index 4996a169fac92b62ee3290bea6b70d80ae973c80..05a7f643809533f8a5570c26f4dacd1d44f02448 100644 --- a/core/tests/Drupal/KernelTests/Core/Cache/CacheContextOptimizationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Cache/CacheContextOptimizationTest.php @@ -109,8 +109,7 @@ public function testUserRolesCacheContextOptimization() { // cache context, the element should have been changed because 'user.roles' // cache context defined a cache tag for user entity changes, which should // have bubbled up for the element when it was optimized away. - $authenticated_user->removeRole($role); - $authenticated_user->save(); + $authenticated_user->removeRole($role)->save(); $element = $test_element; $element['#markup'] = 'this should be visible'; $output = \Drupal::service('renderer')->renderRoot($element); diff --git a/core/tests/Drupal/KernelTests/Core/Element/PathElementFormTest.php b/core/tests/Drupal/KernelTests/Core/Element/PathElementFormTest.php index 92f0774f416a97795f65bd9172679cc8627071bd..69e5c938c77dc5cebdac12a84d87d7fbc016be86 100644 --- a/core/tests/Drupal/KernelTests/Core/Element/PathElementFormTest.php +++ b/core/tests/Drupal/KernelTests/Core/Element/PathElementFormTest.php @@ -51,8 +51,7 @@ protected function setUp(): void { 'name' => 'foobar', 'mail' => 'foobar@example.com', ]); - $this->testUser->addRole($role->id()); - $this->testUser->save(); + $this->testUser->addRole($role->id())->save(); \Drupal::service('current_user')->setAccount($this->testUser); }