mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-10 02:14:31 +02:00
Renamed "devices" permission to "projects"
This commit is contained in:
parent
f2dfe12087
commit
7b6a906d98
19 changed files with 157 additions and 23 deletions
|
@ -158,4 +158,61 @@ class PermissionDataTest extends TestCase
|
|||
$data->setSchemaVersion(12345);
|
||||
$this->assertEquals(12345, $data->getSchemaVersion());
|
||||
}
|
||||
|
||||
public function testIsAnyOperationOfPermissionSet()
|
||||
{
|
||||
$data = new PermissionData();
|
||||
|
||||
//Initially no operation of any permission is set
|
||||
$this->assertFalse($data->isAnyOperationOfPermissionSet('perm1'));
|
||||
|
||||
$data->setPermissionValue('perm1', 'op1', PermissionData::ALLOW);
|
||||
$this->assertTrue($data->isAnyOperationOfPermissionSet('perm1'));
|
||||
}
|
||||
|
||||
public function testGetAllDefinedOperationsOfPermission()
|
||||
{
|
||||
$data = new PermissionData();
|
||||
|
||||
$this->assertEmpty($data->getAllDefinedOperationsOfPermission('perm1'));
|
||||
|
||||
$data->setPermissionValue('perm1', 'op1', PermissionData::ALLOW);
|
||||
$data->setPermissionValue('perm1', 'op2', PermissionData::DISALLOW);
|
||||
|
||||
$this->assertEquals([
|
||||
'op1' => PermissionData::ALLOW, 'op2' => PermissionData::DISALLOW,
|
||||
],
|
||||
$data->getAllDefinedOperationsOfPermission('perm1'));
|
||||
}
|
||||
|
||||
public function testSetAllOperationsOfPermission()
|
||||
{
|
||||
$data = new PermissionData();
|
||||
|
||||
$data->setAllOperationsOfPermission('perm1', [
|
||||
'op1' => PermissionData::ALLOW,
|
||||
'op2' => PermissionData::DISALLOW,
|
||||
]);
|
||||
|
||||
$this->assertEquals([
|
||||
'op1' => PermissionData::ALLOW, 'op2' => PermissionData::DISALLOW,
|
||||
],
|
||||
$data->getAllDefinedOperationsOfPermission('perm1'));
|
||||
}
|
||||
|
||||
public function testRemovePermission()
|
||||
{
|
||||
$data = new PermissionData();
|
||||
|
||||
$data->setPermissionValue('perm1', 'op1', PermissionData::ALLOW);
|
||||
$data->setPermissionValue('perm1', 'op2', PermissionData::DISALLOW);
|
||||
|
||||
$this->assertTrue($data->isPermissionSet('perm1', 'op1'));
|
||||
$this->assertTrue($data->isPermissionSet('perm1', 'op2'));
|
||||
|
||||
$data->removePermission('perm1');
|
||||
|
||||
$this->assertFalse($data->isPermissionSet('perm1', 'op1'));
|
||||
$this->assertFalse($data->isPermissionSet('perm1', 'op2'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue