12
12
*/
13
13
class Branding_ConstructTest extends WP_UnitTestCase {
14
14
/**
15
- * Test that hooks are added when API rewriting is enabled.
15
+ * Test that hooks are added when API rewriting is enabled in single site .
16
16
*
17
- * @dataProvider data_hooks_and_methods
17
+ * @dataProvider data_single_site_hooks_and_methods
18
+ *
19
+ * @group ms-excluded
18
20
*
19
21
* @runInSeparateProcess
20
22
* @preserveGlobalState disabled
21
23
*
22
24
* @string $hook The hook's name.
23
25
* @string $method The method to hook.
24
26
*/
25
- public function test_should_add_hooks ( $ hook , $ method ) {
27
+ public function test_should_add_hooks_in_single_site ( $ hook , $ method ) {
26
28
define ( 'AP_ENABLE ' , true );
27
29
28
30
$ branding = new AspireUpdate \Branding ();
29
31
$ this ->assertIsInt ( has_action ( $ hook , [ $ branding , $ method ] ) );
30
32
}
31
33
32
34
/**
33
- * Test that hooks are not added when API rewriting is disabled.
35
+ * Test that hooks are not added when API rewriting is disabled in single-site.
36
+ *
37
+ * @dataProvider data_single_site_hooks_and_methods
34
38
*
35
- * @dataProvider data_hooks_and_methods
39
+ * @group ms-excluded
36
40
*
37
41
* @runInSeparateProcess
38
42
* @preserveGlobalState disabled
39
43
*
40
44
* @string $hook The hook's name.
41
45
* @string $method The method to hook.
42
46
*/
43
- public function test_should_not_add_hooks ( $ hook , $ method ) {
47
+ public function test_should_not_add_hooks_in_single_site ( $ hook , $ method ) {
44
48
define ( 'AP_ENABLE ' , false );
45
49
46
50
$ branding = new AspireUpdate \Branding ();
@@ -52,7 +56,7 @@ public function test_should_not_add_hooks( $hook, $method ) {
52
56
*
53
57
* @return array[]
54
58
*/
55
- public function data_hooks_and_methods () {
59
+ public function data_single_site_hooks_and_methods () {
56
60
return [
57
61
'admin_notices -> output_admin_notice ' => [
58
62
'hook ' => 'admin_notices ' ,
@@ -64,4 +68,62 @@ public function data_hooks_and_methods() {
64
68
],
65
69
];
66
70
}
71
+
72
+ /**
73
+ * Test that hooks are added when API rewriting is enabled in multisite.
74
+ *
75
+ * @dataProvider data_multisite_hooks_and_methods
76
+ *
77
+ * @group ms-required
78
+ *
79
+ * @runInSeparateProcess
80
+ * @preserveGlobalState disabled
81
+ *
82
+ * @string $hook The hook's name.
83
+ * @string $method The method to hook.
84
+ */
85
+ public function test_should_add_hooks_in_multisite ( $ hook , $ method ) {
86
+ define ( 'AP_ENABLE ' , true );
87
+
88
+ $ branding = new AspireUpdate \Branding ();
89
+ $ this ->assertIsInt ( has_action ( $ hook , [ $ branding , $ method ] ) );
90
+ }
91
+
92
+ /**
93
+ * Test that hooks are not added when API rewriting is disabled in multisite.
94
+ *
95
+ * @dataProvider data_multisite_hooks_and_methods
96
+ *
97
+ * @group ms-required
98
+ *
99
+ * @runInSeparateProcess
100
+ * @preserveGlobalState disabled
101
+ *
102
+ * @string $hook The hook's name.
103
+ * @string $method The method to hook.
104
+ */
105
+ public function test_should_not_add_hooks_in_multisite ( $ hook , $ method ) {
106
+ define ( 'AP_ENABLE ' , false );
107
+
108
+ $ branding = new AspireUpdate \Branding ();
109
+ $ this ->assertFalse ( has_action ( $ hook , [ $ branding , $ method ] ) );
110
+ }
111
+
112
+ /**
113
+ * Data provider.
114
+ *
115
+ * @return array[]
116
+ */
117
+ public function data_multisite_hooks_and_methods () {
118
+ return [
119
+ 'network_admin_notices -> output_admin_notice ' => [
120
+ 'hook ' => 'network_admin_notices ' ,
121
+ 'method ' => 'output_admin_notice ' ,
122
+ ],
123
+ 'admin_enqueue_scripts -> admin_enqueue_scripts ' => [
124
+ 'hook ' => 'admin_enqueue_scripts ' ,
125
+ 'method ' => 'admin_enqueue_scripts ' ,
126
+ ],
127
+ ];
128
+ }
67
129
}
0 commit comments