1
0
Files
breadcrumb-the-shire/tests/Architecture/ListTemplateContractTest.php
fs c609753570 refactor(tests): remove redundant tests and fix assertion style
Remove subset/duplicate architecture tests already covered by broader
checks, and replace assertTrue(true) with self::addToAssertionCount(1)
for explicit no-exception-thrown intent.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 18:46:49 +01:00

58 lines
2.7 KiB
PHP

<?php
namespace MintyPHP\Tests\Architecture;
use PHPUnit\Framework\TestCase;
class ListTemplateContractTest extends TestCase
{
use ListContractFiles;
use ProjectFileAssertionSupport;
public function testListTemplatesUseCentralToolbarRendererAndStandardListWrapper(): void
{
foreach ($this->listIndexTemplates() as $file) {
$content = $this->readProjectFile($file);
$moduleContent = $this->readTemplatePageModule($file);
$usesPartial = $this->usesSharedListFiltersPartial($content);
$this->assertTrue(
$usesPartial || str_contains($content, 'renderGridFilterToolbar('),
$file . ' does not render toolbar directly and does not include shared list-filters partial.'
);
$this->assertStringContainsString('initStandardListPage(', $moduleContent, $file);
$this->assertStringNotContainsString('gridFiltersFromSchema(', $content, $file);
$this->assertSame(0, preg_match('/<select id=\"[^\"]*-filter\"/', $content), $file);
$this->assertSame(0, preg_match('/<input[^>]*id=\"[^\"]*-filter\"/', $content), $file);
$this->assertSame(0, preg_match('/filters:\s*\[/', $content), $file);
}
}
public function testDrawerListTemplatesUseDrawerAndActiveFilterChips(): void
{
foreach ($this->drawerListTemplates() as $file) {
$content = $this->readProjectFile($file);
$moduleContent = $this->readTemplatePageModule($file);
$usesPartial = $this->usesSharedListFiltersPartial($content);
$this->assertStringContainsString("mode: 'drawer'", $moduleContent, $file);
if (!$usesPartial) {
$this->assertStringContainsString('data-filter-drawer-open', $content, $file);
$this->assertStringContainsString('data-filter-drawer-apply', $content, $file);
$this->assertStringContainsString('data-active-filter-chips', $content, $file);
}
$this->assertStringNotContainsString('data-filter-drawer-reset', $content, $file);
}
}
public function testSearchOnlyTemplatesDoNotUseDrawerControls(): void
{
foreach ($this->searchOnlyTemplates() as $file) {
$content = $this->readProjectFile($file);
$moduleContent = $this->readTemplatePageModule($file);
$this->assertStringContainsString("mode: 'search-only'", $moduleContent, $file);
$this->assertStringNotContainsString('data-filter-drawer-open', $content, $file);
$this->assertStringNotContainsString('data-filter-drawer-apply', $content, $file);
$this->assertStringNotContainsString('data-active-filter-chips', $content, $file);
}
}
}