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
63 lines
1.7 KiB
PHP
63 lines
1.7 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\Website\Hub\Concerns\HasRateLimiting;
|
|
use Illuminate\Support\Facades\RateLimiter;
|
|
|
|
class HasRateLimitingTest extends AdminTestCase
|
|
{
|
|
public function test_HasRateLimiting_rateLimit_Good_executes_callback_before_limit(): void
|
|
{
|
|
$this->actingAsHades();
|
|
|
|
$component = new class
|
|
{
|
|
use HasRateLimiting;
|
|
|
|
public string $actionMessage = '';
|
|
|
|
public string $actionType = '';
|
|
|
|
public function attempt(): mixed
|
|
{
|
|
return $this->rateLimit('platform-test', 2, static fn (): string => 'ok');
|
|
}
|
|
};
|
|
|
|
RateLimiter::clear('platform-test:1');
|
|
|
|
$this->assertSame('ok', $component->attempt());
|
|
$this->assertSame('ok', $component->attempt());
|
|
}
|
|
|
|
public function test_HasRateLimiting_rateLimit_Bad_sets_warning_state_when_limited(): void
|
|
{
|
|
$this->actingAsHades();
|
|
|
|
$component = new class
|
|
{
|
|
use HasRateLimiting;
|
|
|
|
public string $actionMessage = '';
|
|
|
|
public string $actionType = '';
|
|
|
|
public function attempt(): mixed
|
|
{
|
|
return $this->rateLimit('platform-test', 1, static fn (): string => 'ok');
|
|
}
|
|
};
|
|
|
|
RateLimiter::clear('platform-test:1');
|
|
$component->attempt();
|
|
|
|
$this->assertNull($component->attempt());
|
|
$this->assertSame('warning', $component->actionType);
|
|
$this->assertStringContainsString('Too many platform test attempts', $component->actionMessage);
|
|
}
|
|
}
|