test: ReferenceUsageQueryTest prüft Parser und Baumdurchlauf ohne Klartext-ID
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
653169a133
commit
e269fcb1f8
@@ -12,8 +12,8 @@ use Mockery;
|
||||
final class ReferenceUsageQueryTest extends TestCase
|
||||
{
|
||||
/** A color reference as post_content holds it: quotes JSON-escaped (formats §2). */
|
||||
private const COLOR_REF = '$variable({"type":"color","value":{"name":'
|
||||
. '"gcid-holz000001","settings":{}}})$';
|
||||
private const COLOR_REF = '$variable({\u0022type\u0022:\u0022color\u0022,\u0022value\u0022:{\u0022name\u0022:'
|
||||
. '\u0022gcid-holz000001\u0022,\u0022settings\u0022:{}}})$';
|
||||
|
||||
public function testCandidatesContainAnIdAnEscapedHyphenOrAnEscapedLetter(): void
|
||||
{
|
||||
@@ -58,10 +58,15 @@ final class ReferenceUsageQueryTest extends TestCase
|
||||
{
|
||||
$query = new ReferenceUsageQuery(['gcid-holz000001']);
|
||||
|
||||
self::assertTrue($query->matches('<!-- wp:divi/text {"x":"gcid-holz000001"} /-->'));
|
||||
self::assertTrue($query->matches('<!-- wp:divi/text {"x":"gcid\u002dholz000001"} /-->'));
|
||||
self::assertTrue($query->matches('<!-- wp:divi/section {"globalModule":"12"} -->'
|
||||
. '<!-- wp:divi/text {"x":"gcid-holz000001"} /--><!-- /wp:divi/section -->'));
|
||||
self::assertFalse($query->matches('<!-- wp:divi/text {"x":"gcid-anders0001"} /-->'));
|
||||
. '<!-- wp:divi/text {"x":"gcid\u002dholz000001"} /--><!-- /wp:divi/section -->'));
|
||||
self::assertFalse($query->matches('<!-- wp:divi/text {"x":"gcid\u002danders0001"} /-->'));
|
||||
// Escaped letter, nested two levels deep inside a global module: only decoded attributes reveal the ID.
|
||||
$nested = '<!-- wp:divi/section {"globalModule":"12"} --><!-- wp:divi/row --><!-- wp:divi/text '
|
||||
. '{"x":"\u0067cid-holz000001"} /--><!-- /wp:divi/row --><!-- /wp:divi/section -->';
|
||||
self::assertStringNotContainsString('gcid-holz000001', $nested);
|
||||
self::assertTrue($query->matches($nested));
|
||||
}
|
||||
|
||||
public function testUnreadableMarkupAndDivi4ContentCount(): void
|
||||
@@ -69,7 +74,8 @@ final class ReferenceUsageQueryTest extends TestCase
|
||||
$query = new ReferenceUsageQuery(['gcid-holz000001']);
|
||||
|
||||
self::assertTrue($query->matches('<!-- wp:divi/section --><!-- wp:divi/text {"x":1} /-->'), 'never closed');
|
||||
self::assertTrue($query->matches('<!-- wp:divi/text {"x":"gcid-holz000001",} /-->'), 'attrs no JSON');
|
||||
self::assertTrue($query->matches('<!-- wp:divi/text {"x":"gcid\u002dholz000001",} /-->'), 'attrs no JSON');
|
||||
self::assertTrue($query->matches('<!-- wp:divi/text {"x":"\u0067cid-holz000001",} /-->'), 'no JSON, no raw ID');
|
||||
self::assertTrue($query->matches('[et_pb_text background_color="gcid-holz000001"]x[/et_pb_text]'), 'Divi 4');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user