detail pages for customers and projects (#1371)
This commit is contained in:
@@ -14,7 +14,6 @@ use App\Repository\RolePermissionRepository;
|
||||
use App\Security\AclDecisionManager;
|
||||
use App\Security\RolePermissionManager;
|
||||
use App\Voter\AbstractVoter;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class AbstractVoterTest extends TestCase
|
||||
@@ -41,20 +40,23 @@ abstract class AbstractVoterTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param string $role
|
||||
* @param string|null $role
|
||||
* @return User
|
||||
*/
|
||||
protected function getUser($id, $role)
|
||||
protected function getUser($id, ?string $role)
|
||||
{
|
||||
$roles = [];
|
||||
if (!empty($role)) {
|
||||
$roles[] = $role;
|
||||
}
|
||||
|
||||
$user = $this->getMockBuilder(User::class)->getMock();
|
||||
$user->method('getId')->willReturn($id);
|
||||
$user->method('getRoles')->willReturn($roles);
|
||||
$user->method('getTeams')->willReturn(new ArrayCollection());
|
||||
$user = new User();
|
||||
$user->setRoles($roles);
|
||||
|
||||
$reflection = new \ReflectionClass($user);
|
||||
$property = $reflection->getProperty('id');
|
||||
$property->setAccessible(true);
|
||||
$property->setValue($user, $id);
|
||||
|
||||
return $user;
|
||||
}
|
||||
@@ -69,16 +71,16 @@ abstract class AbstractVoterTest extends TestCase
|
||||
if (!$overwrite) {
|
||||
$activities = ['view_activity', 'edit_activity', 'budget_activity', 'delete_activity', 'create_activity'];
|
||||
$activitiesTeam = ['view_activity', 'create_activity', 'edit_teamlead_activity', 'budget_teamlead_activity'];
|
||||
$projects = ['view_project', 'edit_project', 'budget_project', 'delete_project', 'create_project'];
|
||||
$projectsTeam = ['view_project', 'edit_teamlead_project', 'budget_teamlead_project', 'permissions_teamlead_project'];
|
||||
$customers = ['view_customer', 'edit_customer', 'budget_customer', 'delete_customer', 'create_customer'];
|
||||
$customersTeam = ['view_customer', 'edit_teamlead_customer', 'budget_teamlead_customer'];
|
||||
$projects = ['view_project', 'create_project', 'edit_project', 'budget_project', 'delete_project', 'permissions_project', 'comments_project', 'details_project'];
|
||||
$projectsTeam = ['view_teamlead_project', 'edit_teamlead_project', 'budget_teamlead_project', 'permissions_teamlead_project', 'comments_teamlead_project', 'details_teamlead_project'];
|
||||
$customers = ['view_customer', 'create_customer', 'edit_customer', 'budget_customer', 'delete_customer', 'permissions_customer', 'comments_customer', 'details_customer'];
|
||||
$customersTeam = ['view_teamlead_customer', 'edit_teamlead_customer', 'budget_teamlead_customer', 'comments_teamlead_customer', 'details_teamlead_customer'];
|
||||
$invoice = ['view_invoice', 'create_invoice'];
|
||||
$invoiceTemplate = ['manage_invoice_template'];
|
||||
$timesheet = ['view_own_timesheet', 'start_own_timesheet', 'stop_own_timesheet', 'create_own_timesheet', 'edit_own_timesheet', 'export_own_timesheet', 'delete_own_timesheet'];
|
||||
$timesheetOthers = ['view_other_timesheet', 'start_other_timesheet', 'stop_other_timesheet', 'create_other_timesheet', 'edit_other_timesheet', 'export_other_timesheet', 'delete_other_timesheet'];
|
||||
$profile = ['view_own_profile', 'edit_own_profile', 'password_own_profile', 'preferences_own_profile', 'api-token_own_profile'];
|
||||
$profileOther = ['view_other_profile', 'edit_other_profile', 'delete_other_profile', 'password_other_profile', 'roles_other_profile', 'preferences_other_profile', 'api-token_other_profile'];
|
||||
$profileOther = ['view_other_profile', 'edit_other_profile', 'password_other_profile', 'roles_other_profile', 'preferences_other_profile', 'api-token_other_profile'];
|
||||
$user = ['view_user', 'create_user', 'delete_user'];
|
||||
$rate = ['view_rate_own_timesheet', 'edit_rate_own_timesheet'];
|
||||
$rateOther = ['view_rate_other_timesheet', 'edit_rate_other_timesheet'];
|
||||
@@ -87,7 +89,7 @@ abstract class AbstractVoterTest extends TestCase
|
||||
$roleUser = ['edit_team_activity', 'edit_team_project', 'edit_team_customer'];
|
||||
$roleTeamlead = ['view_rate_own_timesheet', 'view_rate_other_timesheet', 'hourly-rate_own_profile'];
|
||||
$roleAdmin = ['hourly-rate_own_profile', 'edit_exported_timesheet'];
|
||||
$roleSuperAdmin = ['hourly-rate_own_profile', 'hourly-rate_other_profile', 'delete_own_profile', 'roles_own_profile', 'system_information', 'system_configuration', 'plugins', 'edit_exported_timesheet'];
|
||||
$roleSuperAdmin = ['hourly-rate_own_profile', 'hourly-rate_other_profile', 'roles_own_profile', 'system_information', 'system_configuration', 'plugins', 'edit_exported_timesheet'];
|
||||
|
||||
$permissions = [
|
||||
'ROLE_USER' => array_merge($timesheet, $profile, $roleUser),
|
||||
|
||||
Reference in New Issue
Block a user