feat(core) : gate sidebar by effective permissions
This commit is contained in:
@@ -103,4 +103,28 @@ final class SidebarFilterTest extends TestCase
|
||||
self::assertSame('/x', $result['sections'][0]['items'][0]['to']);
|
||||
self::assertArrayNotHasKey('roles', $result['sections'][0]['items'][0]);
|
||||
}
|
||||
|
||||
public function testItemHiddenWhenPermissionMissing(): void
|
||||
{
|
||||
$sections = [[
|
||||
'label' => 's', 'icon' => 'i',
|
||||
'items' => [
|
||||
['label' => 'a', 'to' => '/a', 'icon' => 'i', 'permission' => 'core.users.view'],
|
||||
['label' => 'b', 'to' => '/b', 'icon' => 'i'],
|
||||
],
|
||||
]];
|
||||
$out = SidebarFilter::filter($sections, [], [], []);
|
||||
self::assertCount(1, $out['sections'][0]['items']);
|
||||
self::assertSame('/b', $out['sections'][0]['items'][0]['to']);
|
||||
}
|
||||
|
||||
public function testItemVisibleWhenPermissionGranted(): void
|
||||
{
|
||||
$sections = [[
|
||||
'label' => 's', 'icon' => 'i',
|
||||
'items' => [['label' => 'a', 'to' => '/a', 'icon' => 'i', 'permission' => 'core.users.view']],
|
||||
]];
|
||||
$out = SidebarFilter::filter($sections, [], [], ['core.users.view']);
|
||||
self::assertCount(1, $out['sections'][0]['items']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user