Changeset 35436 for trunk/tests/phpunit/tests/oembed/headers.php
- Timestamp:
- 10/29/2015 10:50:13 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/oembed/headers.php
r35242 r35436 8 8 */ 9 9 class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase { 10 function test_re quest_json_response_headers() {10 function test_rest_pre_serve_request_headers() { 11 11 if ( ! function_exists( 'xdebug_get_headers' ) ) { 12 12 $this->markTestSkipped( 'xdebug is required for this test' ); 13 13 } 14 14 15 $post = self::factory()->post->create_and_get( array(15 $post = $this->factory()->post->create_and_get( array( 16 16 'post_title' => 'Hello World', 17 17 ) ); 18 18 19 $request = array( 20 'url' => get_permalink( $post->ID ), 21 'format' => 'json', 22 'maxwidth' => 600, 23 'callback' => '', 24 ); 19 $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' ); 20 $request->set_param( 'url', get_permalink( $post->ID ) ); 21 $request->set_param( 'format', 'xml' ); 25 22 26 $legacy_controller = new WP_oEmbed_Controller(); 27 $legacy_controller->dispatch( $request ); 23 $server = new WP_REST_Server(); 24 $response = $server->dispatch( $request ); 25 $output = get_echo( '_oembed_rest_pre_serve_request', array( true, $response, $request, $server ) ); 28 26 29 $headers = xdebug_get_headers(); 30 31 $this->assertTrue( in_array( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), $headers ) ); 32 $this->assertTrue( in_array( 'X-Content-Type-Options: nosniff', $headers ) ); 33 34 $request['callback'] = 'foobar'; 35 36 $legacy_controller->dispatch( $request ); 37 38 $headers = xdebug_get_headers(); 39 40 $this->assertTrue( in_array( 'Content-Type: application/javascript; charset=' . get_option( 'blog_charset' ), $headers ) ); 41 $this->assertTrue( in_array( 'X-Content-Type-Options: nosniff', $headers ) ); 42 } 43 44 function test_request_xml_response_headers() { 45 if ( ! function_exists( 'xdebug_get_headers' ) ) { 46 $this->markTestSkipped( 'xdebug is required for this test' ); 47 } 48 49 $post = self::factory()->post->create_and_get( array( 50 'post_title' => 'Hello World', 51 ) ); 52 53 $request = array( 54 'url' => get_permalink( $post->ID ), 55 'format' => 'xml', 56 'maxwidth' => 600, 57 ); 58 59 $legacy_controller = new WP_oEmbed_Controller(); 60 $legacy_controller->dispatch( $request ); 27 $this->assertNotEmpty( $output ); 61 28 62 29 $headers = xdebug_get_headers();
Note: See TracChangeset
for help on using the changeset viewer.