forked from fa/breadcrumb-the-shire
Rename module extraction contracts
This commit is contained in:
85
tests/Architecture/BookmarksModuleIsolationContractTest.php
Normal file
85
tests/Architecture/BookmarksModuleIsolationContractTest.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Tests\Architecture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class BookmarksModuleIsolationContractTest extends TestCase
|
||||
{
|
||||
use ModuleExtractionContractSupport;
|
||||
|
||||
public function testCoreTemplatesHaveNoBookmarkSpecificMarkup(): void
|
||||
{
|
||||
$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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user