wordpress-develop/tests/phpunit/tests/oembed/headers.php
Gary Pendergast c6c78490e2 Coding Standards: Fix the remaining issues in /tests.
All PHP files in `/tests` now conform to the PHP coding standards, or have exceptions appropriately marked.

Travis now also runs `phpcs` on the `/tests` directory, any future changes to these files must conform entirely to the WordPress PHP coding standards. 🎉

See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45607 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-08 00:55:20 +00:00

36 lines
1009 B
PHP

<?php
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @group oembed
* @group oembed-headers
*/
class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase {
function test_rest_pre_serve_request_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 = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
$request->set_param( 'url', get_permalink( $post->ID ) );
$request->set_param( 'format', 'xml' );
$server = new WP_REST_Server();
$response = $server->dispatch( $request );
$output = get_echo( '_oembed_rest_pre_serve_request', array( true, $response, $request, $server ) );
$this->assertNotEmpty( $output );
$headers = xdebug_get_headers();
$this->assertTrue( in_array( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), $headers, true ) );
}
}