' . $inner . ''; } public function testCandidatesContainTheNameAnEscapedSlashOrAnEscapedLetter(): void { $db = Mockery::mock(\wpdb::class); $db->allows('esc_like')->andReturnUsing(static fn (string $text): string => $text); $db->expects('prepare') ->with( '(post_content LIKE %s OR post_content REGEXP %s OR post_content REGEXP %s)', '%divi/button%', 'divi(\\\\/|\\\\u002[fF])button', '\\\\u00[4-7][0-9a-fA-F]' ) ->andReturn('(prepared)'); self::assertSame('(prepared)', (new ModuleUsageQuery('divi/button'))->candidateCondition($db)); } public function testNeedsAFullBlockName(): void { $this->expectException(InvalidArgumentException::class); new ModuleUsageQuery('button'); } public function testMatchesBlocksOfTheModule(): void { $query = new ModuleUsageQuery('divi/button'); self::assertTrue($query->matches(self::page(''))); self::assertTrue($query->matches(self::page(''))); self::assertTrue($query->matches(self::page( '' ))); self::assertFalse($query->matches(self::page(''))); self::assertFalse($query->matches(self::page('')), 'another module name'); self::assertFalse($query->matches('

Kein Divi-Inhalt

')); } public function testGlobalInstancesOfTheModuleCountSoThatTheyAreReportedAsSkipped(): void { $query = new ModuleUsageQuery('divi/button'); self::assertTrue($query->matches(self::page( '' ))); self::assertTrue($query->matches(self::page( '' )), 'an escaped slash decodes to the same name'); self::assertFalse($query->matches(self::page( '' ))); self::assertTrue($query->matches(self::page( '' )), 'Divi 4 conversion: the block itself carries globalModule'); self::assertTrue($query->matches(self::page('')), 'unreadable attributes'); } public function testBrokenMarkupCountsAsUse(): void { self::assertTrue((new ModuleUsageQuery('divi/button'))->matches( '' )); } }