wordpress-develop/tests/phpunit/tests/oembed/headers.php
Sergey Biryukov bfdc8eff83 Tests: Correctly use the factory method.
This replaces all non-static calls to the `WP_UnitTestCase_Base::factory()` method with static function calls, since the method is declared as static.

This is a consistency improvement for the test suite.

Follow up to [35225], [35242], [49603], [54087].

Props jrf.
See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54088 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-06 22:03:10 +00:00

37 lines
948 B
PHP

<?php
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @group oembed
* @group oembed-headers
* @group xdebug
*/
class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase {
/**
* @requires function xdebug_get_headers
*/
public function test_rest_pre_serve_request_headers() {
$post = self::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->assertContains( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), $headers );
}
}