forked from fa/breadcrumb-the-shire
Moves bookmarks from core hardcoding into modules/bookmarks/ as a
fully self-contained module, following the same pattern as addressbook.
Module contributions via platform slots:
- aside.tab_panel: bookmark sidebar panel
- topbar.right_item: bookmark toggle button
- layout.body_end_template: bookmark/group dialogs
- layout.head_style: bookmark CSS (form + sidebar)
- runtime.component: bookmark-save and bookmark-panel (phase: late)
- search.resource_item: bookmarks in global search (user-scoped via {{userId}})
Backend fully in module namespace (MintyPHP\Module\Bookmarks\*):
- Service: BookmarkService, BookmarkServicesFactory, BookmarkRepositoryFactory
- Repository: BookmarkRepository, BookmarkGroupRepository, BookmarkNavigationRepository
- Support: BookmarkUrlNormalizer
- Providers: BookmarksSessionProvider, BookmarksLayoutProvider, BookmarksSearchProvider
Core cleanup:
- Removed all bookmark-specific markup from core templates
- Removed core DI registrations for bookmark services
- Removed core bookmark pages, JS, CSS
- AuthSessionTenantContextService delegates to module SessionProvider
Architecture guards:
- NoBookmarksHardcodingTest: verifies zero bookmark references in core
- testModuleClassesUseModuleNamespace: prevents core namespace leakage
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
46 lines
1.4 KiB
PHP
46 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace MintyPHP\Tests\Unit\Module;
|
|
|
|
use MintyPHP\Module\Bookmarks\BookmarksAuthorizationPolicy;
|
|
use MintyPHP\Service\Access\AuthorizationPolicyInterface;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class BookmarksAuthorizationPolicyTest extends TestCase
|
|
{
|
|
public function testImplementsAuthorizationPolicyContract(): void
|
|
{
|
|
$policy = new BookmarksAuthorizationPolicy();
|
|
self::assertInstanceOf(AuthorizationPolicyInterface::class, $policy);
|
|
}
|
|
|
|
public function testSupportsBookmarksAbilityOnly(): void
|
|
{
|
|
$policy = new BookmarksAuthorizationPolicy();
|
|
|
|
self::assertTrue($policy->supports(BookmarksAuthorizationPolicy::ABILITY_USE));
|
|
self::assertFalse($policy->supports('addressbook.view'));
|
|
}
|
|
|
|
public function testAuthorizeAllowsAuthenticatedActors(): void
|
|
{
|
|
$policy = new BookmarksAuthorizationPolicy();
|
|
|
|
$decision = $policy->authorize(BookmarksAuthorizationPolicy::ABILITY_USE, [
|
|
'actor_user_id' => 7,
|
|
]);
|
|
|
|
self::assertTrue($decision->isAllowed());
|
|
}
|
|
|
|
public function testAuthorizeDeniesMissingActor(): void
|
|
{
|
|
$policy = new BookmarksAuthorizationPolicy();
|
|
|
|
$decision = $policy->authorize(BookmarksAuthorizationPolicy::ABILITY_USE, []);
|
|
|
|
self::assertFalse($decision->isAllowed());
|
|
self::assertSame(403, $decision->status());
|
|
}
|
|
}
|