WordPress „Zusätzliches CSS“ (in Divi „Eigenes CSS“) über die Design-Pipeline: Probelauf mit Zeilen-Diff, design_rev, Bestätigung, Snapshot, Rollback und Wiederherstellen (Bereich custom_css). Der Guard lehnt </style, <script, expression(, javascript: und neue @import ab und warnt bei fremden Hosts; nur Neues zählt, Bestehendes blockiert keine Änderung. Erfordert edit_css und die Divi-Rolle Theme-Anpassung. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
79 lines
3.1 KiB
PHP
79 lines
3.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Tests\Unit;
|
|
|
|
use LIT\MCP\Integrations\Divi\Design\DesignLock;
|
|
use Brain\Monkey\Functions;
|
|
use LIT\MCP\Abilities\ExposurePolicy;
|
|
use LIT\MCP\Access;
|
|
use LIT\MCP\Admin\ConnectionStatus;
|
|
use LIT\MCP\ChangeLog\ChangeLogCleanup;
|
|
use LIT\MCP\ChangeLog\ChangeLogInstaller;
|
|
use LIT\MCP\Integrations\Divi\Release\CheckReportStore;
|
|
use LIT\MCP\Integrations\Divi\Release\DiviCheckRoute;
|
|
use LIT\MCP\Integrations\Divi\Release\ReleaseResolver;
|
|
use LIT\MCP\Integrations\Divi\Release\ReleaseStore;
|
|
use LIT\MCP\Limits;
|
|
use LIT\MCP\Updater\RecheckOnInstall;
|
|
use Mockery;
|
|
|
|
final class UninstallTest extends TestCase
|
|
{
|
|
protected function tearDown(): void
|
|
{
|
|
unset($GLOBALS['wpdb']);
|
|
parent::tearDown();
|
|
}
|
|
|
|
public function testRemovesOnlyOwnDataOnEverySite(): void
|
|
{
|
|
if (! defined('WP_UNINSTALL_PLUGIN')) {
|
|
define('WP_UNINSTALL_PLUGIN', 'WP-LIT-MCP/wp-lit-mcp.php');
|
|
}
|
|
$db = Mockery::mock(\wpdb::class)->makePartial();
|
|
$db->expects('query')->twice()->with('DROP TABLE IF EXISTS wp_lit_mcp_log');
|
|
$GLOBALS['wpdb'] = $db;
|
|
Functions\when('is_multisite')->justReturn(true);
|
|
Functions\when('get_sites')->justReturn([1, 2]);
|
|
Functions\expect('switch_to_blog')->twice();
|
|
Functions\expect('restore_current_blog')->twice();
|
|
$transients = [];
|
|
Functions\when('delete_transient')->alias(static function (string $transient) use (&$transients): bool {
|
|
$transients[] = $transient;
|
|
return true;
|
|
});
|
|
Functions\expect('wp_clear_scheduled_hook')->twice()->with(ChangeLogCleanup::HOOK);
|
|
Functions\expect('delete_metadata')->once()->with('user', 0, 'lit_mcp_log_per_page', '', true);
|
|
$deleted = [];
|
|
Functions\when('delete_option')->alias(static function (string $option) use (&$deleted): bool {
|
|
$deleted[] = $option;
|
|
return true;
|
|
});
|
|
|
|
require dirname(__DIR__, 2) . '/uninstall.php';
|
|
|
|
$own = [
|
|
Access::OPTION, ExposurePolicy::OPTION, Limits::OPTION, ChangeLogInstaller::VERSION_OPTION,
|
|
ReleaseStore::OPTION, CheckReportStore::OPTION, DiviCheckRoute::LOCK,
|
|
'lit_mcp_snapshots_colors', 'lit_mcp_snapshots_variables', 'lit_mcp_snapshots_presets',
|
|
'lit_mcp_snapshots_theme_options', 'lit_mcp_snapshots_custom_css',
|
|
DesignLock::option('colors'), DesignLock::option('variables'), DesignLock::option('presets'), DesignLock::option('custom_css'),
|
|
// Locks of versions before the shared one (audit L5) may still sit in the table.
|
|
'lit_mcp_lock_colors', 'lit_mcp_lock_theme_options',
|
|
RecheckOnInstall::OPTION,
|
|
];
|
|
self::assertSame(array_merge($own, $own), $deleted);
|
|
self::assertNotContains('mcp_jwt_secret', $deleted);
|
|
self::assertNotContains('wpmedia_mcp_oauth_rewrite_version', $deleted);
|
|
self::assertSame(
|
|
[
|
|
ConnectionStatus::ENDPOINT_TRANSIENT, ReleaseResolver::CACHE,
|
|
ConnectionStatus::ENDPOINT_TRANSIENT, ReleaseResolver::CACHE,
|
|
],
|
|
$transients
|
|
);
|
|
}
|
|
}
|