Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Library;
|
|
|
|
use LIT\MCP\Integrations\Divi\Library\LibraryUsageQuery;
|
|
use LIT\MCP\Tests\Unit\TestCase;
|
|
use Mockery;
|
|
|
|
final class LibraryUsageQueryTest extends TestCase
|
|
{
|
|
public function testConditionIsTheFormerCandidateFilter(): void
|
|
{
|
|
$db = Mockery::mock(\wpdb::class);
|
|
$db->allows('esc_like')->andReturnUsing(static fn (string $text): string => $text);
|
|
$db->expects('prepare')
|
|
->with(
|
|
'(LOWER(post_content) LIKE %s OR LOWER(post_content) LIKE %s OR post_content REGEXP %s)',
|
|
'%globalmodule%',
|
|
'%global_module%',
|
|
'\\\\u00[4-7][0-9a-fA-F]'
|
|
)
|
|
->andReturn('(prepared)');
|
|
|
|
self::assertSame('(prepared)', (new LibraryUsageQuery(12))->candidateCondition($db));
|
|
}
|
|
|
|
public function testMatchesThroughTheUsageMatcher(): void
|
|
{
|
|
$query = new LibraryUsageQuery(12);
|
|
|
|
self::assertTrue($query->matches('<!-- wp:divi/section {"globalModule":"12"} /-->'));
|
|
self::assertFalse($query->matches('<!-- wp:divi/section {"globalModule":"13"} /-->'));
|
|
}
|
|
}
|