Files
WP-LIT-MCP/tests/Unit/LifecycleTest.php
T
janniclas.loosenandClaude Opus 5.5 7035448f7d feat: clean up own data on deactivation and uninstall
Deactivation now clears the endpoint-check transient and the cached rewrite
rules (forcing WordPress to regenerate them without this plugin's routes on
the next request) and activation asks mcp-oauth to re-flush its own rules.
uninstall.php removes all own options/transient/cron/table across every site
of a network, delegating to the new self-contained LIT\MCP\Uninstaller class
so it works without the plugin's autoloader and is unit-testable on its own.
mcp-oauth's data (JWT secret, rewrite marker, refresh-token meta, application
passwords) is left untouched, as is every post/attachment/revision.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
2026-09-26 04:21:23 +02:00

40 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace LIT\MCP\Tests\Unit;
use Brain\Monkey\Functions;
use LIT\MCP\Lifecycle;
use Mockery;
final class LifecycleTest extends TestCase
{
protected function tearDown(): void
{
unset($GLOBALS['wpdb']);
parent::tearDown();
}
public function testActivateInstallsTableSchedulesCleanupAndRequestsOauthRewriteFlush(): void
{
$GLOBALS['wpdb'] = Mockery::mock(\wpdb::class)->makePartial();
Functions\expect('dbDelta')->once();
Functions\expect('update_option')->once()->with('lit_mcp_db_version', '1');
Functions\when('wp_next_scheduled')->justReturn(false);
Functions\expect('wp_schedule_event')->once();
Functions\expect('delete_option')->once()->with('wpmedia_mcp_oauth_rewrite_version');
Lifecycle::activate();
}
public function testDeactivateRemovesCronTransientAndStoredRewriteRules(): void
{
Functions\expect('wp_clear_scheduled_hook')->once()->with('lit_mcp_log_cleanup');
Functions\expect('delete_transient')->once()->with('lit_mcp_endpoint_check');
Functions\expect('delete_option')->once()->with('rewrite_rules');
Lifecycle::deactivate();
}
}