Verified Commit c11cf08f authored by Jess's avatar Jess
Browse files

Issue #3331229 by pminf, chadhester, zshrestha, hardikpandya, _pratik_,...

Issue #3331229 by pminf, chadhester, zshrestha, hardikpandya, _pratik_, rogerpfaff, ultimike, xjm, mandclu, alexb7217: Use chaining for User::addRole() and ::removeRole()

(cherry picked from commit 8d512c2a)
parent 6974f8b7
Loading
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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);
+3 −2
Original line number Diff line number Diff line
@@ -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')
+1 −2
Original line number Diff line number Diff line
@@ -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();
  }

}
+1 −2
Original line number Diff line number Diff line
@@ -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);
  }

+2 −2
Original line number Diff line number Diff line
@@ -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([
Loading