feat: DesignSystemWriter – Presets über Divis Sync-Ablauf schreiben (Mirror preset-sync)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
6ee8f9258a
commit
3fe83e39d3
@@ -184,7 +184,10 @@ final class DiviCheckCommandTest extends TestCase
|
||||
|
||||
self::assertSame(0, $code);
|
||||
self::assertSame(
|
||||
['library-submit-layout', 'tb-api-save', 'tb-load-setting-options', 'tb-store-template', 'vb-sync-flags'],
|
||||
[
|
||||
'library-submit-layout', 'preset-sync', 'tb-api-save', 'tb-load-setting-options', 'tb-store-template',
|
||||
'vb-sync-flags',
|
||||
],
|
||||
array_keys(DiviReference::expected($this->expectedFile))
|
||||
);
|
||||
self::assertStringStartsWith(
|
||||
@@ -193,7 +196,7 @@ final class DiviCheckCommandTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/** Minimal stand-ins for the five mirrored Divi functions at their real paths. */
|
||||
/** Minimal stand-ins for the six mirrored Divi functions at their real paths. */
|
||||
private function writeDivi(): void
|
||||
{
|
||||
$files = [
|
||||
@@ -204,6 +207,8 @@ final class DiviCheckCommandTest extends TestCase
|
||||
. "function et_theme_builder_load_template_setting_options( \$ids ) {\n}",
|
||||
'includes/builder-5/server/VisualBuilder/REST/SyncToServer/SyncToServerController.php' =>
|
||||
"class SyncToServerController {\n\tpublic static function update( \$request ) {\n\t}\n}",
|
||||
'includes/builder-5/server/Packages/GlobalData/GlobalPresetController.php' =>
|
||||
"class GlobalPresetController {\n\tpublic static function sync( \$request ) {\n\t}\n}",
|
||||
];
|
||||
foreach ($files as $path => $code) {
|
||||
$file = $this->themeDir . '/' . $path;
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Design;
|
||||
|
||||
use LIT\MCP\Integrations\Divi\Design\DesignSystemWriter;
|
||||
use LIT\MCP\Integrations\Divi\Release\Call;
|
||||
use LIT\MCP\Integrations\Divi\Release\DiviAdapters;
|
||||
use LIT\MCP\Integrations\Divi\Release\DiviLocked;
|
||||
use LIT\MCP\Integrations\Divi\Release\Manifest;
|
||||
use LIT\MCP\Integrations\Divi\Release\ReleaseGate;
|
||||
use LIT\MCP\Integrations\Divi\Release\ReleaseState;
|
||||
use LIT\MCP\Integrations\Divi\Release\ReleaseStatus;
|
||||
use LIT\MCP\Tests\Unit\TestCase;
|
||||
|
||||
final class DesignSystemWriterTest extends TestCase
|
||||
{
|
||||
public function testIsARegisteredDesignAdapterWithTheSyncMirror(): void
|
||||
{
|
||||
$manifest = DesignSystemWriter::manifest();
|
||||
|
||||
self::assertContains(DesignSystemWriter::class, DiviAdapters::CLASSES);
|
||||
self::assertSame(Manifest::DESIGN, $manifest->area);
|
||||
self::assertSame(
|
||||
[
|
||||
'GlobalPreset::get_data()', 'GlobalPreset::prepare_data()', 'GlobalPreset::validate_preset_count()',
|
||||
'GlobalPreset::get_deleted_preset_ids()', 'GlobalPreset::remove_preset_from_legacy_option()',
|
||||
'GlobalPreset::save_data()', 'Conversion::get_preset_attrs_mapping()', 'Conversion::get_preset_attrs()',
|
||||
'UserRole::can_current_user_use_visual_builder()',
|
||||
],
|
||||
array_map(static fn (Call $call): string => $call->label(), $manifest->calls)
|
||||
);
|
||||
self::assertSame(['preset-sync'], array_map(static fn ($mirror): string => $mirror->id, $manifest->mirrors));
|
||||
self::assertSame('GlobalPresetController', $manifest->mirrors[0]->class);
|
||||
}
|
||||
|
||||
public function testWritesNeedAReleasedDivi(): void
|
||||
{
|
||||
ReleaseGate::useResolver(static fn (): ReleaseStatus => new ReleaseStatus(ReleaseState::Untested, '5.16.0'));
|
||||
|
||||
$this->expectException(DiviLocked::class);
|
||||
|
||||
(new DesignSystemWriter())->savePresets(['module' => [], 'group' => []], false);
|
||||
}
|
||||
|
||||
public function testWithoutDiviNobodyUsesTheVisualBuilder(): void
|
||||
{
|
||||
self::assertFalse((new DesignSystemWriter())->canUseVisualBuilder());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user