public function setUp() { parent::setUp(); $this->has_setup_template = false; add_filter('theme_page_templates', array($this, 'filter_theme_page_templates')); // reregister the route as we now have a template available. $GLOBALS['wp_rest_server']->override_by_default = true; $controller = new WP_REST_Posts_Controller('page'); $controller->register_routes(); $GLOBALS['wp_rest_server']->override_by_default = false; }
/** * @ticket 38877 */ public function test_update_item_with_template_none() { wp_set_current_user(self::$editor_id); add_filter('theme_post_templates', array($this, 'filter_theme_post_templates')); update_post_meta(self::$post_id, '_wp_page_template', 'post-my-test-template.php'); // reregister the route as we now have a template available. $GLOBALS['wp_rest_server']->override_by_default = true; $controller = new WP_REST_Posts_Controller('post'); $controller->register_routes(); $GLOBALS['wp_rest_server']->override_by_default = false; $request = new WP_REST_Request('PUT', sprintf('/wp/v2/posts/%d', self::$post_id)); $params = $this->set_post_data(array('template' => '')); $request->set_body_params($params); $response = $this->server->dispatch($request); $data = $response->get_data(); $post_template = get_page_template_slug(get_post($data['id'])); $this->assertEquals('', $data['template']); $this->assertEquals('', $post_template); }