PluginProbe
Simple Analytics / 1.110
Simple Analytics v1.110
1.110 1.109 1.108 1.107 1.106 1.73 1.74 1.75 1.76 1.77 1.78 1.79 1.8 1.80 1.81 1.82 1.83 1.84 1.85 1.86 1.87 1.88 1.89 1.9 1.90 All 99 releases
simpleanalytics / tests / Regression / deactivation.php

deactivation.php in Simple Analytics 1.110, at tests/Regression/deactivation.php

35 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 require __DIR__ . '/../Support/isolated-options.php';
4
5 sa_with_isolated_options(static function () {
6 $plugin = SimpleAnalytics\PLUGIN_BASENAME;
7 $values = [
8 SimpleAnalytics\SettingName::CUSTOM_DOMAIN => 'stats.example.test',
9 SimpleAnalytics\SettingName::EXCLUDED_IP_ADDRESSES => ['203.0.113.10'],
10 SimpleAnalytics\SettingName::EXCLUDED_ROLES => ['administrator'],
11 SimpleAnalytics\SettingName::MANUAL_COLLECT => '1',
12 ];
13 foreach ($values as $key => $value) update_option($key, $value);
14
15 deactivate_plugins($plugin, false, false);
16 sa_assert(! is_plugin_active($plugin), 'The plugin must be deactivated for this test.');
17 foreach ($values as $key => $value) {
18 sa_assert(get_option($key) === $value, 'Deactivation deleted ' . $key);
19 }
20
21 // The plugin is already loaded in this process; fire WordPress's activation
22 // hook directly to verify that activation retains the existing options.
23 do_action('activate_' . $plugin, false);
24 foreach ($values as $key => $value) {
25 sa_assert(get_option($key) === $value, 'Reactivation changed ' . $key);
26 }
27
28 update_option('sa_unrelated_test_option', 'keep');
29 uninstall_plugin($plugin);
30 foreach (SimpleAnalytics\SettingName::cases() as $key) {
31 sa_assert(get_option($key, 'missing') === 'missing', 'Uninstall did not remove ' . $key);
32 }
33 sa_assert(get_option('sa_unrelated_test_option') === 'keep', 'Uninstall must retain unrelated options.');
34 });
35