void solution.
<?phpabstract class WP_Test_REST_Controller_Testcase extends WP_Test_REST_TestCase {protected $server;public function set_up() {parent::set_up();add_filter( 'rest_url', array( $this, 'filter_rest_url_for_leading_slash' ), 10, 2 );/** @var WP_REST_Server $wp_rest_server */global $wp_rest_server;$wp_rest_server = new Spy_REST_Server;do_action( 'rest_api_init', $wp_rest_server );}public function tear_down() {remove_filter( 'rest_url', array( $this, 'test_rest_url_for_leading_slash' ), 10, 2 );/** @var WP_REST_Server $wp_rest_server */global $wp_rest_server;$wp_rest_server = null;parent::tear_down();}abstract public function test_register_routes();abstract public function test_context_param();abstract public function test_get_items();abstract public function test_get_item();abstract public function test_create_item();abstract public function test_update_item();abstract public function test_delete_item();abstract public function test_prepare_item();abstract public function test_get_item_schema();public function filter_rest_url_for_leading_slash( $url, $path ) {if ( is_multisite() || get_option( 'permalink_structure' ) ) {return $url;}// Make sure path for rest_url has a leading slash for proper resolution.$this->assertTrue( 0 === strpos( $path, '/' ), 'REST API URL should have a leading slash.' );return $url;}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。