| Total Complexity | 3 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | class WPSiteMonitor extends Test_Case { |
||
| 17 | |||
| 18 | public function setUp() { |
||
| 19 | parent::setUp(); |
||
| 20 | |||
| 21 | new WP_Site_Monitor(); |
||
| 22 | (new Settings_Menu)->init_settings(); |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Assert that the plugin settings are unregistered on plugin deactivation. |
||
| 27 | */ |
||
| 28 | public function test_settings_unregistered_when_plugin_deactivated() { |
||
| 29 | global $wp_registered_settings; |
||
| 30 | |||
| 31 | $this->assertArrayHasKey(self::OPTION_NAME, $wp_registered_settings ); |
||
| 32 | |||
| 33 | WP_Site_Monitor::deactivate(); |
||
| 34 | |||
| 35 | $this->assertArrayNotHasKey(self::OPTION_NAME, $wp_registered_settings ); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Assert that the plugin settings are removed on plugin uninstall. |
||
| 40 | */ |
||
| 41 | public function test_settings_removed_on_plugin_uninstall() { |
||
| 42 | global $wpdb; |
||
| 43 | update_option( self::OPTION_NAME, 1 ); |
||
| 44 | |||
| 45 | WP_Site_Monitor::uninstall(); |
||
| 46 | |||
| 47 | $option = self::OPTION_NAME; |
||
| 48 | $row = $wpdb->get_row( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) ); |
||
| 49 | $this->assertNull( $row ); |
||
| 50 | } |
||
| 52 |