/** * Ensure that the OPTIONS handler doesn't kick in for non-OPTIONS requests. */ public function test_options_request_not_options() { register_rest_route('test-ns', '/test', array('methods' => 'GET,POST', 'callback' => '__return_true')); $request = new WP_REST_Request('GET', '/test-ns/test'); $response = rest_handle_options_request(null, $GLOBALS['wp_rest_server'], $request); $this->assertNull($response); }
/** * Test the availability of the item's schema for display / public consumption purposes */ public function test_get_item_schema() { $request = new WP_REST_Request('OPTIONS', '/wp/v2/oembed'); $response = rest_handle_options_request(null, $this->server, $request); $data = $response->get_data(); $properties = $data['schema']['properties']; $this->assertEquals(11, count($properties)); $this->assertArrayHasKey('type', $properties); $this->assertArrayHasKey('version', $properties); $this->assertArrayHasKey('width', $properties); $this->assertArrayHasKey('height', $properties); $this->assertArrayHasKey('title', $properties); $this->assertArrayHasKey('url', $properties); $this->assertArrayHasKey('html', $properties); $this->assertArrayHasKey('author_name', $properties); $this->assertArrayHasKey('author_url', $properties); $this->assertArrayHasKey('provider_name', $properties); $this->assertArrayHasKey('provider_url', $properties); }