61 lines
3.0 KiB
PHP
61 lines
3.0 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->assertStringNotContainsString('data-toolbar-toggle', $content, $file);
|
|
$this->assertStringNotContainsString('data-filter-overflow', $content, $file);
|
|
$this->assertStringNotContainsString('data-filter-toggle', $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);
|
|
}
|
|
}
|
|
}
|