diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php index 4e296714dc..eeaf96b29c 100644 --- a/core/tests/Drupal/Tests/BrowserTestBase.php +++ b/core/tests/Drupal/Tests/BrowserTestBase.php @@ -1415,6 +1415,9 @@ protected function drupalCreateNode(array $settings = array()) { protected function drupalCreateUser(array $permissions = array(), $name = NULL, $admin = FALSE) { $user = $this->drupalCreateUserParent($permissions, $name, $admin); $this->markEntityForCleanup($user); + foreach ($user->getRoles(TRUE) as $rid) { + $this->markEntityForCleanup(Role::load($rid)); + } return $user; } @@ -1422,9 +1425,9 @@ protected function drupalCreateUser(array $permissions = array(), $name = NULL, * {@inheritdoc} */ protected function drupalCreateRole(array $permissions, $rid = NULL, $name = NULL, $weight = NULL) { - $role = $this->drupalCreateRoleParent($permissions, $rid, $name, $weight); - $this->markEntityForCleanup(Role::load($role)); - return $role; + $rid = $this->drupalCreateRoleParent($permissions, $rid, $name, $weight); + $this->markEntityForCleanup(Role::load($rid)); + return $rid; } }