Commit 13864c74 authored by Nicolas Widart's avatar Nicolas Widart

Adding an empty permissions edge case

parent a7aa510f
...@@ -41,6 +41,9 @@ class PermissionManager ...@@ -41,6 +41,9 @@ class PermissionManager
*/ */
public function clean($permissions) public function clean($permissions)
{ {
if (!$permissions) {
return [];
}
$cleanedPermissions = []; $cleanedPermissions = [];
foreach ($permissions as $permissionName => $checkedPermission) { foreach ($permissions as $permissionName => $checkedPermission) {
$cleanedPermissions[$permissionName] = (bool)$checkedPermission; $cleanedPermissions[$permissionName] = (bool)$checkedPermission;
......
...@@ -82,4 +82,16 @@ class PermissionManagerTest extends \TestCase ...@@ -82,4 +82,16 @@ class PermissionManagerTest extends \TestCase
$this->assertEquals($expected, $cleanedPermissions); $this->assertEquals($expected, $cleanedPermissions);
} }
/** @test */
public function itShouldReturnEmptyArrayIfNoRolesAreSupplied()
{
$request = [];
$expected = [];
$cleanedPermissions = $this->permissions->clean($request);
$this->assertEquals($expected, $cleanedPermissions);
}
} }
Markdown is supported
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