feat: extract bookmarks as standalone module with MintyPHP\Module\Bookmarks namespace
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>
This commit is contained in:
84
tests/Architecture/NoBookmarksHardcodingTest.php
Normal file
84
tests/Architecture/NoBookmarksHardcodingTest.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Tests\Architecture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class NoBookmarksHardcodingTest extends TestCase
|
||||
{
|
||||
public function testCoreTemplatesHaveNoBookmarkSpecificMarkup(): void
|
||||
{
|
||||
$files = [
|
||||
dirname(__DIR__, 2) . '/templates/default.phtml',
|
||||
dirname(__DIR__, 2) . '/templates/partials/app-topbar.phtml',
|
||||
dirname(__DIR__, 2) . '/templates/partials/app-main-aside.phtml',
|
||||
dirname(__DIR__, 2) . '/templates/partials/app-main-aside-icon-bar.phtml',
|
||||
];
|
||||
|
||||
foreach ($files as $file) {
|
||||
$content = file_get_contents($file);
|
||||
self::assertIsString($content);
|
||||
self::assertStringNotContainsString('aside-tab-bookmarks', $content, $file);
|
||||
self::assertStringNotContainsString('aside-panel-bookmarks', $content, $file);
|
||||
self::assertStringNotContainsString('data-app-bookmark-dialog', $content, $file);
|
||||
self::assertStringNotContainsString('bookmarks.nav', $content, $file);
|
||||
self::assertStringNotContainsString("components.bookmark", $content, $file);
|
||||
}
|
||||
}
|
||||
|
||||
public function testCoreBookmarkEntrypointsAreRemoved(): void
|
||||
{
|
||||
$root = dirname(__DIR__, 2);
|
||||
|
||||
self::assertFileDoesNotExist($root . '/templates/partials/app-bookmark-dialog.phtml');
|
||||
self::assertFileDoesNotExist($root . '/web/js/components/app-bookmark-save.js');
|
||||
self::assertFileDoesNotExist($root . '/web/js/components/app-bookmark-panel.js');
|
||||
self::assertFileDoesNotExist($root . '/web/css/components/app-bookmark-form.css');
|
||||
self::assertDirectoryDoesNotExist($root . '/pages/bookmarks');
|
||||
}
|
||||
|
||||
public function testCoreNoLongerContainsBookmarkServiceDirectory(): void
|
||||
{
|
||||
$root = dirname(__DIR__, 2);
|
||||
self::assertDirectoryDoesNotExist(
|
||||
$root . '/lib/Service/Bookmark',
|
||||
'Bookmark service classes should live in modules/bookmarks/lib, not in Core lib/Service'
|
||||
);
|
||||
}
|
||||
|
||||
public function testCoreNoLongerContainsBookmarkRepositoryFiles(): void
|
||||
{
|
||||
$root = dirname(__DIR__, 2);
|
||||
$repoDir = $root . '/lib/Repository/User';
|
||||
if (!is_dir($repoDir)) {
|
||||
self::addToAssertionCount(1);
|
||||
return;
|
||||
}
|
||||
|
||||
$entries = scandir($repoDir) ?: [];
|
||||
$bookmarkFiles = array_filter($entries, static fn (string $f): bool => str_starts_with($f, 'Bookmark'));
|
||||
self::assertSame(
|
||||
[],
|
||||
array_values($bookmarkFiles),
|
||||
'Core lib/Repository/User/ still contains Bookmark files: ' . implode(', ', $bookmarkFiles)
|
||||
);
|
||||
}
|
||||
|
||||
public function testCoreNoLongerContainsBookmarkUrlNormalizer(): void
|
||||
{
|
||||
$root = dirname(__DIR__, 2);
|
||||
self::assertFileDoesNotExist(
|
||||
$root . '/lib/Support/BookmarkUrlNormalizer.php',
|
||||
'BookmarkUrlNormalizer should live in modules/bookmarks/lib, not in Core lib/Support'
|
||||
);
|
||||
}
|
||||
|
||||
public function testCoreAuthLifecycleHasNoLegacyBookmarkSessionKeyWrites(): void
|
||||
{
|
||||
$file = dirname(__DIR__, 2) . '/lib/Service/Auth/AuthSessionTenantContextService.php';
|
||||
$content = file_get_contents($file);
|
||||
self::assertIsString($content);
|
||||
self::assertStringNotContainsString('user_bookmarks', $content);
|
||||
self::assertStringNotContainsString('module.bookmarks.grouped', $content);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user