Skip to content

Commit 8ad9f49

Browse files
committed
Fix calculate context unit tests
1 parent e0afb3f commit 8ad9f49

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tests/php/test-fieldmanager-calculate-context.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
* @group context
66
*/
77
class Test_Fieldmanager_Calculate_Context extends WP_UnitTestCase {
8-
protected $screen, $self, $get, $submenus, $post_id;
8+
protected $screen, $self, $get, $submenus;
99

1010
public function setUp() {
11+
parent::setUp();
12+
1113
$this->screen = get_current_screen();
1214
$this->self = isset( $_SERVER['PHP_SELF'] ) ? $_SERVER['PHP_SELF'] : null;
1315
$this->get = $_GET;
1416
$this->submenus = _fieldmanager_registry( 'submenus' );
1517

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-
1818
_fieldmanager_registry( 'submenus', array() );
1919

2020
// Spoof is_admin().
@@ -26,6 +26,8 @@ public function tearDown( $value = null ) {
2626
$_SERVER['PHP_SELF'] = $this->self;
2727
$_GET = $this->get;
2828
_fieldmanager_registry( 'submenus', $this->submenus );
29+
30+
parent::tearDown();
2931
}
3032

3133
/**
@@ -154,7 +156,8 @@ public function test_basic_contexts( $self_override, $get_override, $context, $t
154156

155157
public function test_post_screen_context() {
156158
$_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 ) );
158161
$this->assertEquals( array( 'post', 'page' ), fm_calculate_context() );
159162
$this->_context_action_assertions( 'post', 'page' );
160163
}

0 commit comments

Comments
 (0)