1
0
mirror of https://github.com/chylex/Lightning-Tracker.git synced 2024-12-22 05:42:48 +01:00
Lightning-Tracker/tests/acceptance/T021_ProjectManageability_Cest.php

92 lines
2.3 KiB
PHP

<?php
declare(strict_types = 1);
namespace acceptance;
use AcceptanceTester;
class T021_ProjectManageability_Cest{
private function ensureCanManage(AcceptanceTester $I, array $projects): void{
foreach($projects as $project){
$I->amOnPage('/project/'.$project);
$I->seeElement('#navigation a[href="http://localhost/project/'.$project.'/settings"]');
}
}
private function ensureCannotManage(AcceptanceTester $I, array $projects): void{
foreach($projects as $project){
$I->amOnPage('/project/'.$project);
$I->seeElement('#navigation a[href="http://localhost/project/'.$project.'/issues"]');
$I->dontSeeElement('#navigation a[href="http://localhost/project/'.$project.'/settings"]');
}
}
public function canManageAllProjectsAsAdmin(AcceptanceTester $I): void{
$I->amLoggedIn('Admin');
$this->ensureCanManage($I, [
'AdminVisible', 'AdminHidden',
'User1Visible', 'User1Hidden',
'User2Visible', 'User2Hidden',
]);
}
public function canManageAllProjectsAsModerator(AcceptanceTester $I): void{
$I->amLoggedIn('Moderator');
$this->ensureCanManage($I, [
'AdminVisible', 'AdminHidden',
'User1Visible', 'User1Hidden',
'User2Visible', 'User2Hidden',
]);
}
public function canManagePubliclyVisibleProjectsAsManager1(AcceptanceTester $I): void{
$I->amLoggedIn('Manager1');
$this->ensureCanManage($I, [
'AdminVisible',
'User1Visible',
'User2Visible',
]);
}
public function canManageSomeProjectsAsUser1(AcceptanceTester $I): void{
$I->amLoggedIn('User1');
$this->ensureCanManage($I, [
'User1Visible', 'User1Hidden',
]);
$this->ensureCannotManage($I, [
'AdminVisible',
'User2Visible',
]);
}
public function canManageSomeProjectsAsUser2(AcceptanceTester $I): void{
$I->amLoggedIn('User2');
$this->ensureCanManage($I, [
'User2Visible', 'User2Hidden',
]);
$this->ensureCannotManage($I, [
'AdminVisible',
'User1Visible',
]);
}
public function cannotManageAnyProjectsAsRoleLess(AcceptanceTester $I): void{
$I->amLoggedIn('RoleLess');
$this->ensureCannotManage($I, [
'AdminVisible',
'User1Visible',
'User2Visible',
]);
}
}
?>