- m-1: the no-change Divi result carries preview_url/edit_url too - m-2: overview names replace-text's per-page tree_rev - m-3: divi-shortform documents validation_failed vs not_found for unknown IDs - m-4: DiviWriter/DiviPageLoader final (no mocks left), neutral NewDraft log detail, snapshots are Etappe 4 - m-5: Tested up to 7.1, changelog completed - m-6: content-create warns when the extras changed the stored layout - m-7: deleting a whole section outlines nothing instead of the next one - m-8: uninstall removes the user meta lit_mcp_log_per_page; readme lists it Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
53 lines
1.9 KiB
PHP
53 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Tests\Unit;
|
|
|
|
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\Limits;
|
|
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();
|
|
Functions\expect('delete_transient')->twice()->with(ConnectionStatus::ENDPOINT_TRANSIENT);
|
|
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];
|
|
self::assertSame(array_merge($own, $own), $deleted);
|
|
self::assertNotContains('mcp_jwt_secret', $deleted);
|
|
self::assertNotContains('wpmedia_mcp_oauth_rewrite_version', $deleted);
|
|
}
|
|
}
|