Completed
Push — master ( a85cff...3e66dc )
by Benjamin
03:04
created

WPSiteMonitor::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
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 Tests\Test_Case;
10
use WPSiteMonitor\Settings_Menu;
11
use WPSiteMonitor\WP_Site_Monitor;
12
13
/**
14
 * WP Site Monitor test case.
15
 */
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
	}
51
}
52