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>
42 lines
1.3 KiB
PHP
42 lines
1.3 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\DiviFlags;
|
||
use LIT\MCP\Tests\Unit\TestCase;
|
||
use RuntimeException;
|
||
|
||
final class DiviFlagsTest extends TestCase
|
||
{
|
||
public function testSetsBothFlagsAndAcceptsAnUnchangedValue(): void
|
||
{
|
||
$written = [];
|
||
// update_post_meta() is false when the value is already "on" – no failure (ruling S11).
|
||
Functions\when('update_post_meta')->alias(static function (int $id, string $key, string $value) use (&$written): bool {
|
||
$written[] = "$id:$key=$value";
|
||
|
||
return false;
|
||
});
|
||
Functions\when('get_post_meta')->justReturn('on');
|
||
|
||
DiviFlags::set(7);
|
||
|
||
self::assertSame(['7:_et_pb_use_divi_5=on', '7:_et_pb_use_builder=on'], $written);
|
||
}
|
||
|
||
public function testThrowsWhenAFlagDoesNotReadBack(): void
|
||
{
|
||
Functions\when('update_post_meta')->justReturn(true);
|
||
Functions\when('get_post_meta')->alias(
|
||
static fn (int $id, string $key): string => $key === '_et_pb_use_builder' ? 'off' : 'on'
|
||
);
|
||
|
||
$this->expectException(RuntimeException::class);
|
||
$this->expectExceptionMessage('_et_pb_use_builder');
|
||
DiviFlags::set(7);
|
||
}
|
||
}
|