5
5
* @group context
6
6
*/
7
7
class Test_Fieldmanager_Calculate_Context extends WP_UnitTestCase {
8
- protected $ screen , $ self , $ get , $ submenus, $ post_id ;
8
+ protected $ screen , $ self , $ get , $ submenus ;
9
9
10
10
public function setUp () {
11
+ parent ::setUp ();
12
+
11
13
$ this ->screen = get_current_screen ();
12
14
$ this ->self = isset ( $ _SERVER ['PHP_SELF ' ] ) ? $ _SERVER ['PHP_SELF ' ] : null ;
13
15
$ this ->get = $ _GET ;
14
16
$ this ->submenus = _fieldmanager_registry ( 'submenus ' );
15
17
16
- $ this ->post_id = $ this ->factory ->post ->create ( array ( 'post_title ' => rand_str (), 'post_date ' => '2015-07-01 00:00:00 ' , 'post_type ' => 'page ' ) );
17
-
18
18
_fieldmanager_registry ( 'submenus ' , array () );
19
19
20
20
// Spoof is_admin().
@@ -26,6 +26,8 @@ public function tearDown( $value = null ) {
26
26
$ _SERVER ['PHP_SELF ' ] = $ this ->self ;
27
27
$ _GET = $ this ->get ;
28
28
_fieldmanager_registry ( 'submenus ' , $ this ->submenus );
29
+
30
+ parent ::tearDown ();
29
31
}
30
32
31
33
/**
@@ -154,7 +156,8 @@ public function test_basic_contexts( $self_override, $get_override, $context, $t
154
156
155
157
public function test_post_screen_context () {
156
158
$ _SERVER ['PHP_SELF ' ] = '/post.php ' ;
157
- $ _GET = array ( 'post ' => strval ( $ this ->post_id ) );
159
+ $ post_id = $ this ->factory ->post ->create ( array ( 'post_title ' => rand_str (), 'post_date ' => '2015-07-01 00:00:00 ' , 'post_type ' => 'page ' ) );
160
+ $ _GET = array ( 'post ' => strval ( $ post_id ) );
158
161
$ this ->assertEquals ( array ( 'post ' , 'page ' ), fm_calculate_context () );
159
162
$ this ->_context_action_assertions ( 'post ' , 'page ' );
160
163
}
0 commit comments