Commit 2a0dbb3a authored by Jacob Priddy's avatar Jacob Priddy 👌
Browse files

Restrict deleting of default permission groups

parent f8bf96a1
Pipeline #2292 passed with stages
in 1 minute and 46 seconds
......@@ -5,6 +5,7 @@ namespace Tests\Unit\Source\UseCases\Groups\DeleteGroup;
use Source\Entities\Group;
use PHPUnit\Framework\TestCase;
use Source\Authorization\Permissions;
use Source\Exceptions\DeleteFailedException;
use Source\Exceptions\EntityNotFoundException;
use Source\UseCases\Groups\DeleteGroup\DeleteGroup;
......@@ -84,4 +85,28 @@ class UseCaseTest extends TestCase
$this->assertCount(1, $this->groupsRepository->all());
$this->assertEquals('420', $this->groupsRepository->get('420')->getId());
}
public function groupNameProvider(): array
{
$reflection = new \ReflectionClass(Permissions::class);
return array_map(static function (string $element) {
return [$element];
}, $reflection->getConstants());
}
/**
* @test
* @dataProvider groupNameProvider
* @param string $group
* @throws \Source\Exceptions\DeleteFailedException
* @throws \Source\Exceptions\EntityNotFoundException
*/
public function default_permission_groups_cannot_be_deleted(string $group): void
{
$g = $this->groupsRepository->create(new Group(0, $group, ''));
$this->expectException(DeleteFailedException::class);
$this->handleTest($g->getId());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment