From 7c4eddd810c7f01e13001e2439c7327dc4647abe Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sat, 6 Sep 2014 17:54:02 +0200 Subject: [PATCH] Removed PRIVILEGE_ prefix from constants --- src/Controllers/UserController.php | 8 ++++---- src/Privilege.php | 8 ++++---- tests/PrivilegeTest.php | 2 +- tests/Services/PrivilegeServiceTest.php | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Controllers/UserController.php b/src/Controllers/UserController.php index a8d466d3..b561a6c4 100644 --- a/src/Controllers/UserController.php +++ b/src/Controllers/UserController.php @@ -39,7 +39,7 @@ final class UserController extends AbstractController public function getFiltered() { - $this->privilegeService->assertPrivilege(\Szurubooru\Privilege::PRIVILEGE_LIST_USERS); + $this->privilegeService->assertPrivilege(\Szurubooru\Privilege::LIST_USERS); $searchFormData = new \Szurubooru\FormData\SearchFormData($this->inputReader); $searchResult = $this->userService->getFiltered($searchFormData); @@ -52,7 +52,7 @@ final class UserController extends AbstractController public function register() { - $this->privilegeService->assertPrivilege(\Szurubooru\Privilege::PRIVILEGE_REGISTER); + $this->privilegeService->assertPrivilege(\Szurubooru\Privilege::REGISTER); $input = new \Szurubooru\FormData\RegistrationFormData($this->inputReader); $user = $this->userService->register($input); @@ -68,8 +68,8 @@ final class UserController extends AbstractController { $this->privilegeService->assertPrivilege( $this->privilegeService->isLoggedIn($name) - ? \Szurubooru\Privilege::PRIVILEGE_DELETE_OWN_ACCOUNT - : \Szurubooru\Privilege::PRIVILEGE_DELETE_ACCOUNTS); + ? \Szurubooru\Privilege::DELETE_OWN_ACCOUNT + : \Szurubooru\Privilege::DELETE_ACCOUNTS); return $this->userService->deleteByName($name); } diff --git a/src/Privilege.php b/src/Privilege.php index edb8ba8b..005134bf 100644 --- a/src/Privilege.php +++ b/src/Privilege.php @@ -3,8 +3,8 @@ namespace Szurubooru; class Privilege { - const PRIVILEGE_REGISTER = 'register'; - const PRIVILEGE_LIST_USERS = 'listUsers'; - const PRIVILEGE_DELETE_OWN_ACCOUNT = 'deleteOwnAccount'; - const PRIVILEGE_DELETE_ALL_ACCOUNTS = 'deleteAllAccounts'; + const REGISTER = 'register'; + const LIST_USERS = 'listUsers'; + const DELETE_OWN_ACCOUNT = 'deleteOwnAccount'; + const DELETE_ALL_ACCOUNTS = 'deleteAllAccounts'; } diff --git a/tests/PrivilegeTest.php b/tests/PrivilegeTest.php index 7c578782..2089e91f 100644 --- a/tests/PrivilegeTest.php +++ b/tests/PrivilegeTest.php @@ -8,7 +8,7 @@ class PrivilegeTest extends \Szurubooru\Tests\AbstractTestCase $refl = new \ReflectionClass(\Szurubooru\Privilege::class); foreach ($refl->getConstants() as $key => $value) { - $value = strtoupper('privilege_' . ltrim(preg_replace('/[A-Z]/', '_\0', $value), '_')); + $value = strtoupper(ltrim(preg_replace('/[A-Z]/', '_\0', $value), '_')); $this->assertEquals($key, $value); } } diff --git a/tests/Services/PrivilegeServiceTest.php b/tests/Services/PrivilegeServiceTest.php index 6caa02b3..7d8af13a 100644 --- a/tests/Services/PrivilegeServiceTest.php +++ b/tests/Services/PrivilegeServiceTest.php @@ -19,7 +19,7 @@ class PrivilegeServiceTest extends \Szurubooru\Tests\AbstractTestCase $testUser->accessRank = \Szurubooru\Entities\User::ACCESS_RANK_POWER_USER; $this->authServiceMock->method('getLoggedInUser')->willReturn($testUser); - $privilege = \Szurubooru\Privilege::PRIVILEGE_LIST_USERS; + $privilege = \Szurubooru\Privilege::LIST_USERS; $this->configMock->set('security/privileges/' . $privilege, 'powerUser'); $privilegeService = $this->getPrivilegeService();