docs: Guides korrigiert (not_found, Snapshot-Gesamtgrenze, Schleifen-Warnungen) und LoopGuideTest enger an den Code gebunden
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
fc35cbe9dd
commit
52208764f0
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Tests\Unit\Guides;
|
||||
|
||||
use LIT\MCP\Integrations\Divi\Compose\Placeholders;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
@@ -53,16 +54,22 @@ final class LoopGuideTest extends TestCase
|
||||
|
||||
public function testRefusalPhrasesAreTheOnesTheCodeSays(): void
|
||||
{
|
||||
// Only string literals count (no comments), matched exactly including case.
|
||||
$code = '';
|
||||
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(self::root() . '/src'));
|
||||
foreach ($files as $file) {
|
||||
if (str_ends_with((string) $file, '.php')) {
|
||||
$code .= (string) file_get_contents((string) $file);
|
||||
if (! str_ends_with((string) $file, '.php')) {
|
||||
continue;
|
||||
}
|
||||
foreach (token_get_all((string) file_get_contents((string) $file)) as $token) {
|
||||
if (is_array($token) && in_array($token[0], [T_CONSTANT_ENCAPSED_STRING, T_ENCAPSED_AND_WHITESPACE], true)) {
|
||||
$code .= $token[1] . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (self::PHRASES as $phrase) {
|
||||
self::assertNotFalse(mb_stripos($code, $phrase), 'no source says "' . $phrase . '"');
|
||||
self::assertNotFalse(mb_strpos($code, $phrase), 'no source string says "' . $phrase . '"');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +79,7 @@ final class LoopGuideTest extends TestCase
|
||||
self::assertNotEmpty($examples[1], 'the guides show no {{loop:…}} example');
|
||||
foreach (array_unique($examples[1]) as $name) {
|
||||
self::assertContains('loop_' . $name, self::DIVI_LOOP_OPTIONS, '{{loop:' . $name . '}} is no Divi option');
|
||||
self::assertSame('loop_' . $name, Placeholders::LOOP[$name] ?? null, '{{loop:' . $name . '}} is not in Placeholders::LOOP');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user