Passed
Push — master ( d406ab...3befbe )
by Benjamin
02:31
created

WPSiteMonitor::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Class WPSiteMonitorTest
4
 *
5
 * @package WPSiteMonitor
6
 * @since 1.0.0
7
 */
8
9
use WPSiteMonitor\Settings_Menu;
10
use WPSiteMonitor\WP_Site_Monitor;
11
12
/**
13
 * WP Site Monitor test case.
14
 */
15
class WPSiteMonitor extends WP_UnitTestCase {
16
17
	const OPTION_NAME = 'wp_site_monitor_enable';
18
19
	public function setUp() {
20
		parent::setUp();
21
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
	}
51
}
52