Removed PRIVILEGE_ prefix from constants

This commit is contained in:
Marcin Kurczewski 2014-09-06 17:54:02 +02:00
parent 8e8e983f28
commit 7c4eddd810
4 changed files with 10 additions and 10 deletions

View file

@ -39,7 +39,7 @@ final class UserController extends AbstractController
public function getFiltered() 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); $searchFormData = new \Szurubooru\FormData\SearchFormData($this->inputReader);
$searchResult = $this->userService->getFiltered($searchFormData); $searchResult = $this->userService->getFiltered($searchFormData);
@ -52,7 +52,7 @@ final class UserController extends AbstractController
public function register() public function register()
{ {
$this->privilegeService->assertPrivilege(\Szurubooru\Privilege::PRIVILEGE_REGISTER); $this->privilegeService->assertPrivilege(\Szurubooru\Privilege::REGISTER);
$input = new \Szurubooru\FormData\RegistrationFormData($this->inputReader); $input = new \Szurubooru\FormData\RegistrationFormData($this->inputReader);
$user = $this->userService->register($input); $user = $this->userService->register($input);
@ -68,8 +68,8 @@ final class UserController extends AbstractController
{ {
$this->privilegeService->assertPrivilege( $this->privilegeService->assertPrivilege(
$this->privilegeService->isLoggedIn($name) $this->privilegeService->isLoggedIn($name)
? \Szurubooru\Privilege::PRIVILEGE_DELETE_OWN_ACCOUNT ? \Szurubooru\Privilege::DELETE_OWN_ACCOUNT
: \Szurubooru\Privilege::PRIVILEGE_DELETE_ACCOUNTS); : \Szurubooru\Privilege::DELETE_ACCOUNTS);
return $this->userService->deleteByName($name); return $this->userService->deleteByName($name);
} }

View file

@ -3,8 +3,8 @@ namespace Szurubooru;
class Privilege class Privilege
{ {
const PRIVILEGE_REGISTER = 'register'; const REGISTER = 'register';
const PRIVILEGE_LIST_USERS = 'listUsers'; const LIST_USERS = 'listUsers';
const PRIVILEGE_DELETE_OWN_ACCOUNT = 'deleteOwnAccount'; const DELETE_OWN_ACCOUNT = 'deleteOwnAccount';
const PRIVILEGE_DELETE_ALL_ACCOUNTS = 'deleteAllAccounts'; const DELETE_ALL_ACCOUNTS = 'deleteAllAccounts';
} }

View file

@ -8,7 +8,7 @@ class PrivilegeTest extends \Szurubooru\Tests\AbstractTestCase
$refl = new \ReflectionClass(\Szurubooru\Privilege::class); $refl = new \ReflectionClass(\Szurubooru\Privilege::class);
foreach ($refl->getConstants() as $key => $value) 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); $this->assertEquals($key, $value);
} }
} }

View file

@ -19,7 +19,7 @@ class PrivilegeServiceTest extends \Szurubooru\Tests\AbstractTestCase
$testUser->accessRank = \Szurubooru\Entities\User::ACCESS_RANK_POWER_USER; $testUser->accessRank = \Szurubooru\Entities\User::ACCESS_RANK_POWER_USER;
$this->authServiceMock->method('getLoggedInUser')->willReturn($testUser); $this->authServiceMock->method('getLoggedInUser')->willReturn($testUser);
$privilege = \Szurubooru\Privilege::PRIVILEGE_LIST_USERS; $privilege = \Szurubooru\Privilege::LIST_USERS;
$this->configMock->set('security/privileges/' . $privilege, 'powerUser'); $this->configMock->set('security/privileges/' . $privilege, 'powerUser');
$privilegeService = $this->getPrivilegeService(); $privilegeService = $this->getPrivilegeService();