Foundation slice for Mantis #843 php/Mod/Admin + php/Website/Hub RFC: * php/Mod/Admin/Boot.php — search registry, menu registry, form component layer, HasRateLimiting concern, reusable form/view primitives under Mod/Admin/Forms * php/Website/Hub/Boot.php — host-aware Hub route naming for secondary domains * WorkspaceSwitcher and GlobalSearch global Hub Livewire components * Foundation routed slice in Hub/Routes/admin.php: dashboard shell, workspace listing, site settings (with WordPress/webhook connector), account usage, platform user list+detail * Foundation tests under php/tests/Feature/Mod/Admin/ 53 PHP files. php -l clean. Pest unrunnable in sandbox (no vendor/). Foundation slice only — composer.json kept off-limits so namespace stays under Core\Mod\Agentic\... rather than standalone Core\Admin package. Deferred: Profile, Settings, ServiceManager, ServicesAdmin, Honeypot, Entitlement\{Dashboard,FeatureManager,PackageManager}, PromptManager, WaitlistManager, Console, Databases, Deployments, Content, ContentManager, ContentEditor, ActivityLog, Analytics, AIServices, BoostPurchase. Lane was under-instructed by supervisor with stop-at framing — follow-up tickets needed for remainder. Co-authored-by: Codex <noreply@openai.com> Closes tasks.lthn.sh/view.php?id=843
79 lines
2.3 KiB
PHP
79 lines
2.3 KiB
PHP
<?php
|
|
|
|
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Core\Mod\Agentic\Tests\Feature\Mod\Admin;
|
|
|
|
use Core\Mod\Agentic\Mod\Admin\Menu\AdminMenuRegistry;
|
|
use Core\Mod\Agentic\Mod\Admin\Menu\Contracts\AdminMenuProvider;
|
|
use Tests\Fixtures\HadesUser;
|
|
|
|
class AdminMenuRegistryTest extends AdminTestCase
|
|
{
|
|
public function test_AdminMenuRegistry_items_Good_groups_and_orders_menu_items(): void
|
|
{
|
|
$registry = new AdminMenuRegistry;
|
|
$registry->register($this->makeProvider());
|
|
|
|
$items = $registry->items($this->hadesUser);
|
|
|
|
$this->assertArrayHasKey('dashboard', $items);
|
|
$this->assertArrayHasKey('admin', $items);
|
|
$this->assertSame('Dashboard', $items['dashboard']['items'][0]['label']);
|
|
$this->assertSame('Platform', $items['admin']['items'][0]['label']);
|
|
}
|
|
|
|
public function test_AdminMenuRegistry_items_Bad_hides_admin_items_for_non_hades_users(): void
|
|
{
|
|
$registry = new AdminMenuRegistry;
|
|
$registry->register($this->makeProvider());
|
|
|
|
$user = new class extends HadesUser
|
|
{
|
|
public function isHades(): bool
|
|
{
|
|
return false;
|
|
}
|
|
};
|
|
|
|
$items = $registry->items($user);
|
|
|
|
$this->assertArrayHasKey('dashboard', $items);
|
|
$this->assertArrayNotHasKey('admin', $items);
|
|
}
|
|
|
|
protected function makeProvider(): AdminMenuProvider
|
|
{
|
|
return new class implements AdminMenuProvider
|
|
{
|
|
public function adminMenuItems(): array
|
|
{
|
|
return [
|
|
[
|
|
'group' => 'dashboard',
|
|
'priority' => 10,
|
|
'item' => fn (): array => ['label' => 'Dashboard', 'href' => '/hub'],
|
|
],
|
|
[
|
|
'group' => 'admin',
|
|
'priority' => 20,
|
|
'admin' => true,
|
|
'item' => fn (): array => ['label' => 'Platform', 'href' => '/hub/platform'],
|
|
],
|
|
];
|
|
}
|
|
|
|
public function menuPermissions(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function canViewMenu(?object $user, ?object $workspace): bool
|
|
{
|
|
return $user !== null;
|
|
}
|
|
};
|
|
}
|
|
}
|