Content => whether it shows entry 123. */ public static function contents(): array { $escapedKey = '"' . self::u('0067') . 'lobalModule"'; return [ 'divi 5 canonical' => ['', true], 'divi 5 leading zeros' => ['', true], 'divi 5 escaped key' => ['', true], 'divi 5 escaped value' => [ '', true, ], 'divi 5 escaped key with leading zeros' => [ '', true, ], 'divi 5 another entry' => ['', false], 'divi 5 escaped key, another entry' => ['', false], 'divi 5 id in local attributes' => [ '', true, ], 'divi 4 double quotes' => ['[et_pb_section global_module="123"][/et_pb_section]', true], 'divi 4 single quotes and zeros' => ["[et_pb_text global_module='0123']x[/et_pb_text]", true], 'divi 4 unquoted' => ['[et_pb_row global_module=123 admin_label="x"][/et_pb_row]', true], 'divi 4 typographic quotes' => ['[et_pb_row global_module=' . "\u{201D}" . '123' . "\u{201D}" . '][/et_pb_row]', true], 'divi 4 another entry' => ['[et_pb_section global_module="1230"][/et_pb_section]', false], 'undecodable escaped opener' => [ '', true, ], 'undecodable escaped opener naming nothing readable' => [ '', true, ], 'escaped markup only' => [ '', false, ], 'plain page' => ['', false], // Ruling P24 G1: a Divi 4 shortcode inside a Divi 5 attribute value (quotes serialized as escapes). 'shortcode in a divi 5 text value' => [self::inText('[et_pb_section global_module=' . self::u('0022') . '123' . self::u('0022') . '][/et_pb_section]'), true], 'shortcode in a divi 5 text value, another entry' => [self::inText('[et_pb_section global_module=' . self::u('0022') . '124' . self::u('0022') . '][/et_pb_section]'), false], 'shortcode in a divi 5 text value, escaped digits' => [self::inText('[et_pb_section global_module=' . self::u('0022') . self::u('0031') . self::u('0032') . '3' . self::u('0022') . '][/et_pb_section]'), true], // G2: parsed like shortcode_parse_atts, cast with (int) like Divi. 'divi 4 leading space' => ['[et_pb_section global_module=" 123"][/et_pb_section]', true], 'divi 4 exponent' => ['[et_pb_section global_module="1.23e2"][/et_pb_section]', true], 'divi 4 upper-case attribute' => ['[et_pb_section GLOBAL_MODULE="123"][/et_pb_section]', true], 'divi 4 zero renders nothing' => ['[et_pb_section global_module="0"][/et_pb_section]', false], 'divi 4 empty renders nothing' => ['[et_pb_section global_module=""][/et_pb_section]', false], 'global_module as plain text' => ['

global_module="123" steht hier nur als Text

', false], ]; } /** A Divi 5 text module whose content value holds $text, JSON-encoded like WordPress does. */ private static function inText(string $text): string { return ''; } /** * Ruling P24 G3: a global_module Divi casts to 0 renders the newest library or TB layout * (et_pb_load_global_module, WP_Query p=0) – a reference to every entry. * * @return array */ public static function wildcards(): array { return [ 'entity before the id' => ['[et_pb_section global_module=""123"][/et_pb_section]'], 'letters' => ['[et_pb_row global_module="abc"][/et_pb_row]'], 'typographic quotes' => ['[et_pb_row global_module=' . "\u{201D}" . '123' . "\u{201D}" . '][/et_pb_row]'], 'double zero' => ['[et_pb_row global_module="00"][/et_pb_row]'], 'inside a divi 5 value' => [self::inText('[et_pb_text global_module=' . self::u('0022') . 'x' . self::u('0022') . ']a[/et_pb_text]')], ]; } /** @dataProvider wildcards */ public function testAValueThatCastsToZeroShowsEveryEntry(string $content): void { self::assertTrue(UsageMatcher::shows($content, 123)); self::assertTrue(UsageMatcher::shows($content, 98765)); } /** @dataProvider contents */ public function testFindsEveryReferenceDiviRenders(string $content, bool $shows): void { self::assertSame($shows, UsageMatcher::shows($content, 123)); } /** * Ruling Q7: referencesAny() refuses every reference Divi renders, to any entry – what shows() finds for * some ID, and the values that cast to 0 (the newest layout – possibly the entry being created). * * @dataProvider contents */ public function testReferencesAnyFindsEveryReferenceToAnyEntry(string $content, bool $shows): void { $any = UsageMatcher::shows($content, 123) || UsageMatcher::shows($content, 124) || UsageMatcher::shows($content, 1234) || UsageMatcher::shows($content, 1230); self::assertSame($any, UsageMatcher::referencesAny($content)); } /** @dataProvider wildcards */ public function testReferencesAnyFindsValuesThatCastToZero(string $content): void { self::assertTrue(UsageMatcher::referencesAny($content)); } /** @return array */ public static function anyContents(): array { return [ 'divi 5 non-numeric id' => ['', true], 'divi 5 numeric id' => ['', true], 'divi 5 textual id in raw text' => ['

"globalModule":"9"

', true], 'divi 4 other tag' => ['[et_pb_blurb global_module="55"][/et_pb_blurb]', true], 'divi 4 zero' => ['[et_pb_section global_module="0"][/et_pb_section]', false], 'plain text' => ['', false], ]; } /** @dataProvider anyContents */ public function testReferencesAnyFailsClosed(string $content, bool $references): void { self::assertSame($references, UsageMatcher::referencesAny($content)); } public function testTheEscapeBytesAreReal(): void { self::assertSame(6, strlen(self::u('0067'))); self::assertSame(92, ord(self::u('0067')[0])); } }