diff --git a/src/Integrations/Divi/Design/DesignRights.php b/src/Integrations/Divi/Design/DesignRights.php index 1ae3869..aaf8c1d 100644 --- a/src/Integrations/Divi/Design/DesignRights.php +++ b/src/Integrations/Divi/Design/DesignRights.php @@ -79,10 +79,10 @@ final class DesignRights } /** - * Theme options (writing and restoring): edit_theme_options and Divi's role right "Theme-Anpassung". $writer is - * not asked – Divi's customizer needs no Visual Builder; it keeps the signature of the other design rights. + * Theme options (writing and restoring): edit_theme_options and Divi's role right "Theme-Anpassung". Divi's + * customizer needs no Visual Builder, so no DesignSystemWriter is asked. */ - public static function themeOptions(DesignSystemWriter $writer, ThemeOptionsAdapter $options): ?WP_Error + public static function themeOptions(ThemeOptionsAdapter $options): ?WP_Error { $refusal = self::themeRight('Theme-Optionen ändern'); if ($refusal !== null || $options->canCustomize()) { diff --git a/src/Integrations/Divi/Design/DiviThemeOptionsUpdateAbility.php b/src/Integrations/Divi/Design/DiviThemeOptionsUpdateAbility.php index 21518c2..6eb6d51 100644 --- a/src/Integrations/Divi/Design/DiviThemeOptionsUpdateAbility.php +++ b/src/Integrations/Divi/Design/DiviThemeOptionsUpdateAbility.php @@ -29,7 +29,6 @@ final class DiviThemeOptionsUpdateAbility implements Ability, RequiresDiviFeatur private const BUILDER = 'Geänderte Schriften wirken auch im Divi-Builder (Standardschrift der Module).'; public function __construct( - private DesignSystemWriter $writer, private ThemeOptionsAdapter $options, private FontCatalog $fonts, private DesignChange $change @@ -102,12 +101,12 @@ final class DiviThemeOptionsUpdateAbility implements Ability, RequiresDiviFeatur public function permission(array $input): bool|WP_Error { - return DesignRights::themeOptions($this->writer, $this->options) ?? true; + return DesignRights::themeOptions($this->options) ?? true; } public function execute(array $input): mixed { - $refusal = DesignRights::themeOptions($this->writer, $this->options); + $refusal = DesignRights::themeOptions($this->options); if ($refusal !== null) { return $refusal; } diff --git a/src/Integrations/Divi/Design/ThemeOptionsRestorePlanner.php b/src/Integrations/Divi/Design/ThemeOptionsRestorePlanner.php index e0365ff..63b7697 100644 --- a/src/Integrations/Divi/Design/ThemeOptionsRestorePlanner.php +++ b/src/Integrations/Divi/Design/ThemeOptionsRestorePlanner.php @@ -18,7 +18,7 @@ final class ThemeOptionsRestorePlanner implements RestorePlanner { private const RESET = 'Theme-Optionen, die im Snapshot nicht gesetzt sind, kehren zum Divi-Standard zurück (%s).'; - public function __construct(private DesignSystemWriter $writer, private ThemeOptionsAdapter $options) + public function __construct(private ThemeOptionsAdapter $options) { } @@ -34,7 +34,7 @@ final class ThemeOptionsRestorePlanner implements RestorePlanner public function rights(): ?WP_Error { - return DesignRights::themeOptions($this->writer, $this->options); + return DesignRights::themeOptions($this->options); } /** Like lit/divi-theme-options-update: reads et_divi (ThemeOptionRead), writes it (ThemeOptionWrite). */ diff --git a/src/Integrations/Divi/DiviIntegration.php b/src/Integrations/Divi/DiviIntegration.php index dcc3f7e..2a83d4e 100644 --- a/src/Integrations/Divi/DiviIntegration.php +++ b/src/Integrations/Divi/DiviIntegration.php @@ -299,7 +299,7 @@ final class DiviIntegration implements Integration, Bootable new PresetRestorePlanner($this->designWriter, DesignRights::unfilteredHtml()), new ColorRestorePlanner($this->designWriter, $this->colorsAdapter), new VariableRestorePlanner($this->designWriter, $this->variablesAdapter), - new ThemeOptionsRestorePlanner($this->designWriter, $this->themeOptionsAdapter) + new ThemeOptionsRestorePlanner($this->themeOptionsAdapter) ), new DiviPresetsAssignAbility( $this->designWriter, @@ -329,7 +329,6 @@ final class DiviIntegration implements Integration, Bootable ), new DiviThemeOptionsGetAbility($this->themeOptionsAdapter), new DiviThemeOptionsUpdateAbility( - $this->designWriter, $this->themeOptionsAdapter, $this->fontCatalog, $this->designChange() diff --git a/tests/Unit/Integrations/Divi/Design/DesignRightsTest.php b/tests/Unit/Integrations/Divi/Design/DesignRightsTest.php index 7857e7b..3417641 100644 --- a/tests/Unit/Integrations/Divi/Design/DesignRightsTest.php +++ b/tests/Unit/Integrations/Divi/Design/DesignRightsTest.php @@ -78,21 +78,18 @@ final class DesignRightsTest extends TestCase public function testThemeOptionsNeedEditThemeOptionsAndTheThemeCustomizerRight(): void { - $writer = Mockery::mock(DesignSystemWriter::class); - // Divi's customizer does not need the Visual Builder (plan 4d, rights). - $writer->expects('canUseVisualBuilder')->never(); $options = Mockery::mock(ThemeOptionsAdapter::class); $options->allows('canCustomize')->andReturn(true, false); Functions\when('current_user_can')->alias(static fn (string $cap): bool => $cap === 'edit_theme_options'); - self::assertNull(DesignRights::themeOptions($writer, $options)); - $refusal = self::assertToolError(DesignRights::themeOptions($writer, $options), 'forbidden'); + self::assertNull(DesignRights::themeOptions($options)); + $refusal = self::assertToolError(DesignRights::themeOptions($options), 'forbidden'); self::assertStringContainsString('Theme-Anpassung', $refusal['message']); self::assertStringContainsString('keine Theme-Optionen', $refusal['message']); self::assertStringContainsString('Rollen-Editor', $refusal['hint']); Functions\when('current_user_can')->justReturn(false); - $refusal = self::assertToolError(DesignRights::themeOptions($writer, $options), 'forbidden'); + $refusal = self::assertToolError(DesignRights::themeOptions($options), 'forbidden'); self::assertStringContainsString('Theme-Optionen ändern erfordert', $refusal['message']); self::assertStringContainsString('edit_theme_options', $refusal['message']); } diff --git a/tests/Unit/Integrations/Divi/Design/DiviDesignRestoreAbilityTest.php b/tests/Unit/Integrations/Divi/Design/DiviDesignRestoreAbilityTest.php index c5b6181..5503aab 100644 --- a/tests/Unit/Integrations/Divi/Design/DiviDesignRestoreAbilityTest.php +++ b/tests/Unit/Integrations/Divi/Design/DiviDesignRestoreAbilityTest.php @@ -179,7 +179,7 @@ final class DiviDesignRestoreAbilityTest extends TestCase new PresetRestorePlanner($writer), new ColorRestorePlanner($writer, $colors), new VariableRestorePlanner($writer, $variables), - new ThemeOptionsRestorePlanner($writer, $options ?? self::optionStore($noOptions)) + new ThemeOptionsRestorePlanner($options ?? self::optionStore($noOptions)) ); } diff --git a/tests/Unit/Integrations/Divi/Design/DiviThemeOptionsUpdateAbilityTest.php b/tests/Unit/Integrations/Divi/Design/DiviThemeOptionsUpdateAbilityTest.php index ae5371a..ba4ddcf 100644 --- a/tests/Unit/Integrations/Divi/Design/DiviThemeOptionsUpdateAbilityTest.php +++ b/tests/Unit/Integrations/Divi/Design/DiviThemeOptionsUpdateAbilityTest.php @@ -49,11 +49,7 @@ final class DiviThemeOptionsUpdateAbilityTest extends TestCase bool $customize = true, ?ThemeOptionsAdapter $options = null ): DiviThemeOptionsUpdateAbility { - $writer = Mockery::mock(DesignSystemWriter::class); - $writer->allows('canUseVisualBuilder')->andReturn(true); - return new DiviThemeOptionsUpdateAbility( - $writer, $options ?? ThemeOptionsAreaTest::adapter($this->stored, $this->writes, $sanitize, $customize), FontCheckTest::catalog(), new DesignChange($snapshots ?? Mockery::mock(SnapshotStore::class), new FakeChangeLog(3)) diff --git a/tests/Unit/Integrations/Divi/Design/ThemeOptionsRestorePlannerTest.php b/tests/Unit/Integrations/Divi/Design/ThemeOptionsRestorePlannerTest.php index e6c0cd7..c49b83b 100644 --- a/tests/Unit/Integrations/Divi/Design/ThemeOptionsRestorePlannerTest.php +++ b/tests/Unit/Integrations/Divi/Design/ThemeOptionsRestorePlannerTest.php @@ -36,13 +36,8 @@ final class ThemeOptionsRestorePlannerTest extends TestCase { $stored = []; $writes = []; - $writer = Mockery::mock(DesignSystemWriter::class); - $writer->allows('canUseVisualBuilder')->andReturn(true); - return new ThemeOptionsRestorePlanner( - $writer, - ThemeOptionsAreaTest::adapter($stored, $writes, null, $customize) - ); + return new ThemeOptionsRestorePlanner(ThemeOptionsAreaTest::adapter($stored, $writes, null, $customize)); } public function testAreaFeaturesAndDesignArea(): void