*/
public static function contents(): array
{
$certain = MediaUsageFinder::CERTAIN;
$possible = MediaUsageFinder::POSSIBLE;
return [
'wp-image class' => ['
', $certain],
'other wp-image id' => ['
', null],
'gallery shortcode' => ['[gallery ids="1, 33,5"]', $certain],
'divi 4 gallery_ids' => ['[et_pb_gallery gallery_ids="12,33"]', $certain],
'core image block' => ['', $certain],
'core gallery ids' => ['', $certain],
'divi 5 image id' => ['', $certain],
'divi 5 galleryIds' => ['', $certain],
'id outside a media block' => ['', null],
'file url only' => ['
', $possible],
'json-escaped file url' => ['{"src":"\/uploads\/2026\/09\/foto.jpg"}', $possible],
'other file' => ['
', null],
];
}
/** @dataProvider contents */
public function testCertaintyOfStoredContent(string $content, ?string $expected): void
{
$fileRegex = ContentMediaReferences::fileRegex('2026/09/foto');
self::assertSame($expected, ContentMediaReferences::certainty($content, 33, $fileRegex));
}
public function testListsAndLeaves(): void
{
self::assertTrue(ContentMediaReferences::inList(['1, 2', ' 33 '], 33));
self::assertFalse(ContentMediaReferences::inList(['1,333', 'x33'], 33));
self::assertSame(['1', '33', '7'], ContentMediaReferences::stringLeaves(['1', [33, ['7', null, 2.5]]]));
self::assertFalse(ContentMediaReferences::matches(null, 'anything'));
}
}