diff --git a/tests/phpunit/tests/trackback/trackbackResponse.php b/tests/phpunit/tests/trackback/trackbackResponse.php new file mode 100644 index 0000000000000..1ca34e2d28e19 --- /dev/null +++ b/tests/phpunit/tests/trackback/trackbackResponse.php @@ -0,0 +1,76 @@ +post_id = $this->factory()->post->create(); + $wp = new stdClass(); + $post_id = $this->post_id; + $old_get = $_GET; + $old_post = $_POST; + + $_GET = array( 'tb_id' => $this->post_id ); + $_POST = array( + 'url' => 'https://example.com/trackback', + 'title' => 'Trackback title', + 'blog_name' => 'Trackback blog', + ); + + if ( ! function_exists( 'trackback_response' ) ) { + set_error_handler( + static function ( $severity, $message ) { + return E_WARNING === $severity && str_contains( $message, 'Cannot modify header information' ); + } + ); + ob_start(); + require ABSPATH . 'wp-trackback.php'; + ob_end_clean(); + restore_error_handler(); + } + + $_GET = $old_get; + $_POST = $old_post; + } + + /** + * Tests that trackback_response() returns a successful XML response. + * + * @ticket 66011 + */ + public function test_trackback_response_success() { + set_error_handler( + static function ( $severity, $message ) { + return E_WARNING === $severity && str_contains( $message, 'Cannot modify header information' ); + } + ); + ob_start(); + trackback_response(); + $response = ob_get_clean(); + restore_error_handler(); + + $this->assertSame( + "\n\n0\n", + $response + ); + } +}