From ed360edb8370f886f5fa48123353305e22b8cf51 Mon Sep 17 00:00:00 2001 From: v-dumas Date: Mon, 17 Nov 2025 15:04:19 +0100 Subject: [PATCH] Fix PHP CS --- core/userrights.class.inc.php | 3 +-- .../src/BaseTestCase/ItopDataTestCase.php | 10 ++++------ .../unitary-tests/core/UserRightsTest.php | 11 +++++------ 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/core/userrights.class.inc.php b/core/userrights.class.inc.php index cfc8628cf..118f19b39 100644 --- a/core/userrights.class.inc.php +++ b/core/userrights.class.inc.php @@ -427,8 +427,7 @@ abstract class User extends cmdbAbstractObject $this->m_aCheckIssues[] = Dict::S('Class:User/Error:AdminProfileCannotBeRemovedBySelf'); } } - } - elseif ($this->IsPrivilegedUser()) { + } elseif ($this->IsPrivilegedUser()) { // Prevent Privileged User to be saved with profiles denying the access to the backoffice $oSet->Rewind(); while ($oUserProfile = $oSet->Fetch()) { diff --git a/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php b/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php index 932c685eb..af0e8fb89 100644 --- a/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php +++ b/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php @@ -661,17 +661,15 @@ abstract class ItopDataTestCase extends ItopTestCase { /** @var \ormLinkSet $oSet */ $oSet = $oUser->Get('profile_list'); - foreach ($oSet as $oUserProfile) - { - if ($oUserProfile->Get('profileid') == $iProfileId) - { + foreach ($oSet as $oUserProfile) { + if ($oUserProfile->Get('profileid') == $iProfileId) { $oSet->RemoveItem($oUserProfile->GetKey()); break; } } - $oUser = $this->updateObject(User::class, $oUser->GetKey(), array( + $oUser = $this->updateObject(User::class, $oUser->GetKey(), [ 'profile_list' => $oSet, - )); + ]); return $oUser; } diff --git a/tests/php-unit-tests/unitary-tests/core/UserRightsTest.php b/tests/php-unit-tests/unitary-tests/core/UserRightsTest.php index 696577e86..8bdabd4f4 100644 --- a/tests/php-unit-tests/unitary-tests/core/UserRightsTest.php +++ b/tests/php-unit-tests/unitary-tests/core/UserRightsTest.php @@ -87,12 +87,12 @@ class UserRightsTest extends ItopDataTestCase foreach ($aProfileIds as $iProfileId) { $oProfiles->AddItem(MetaModel::NewObject('URP_UserProfile', ['profileid' => $iProfileId, 'reason' => 'UNIT Tests'])); } - $oUser = MetaModel::NewObject('UserLocal', array( + $oUser = MetaModel::NewObject('UserLocal', [ 'login' => $sLogin, 'password' => 'Password1!', 'expiration' => UserLocal::EXPIRE_NEVER, 'profile_list' => $oProfiles, - )); + ]); return $oUser; } @@ -336,9 +336,9 @@ class UserRightsTest extends ItopDataTestCase public function UserCannotElevateTheirOwnRightsProvider(): array { return [ - 'Configuration manager to SuperUser' => ['current'=> 3, 'added' => 117], - 'Configuration manager to Administrator' => ['current'=> 3, 'added' => 1], - 'SuperUser to Administrator' => ['current'=> 117, 'added' => 1], + 'Configuration manager to SuperUser' => ['current' => 3, 'added' => 117], + 'Configuration manager to Administrator' => ['current' => 3, 'added' => 1], + 'SuperUser to Administrator' => ['current' => 117, 'added' => 1], ]; } @@ -417,7 +417,6 @@ class UserRightsTest extends ItopDataTestCase $this->RemoveProfileFromUser($oUser, $iProfileId); } - public function UserCannotLoseUserEditionRightsProvider(): array { return [