DiviSaver/DiviWriter/DiviComposition/DiviChange, WpValueSanitizer (S4), WpMediaResolver, DiviFlags (S11), DynamicContentMap from Divi's live registry (S22), S31 wiring, S35 control strip at apply() entry. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
33 lines
1.2 KiB
PHP
33 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Pages;
|
|
|
|
use Brain\Monkey\Functions;
|
|
use LIT\MCP\Integrations\Divi\Pages\WpMediaResolver;
|
|
use LIT\MCP\Tests\Unit\TestCase;
|
|
|
|
final class WpMediaResolverTest extends TestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
Functions\when('wp_attachment_is_image')->alias(static fn (int $id): bool => $id !== 5);
|
|
Functions\when('current_user_can')->alias(static fn (string $cap, int $id): bool => $cap === 'read_post' && $id !== 6);
|
|
Functions\when('wp_get_attachment_url')->alias(static fn (int $id): string|false => $id === 8 ? false : "https://kunde.test/$id.jpg");
|
|
Functions\when('get_post_meta')->justReturn('Alt-Text');
|
|
}
|
|
|
|
public function testReadableImagesOnly(): void
|
|
{
|
|
$media = new WpMediaResolver();
|
|
|
|
self::assertSame(['url' => 'https://kunde.test/33.jpg', 'alt' => 'Alt-Text'], $media->image(33));
|
|
self::assertNull($media->image(0), 'no id');
|
|
self::assertNull($media->image(5), 'no image');
|
|
self::assertNull($media->image(6), 'not readable');
|
|
self::assertNull($media->image(8), 'no url');
|
|
}
|
|
}
|