refactor: GlobalUsages sucht über UsageQuery – Bibliothekssuche als LibraryUsageQuery
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
3fe83e39d3
commit
454116851e
@@ -0,0 +1,36 @@
|
||||
<?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"} /-->'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user