Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
68 lines
2.1 KiB
PHP
68 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Tests\Unit\Integrations\Divi;
|
|
|
|
use Brain\Monkey\Functions;
|
|
use LIT\MCP\Integrations\Divi\DiviLogoUsage;
|
|
use LIT\MCP\Integrations\Media\MediaUsageSource;
|
|
use LIT\MCP\Tests\Unit\TestCase;
|
|
|
|
final class DiviLogoUsageTest extends TestCase
|
|
{
|
|
private const POSSIBLE_LOGO = [
|
|
'post_id' => 0,
|
|
'title' => 'Divi-Logo',
|
|
'post_type' => 'option',
|
|
'where' => 'divi_logo',
|
|
'certainty' => 'möglicherweise',
|
|
];
|
|
|
|
private function stub(string $logo, string $file = '2026/09/foto-scaled.jpg'): void
|
|
{
|
|
Functions\when('get_post_meta')->justReturn($file);
|
|
Functions\when('get_option')->alias(
|
|
static fn (string $name): mixed => $name === 'et_divi' ? ['divi_logo' => $logo] : false
|
|
);
|
|
}
|
|
|
|
public function testIsAMediaUsageSource(): void
|
|
{
|
|
self::assertInstanceOf(MediaUsageSource::class, new DiviLogoUsage());
|
|
}
|
|
|
|
public function testTheLogoThatIsTheFileIsAPossibleUsage(): void
|
|
{
|
|
$this->stub('https://k.de/wp-content/uploads/2026/09/foto.jpg');
|
|
|
|
self::assertSame([self::POSSIBLE_LOGO], (new DiviLogoUsage())->usagesOf(33));
|
|
}
|
|
|
|
public function testAGeneratedSizeOfTheFileCountsToo(): void
|
|
{
|
|
$this->stub('https://k.de/wp-content/uploads/2026/09/foto-300x200.jpg');
|
|
|
|
self::assertSame([self::POSSIBLE_LOGO], (new DiviLogoUsage())->usagesOf(33));
|
|
}
|
|
|
|
public function testAnotherFileIsNoUsage(): void
|
|
{
|
|
$this->stub('https://k.de/wp-content/uploads/2026/09/anderes.jpg');
|
|
|
|
self::assertSame([], (new DiviLogoUsage())->usagesOf(33));
|
|
}
|
|
|
|
public function testWithoutALogoOrWithoutAFileThereIsNoUsage(): void
|
|
{
|
|
$this->stub('');
|
|
self::assertSame([], (new DiviLogoUsage())->usagesOf(33));
|
|
|
|
$this->stub('https://k.de/wp-content/uploads/2026/09/foto.jpg', '');
|
|
self::assertSame([], (new DiviLogoUsage())->usagesOf(33));
|
|
|
|
Functions\when('get_option')->justReturn(false);
|
|
self::assertSame([], (new DiviLogoUsage())->usagesOf(33));
|
|
}
|
|
}
|