Files
breadcrumb-the-shire/tests/Architecture/BookmarksModuleIsolationContractTest.php

86 lines
3.1 KiB
PHP
Raw Normal View History

<?php
namespace MintyPHP\Tests\Architecture;
use PHPUnit\Framework\TestCase;
2026-03-19 18:57:03 +01:00
final class BookmarksModuleIsolationContractTest extends TestCase
{
2026-03-19 18:57:03 +01:00
use ModuleExtractionContractSupport;
public function testCoreTemplatesHaveNoBookmarkSpecificMarkup(): void
{
2026-03-19 18:57:03 +01:00
$this->assertFilesDoNotContain(
[
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',
],
[
'aside-tab-bookmarks',
'aside-panel-bookmarks',
'data-app-bookmark-dialog',
'bookmarks.nav',
'components.bookmark',
]
);
}
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);
}
}