Prove the heredoc breakpoint scan on a fixture, not production debt
Plan step 38's last batch cleared the one real medium: this premise test relied on (containment.blade.php's Lists example, now <x-grid :columns="['compact' => 1, 'medium' => 2]">) — its own goal, not a regression, but it leaves nothing left over to find. The test now builds a real two-heredocs-deep fixture (an @php block nesting a <<<'BLADE' example, exactly how a showcase section is shaped) and reuses the first test's own pattern and helper against it, so the scan is proven on demand instead of by whatever Tailwind happens to still be lying around. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
d15312023b
commit
97d7d9b5c0
@@ -78,8 +78,34 @@ it('scans the showcase example heredocs too, where the package teaches its own m
|
|||||||
->filter(fn (SplFileInfo $file): bool => str_contains($file->getRelativePathname(), 'showcase'.DIRECTORY_SEPARATOR.'sections'))
|
->filter(fn (SplFileInfo $file): bool => str_contains($file->getRelativePathname(), 'showcase'.DIRECTORY_SEPARATOR.'sections'))
|
||||||
->filter(fn (SplFileInfo $file): bool => str_contains($file->getContents(), "<<<'BLADE'"));
|
->filter(fn (SplFileInfo $file): bool => str_contains($file->getContents(), "<<<'BLADE'"));
|
||||||
|
|
||||||
// The scan reads whole files, so nothing above can be hiding inside a heredoc; this only holds
|
// Every section still teaches its examples through a heredoc nested inside an @php block
|
||||||
// the premise up, in case the examples ever move out of them.
|
// (plan step 38 rewrote what is inside them, not the mechanism), so the two scans above —
|
||||||
expect($sections)->not->toBeEmpty()
|
// which read a file's raw text rather than its parsed Blade or PHP — still reach them.
|
||||||
->and($sections->filter(fn (SplFileInfo $file): bool => str_contains($file->getContents(), 'medium:'))->isNotEmpty())->toBeTrue();
|
expect($sections)->not->toBeEmpty();
|
||||||
|
|
||||||
|
// The premise itself, proven on a fixture now that plan step 38 has cleared every Tailwind
|
||||||
|
// breakpoint prefix out of the showcase (its own goal, so production content can no longer
|
||||||
|
// carry one): a real file, shaped exactly like a showcase section (an outer heredoc nesting an
|
||||||
|
// inner one, `@php … <<<'BLADE' … BLADE, … @endphp`), still gives up a prefix hiding two
|
||||||
|
// heredocs deep to the same pattern and helper the first test above uses.
|
||||||
|
$directory = sys_get_temp_dir().'/breakpoint-heredoc-probe-'.uniqid();
|
||||||
|
File::ensureDirectoryExists($directory);
|
||||||
|
File::put($directory.'/probe.blade.php', <<<'OUTER'
|
||||||
|
@php
|
||||||
|
$examples = [
|
||||||
|
'Probe' => <<<'BLADE'
|
||||||
|
<div class="md:flex"></div>
|
||||||
|
BLADE,
|
||||||
|
];
|
||||||
|
@endphp
|
||||||
|
OUTER);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pattern = '/(?<![\w@-])(?:max-)?(?:sm|md|lg|xl|2xl):[a-z\[(-]/';
|
||||||
|
$probe = File::allFiles($directory)[0];
|
||||||
|
|
||||||
|
expect(breakpointOffenders($probe, $pattern))->not->toBeEmpty();
|
||||||
|
} finally {
|
||||||
|
File::deleteDirectory($directory);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user