From 13fbed7262c86010f46d78c5253f8ed08d2bec72 Mon Sep 17 00:00:00 2001 From: Kristiaan Van den Eynde Date: Mon, 7 Aug 2017 10:40:36 +0200 Subject: [PATCH] interdiff --- .../Tests/Update/UserUpdateUserOneAdminTest.php | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/core/modules/user/src/Tests/Update/UserUpdateUserOneAdminTest.php b/core/modules/user/src/Tests/Update/UserUpdateUserOneAdminTest.php index 75d87e8..0e8a0bf 100644 --- a/core/modules/user/src/Tests/Update/UserUpdateUserOneAdminTest.php +++ b/core/modules/user/src/Tests/Update/UserUpdateUserOneAdminTest.php @@ -26,11 +26,30 @@ protected function setDatabaseDumpFiles() { * Tests that user 1 has the administrator role after the update. */ public function testUserOneAdminRole() { + // Standard install profile used to assign the administrator role to user 1. + // Let's check for its presence, remove it and check whether the removal did + // its job. + $this->assertTrue($this->UserOneHasAdministratorRole()); $user1 = User::load(1); - $this->assertFalse(in_array(RoleInterface::ADMINISTRATOR_ID, $user1->getRoles())); + $user1->removeRole(RoleInterface::ADMINISTRATOR_ID); + $user1->save(); + $this->assertFalse($this->UserOneHasAdministratorRole()); + + // The user_post_update_grant_user_1_admin_role() post update function + // should have added the administrator role to user 1. $this->runUpdates(); + $this->assertTrue($this->UserOneHasAdministratorRole()); + } + + /** + * Checks whether user 1 has the administrator role. + * + * @return bool + * Whether user 1 has the administrator role. + */ + protected function UserOneHasAdministratorRole() { $user1 = User::load(1); - $this->assertTrue(in_array(RoleInterface::ADMINISTRATOR_ID, $user1->getRoles())); + return in_array(RoleInterface::ADMINISTRATOR_ID, $user1->getRoles(), TRUE); } } -- 2.8.1