feat: Fundstellen aller Module eines Typs, Standard-Gruppen-Presets in der Fundstellensuche (ModuleUsageQuery)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Jan-Niclas Loosen
2026-10-18 16:55:54 +02:00
co-authored by Claude Sonnet 5.5
parent 1f9b50f1a6
commit 763d765660
11 changed files with 329 additions and 23 deletions
@@ -62,4 +62,37 @@ final class PresetUsageQueryTest extends TestCase
new PresetUsageQuery([]);
}
public function testADefaultGroupPresetLooksForEveryDiviBlock(): void
{
$db = Mockery::mock(\wpdb::class);
$db->allows('esc_like')->andReturnUsing(static fn (string $text): string => $text);
$db->expects('prepare')
->with(
'(post_content LIKE %s OR post_content LIKE %s OR post_content REGEXP %s)',
'%gggggggggg%',
'%wp:divi/%',
'\\\\u00[4-7][0-9a-fA-F]'
)
->andReturn('(prepared)');
$query = new PresetUsageQuery([
['scope' => new PresetScope('group', 'divi/font-body'), 'id' => 'gggggggggg', 'default' => true],
]);
self::assertSame('(prepared)', $query->candidateCondition($db));
}
public function testWithGroupsDetectsTheImplicitUseOfADefaultGroupPreset(): void
{
$query = PresetUsageQuery::withGroups(
[['scope' => new PresetScope('group', 'divi/font-body'), 'id' => 'gggggggggg', 'default' => true]],
static fn (string $module): array => $module === 'divi/text'
? ['content.decoration.bodyFont' => 'divi/font-body']
: []
);
self::assertTrue($query->matches('<!-- wp:divi/text {} /-->'));
self::assertFalse($query->matches('<!-- wp:divi/button {} /-->'));
}
}