Example #1
0
 /**
  * Test the HTTP headers set by the xml_response method.
  */
 function test_request_xml_response_headers()
 {
     if (!function_exists('xdebug_get_headers')) {
         $this->markTestSkipped('xdebug is required for this test');
     }
     $post = $this->factory->post->create_and_get(array('post_title' => 'Hello World'));
     $request = array('url' => get_permalink($post->ID), 'format' => 'xml', 'maxwidth' => 600);
     $legacy_controller = new WP_Legacy_oEmbed_Controller();
     $legacy_controller->dispatch($request);
     $headers = xdebug_get_headers();
     $this->assertTrue(in_array('Content-Type: text/xml; charset=' . get_option('blog_charset'), $headers));
 }
 /**
  * Test request for a child blog post embed in root blog.
  *
  * @group multisite
  */
 function test_request_ms_child_in_root_blog()
 {
     if (!is_multisite()) {
         $this->markTestSkipped(__METHOD__ . ' is a multisite-only test.');
     }
     $child = $this->factory->blog->create();
     switch_to_blog($child);
     $post = $this->factory->post->create_and_get(array('post_title' => 'Hello Child Blog'));
     $request = array('url' => get_permalink($post->ID), 'format' => 'json', 'maxwidth' => 600, 'callback' => '');
     $legacy_controller = new WP_Legacy_oEmbed_Controller();
     $data = json_decode($legacy_controller->dispatch($request), true);
     $this->assertTrue(is_array($data));
     restore_current_blog();
 }
 /**
  * Test request for a normal post.
  */
 function test_request_xml_not_implemented()
 {
     $post = $this->factory->post->create_and_get(array('post_title' => 'Hello World'));
     $request = array('url' => get_permalink($post->ID), 'format' => 'xml', 'maxwidth' => 600, 'callback' => '');
     add_filter('oembed_xml_response', '__return_false');
     $legacy_controller = new WP_Legacy_oEmbed_Controller();
     $this->assertEquals('Not implemented', $legacy_controller->dispatch($request));
 }