根据this test, 您使用set_current_screen()
导航到one of these 在setUp
方法
唉,如果您查看非常有用的参考页get_current_screen()...
示例:
<?php
class AxisSetupTest extends WP_UnitTestCase {
/**
* @covers AxisWP::__construct
*/
function test_constructor() {
// Assert
// Admin
$this->assertInternalType(\'integer\', has_action( \'admin_enqueue_scripts\', array( \'AxisWP\', \'add_admin_stylesheet\' ) ) );
}
public function setUp() {
parent::setUp();
$user_id = $this->factory->user->create( array( \'role\' => \'administrator\' ) );
$user = wp_set_current_user( $user_id );
// This is the key here.
set_current_screen( \'edit-post\' );
}
public function tearDown() {
parent::tearDown();
}
}