From a188681c51757e32ce9ee9dccb8f5b3209409f91 Mon Sep 17 00:00:00 2001 From: Shane Rounce Date: Mon, 23 Nov 2026 13:22:29 +0000 Subject: [PATCH 1/6] Tests: Skip oEmbed XML response tests when SimpleXML is not available. `_oembed_rest_pre_serve_request()` sends a 501 status and calls `die()` when the `SimpleXMLElement` class does not exist. Two tests call it for an XML response without checking for the extension, so on a PHP build without SimpleXML the whole PHPUnit run stops there, printing "Not Implemented" and exiting with a zero status. These tests now require the `simplexml` extension and are skipped without it. --- tests/phpunit/tests/oembed/controller.php | 3 +++ tests/phpunit/tests/oembed/headers.php | 1 + 2 files changed, 4 insertions(+) diff --git a/tests/phpunit/tests/oembed/controller.php b/tests/phpunit/tests/oembed/controller.php index 6077b088d924a..ef5efd7eaf9ff 100644 --- a/tests/phpunit/tests/oembed/controller.php +++ b/tests/phpunit/tests/oembed/controller.php @@ -454,6 +454,9 @@ public function test_request_ms_child_in_root_blog() { restore_current_blog(); } + /** + * @requires extension simplexml + */ public function test_rest_pre_serve_request() { $user = get_user_by( 'id', self::$subscriber ); $post = self::factory()->post->create_and_get( diff --git a/tests/phpunit/tests/oembed/headers.php b/tests/phpunit/tests/oembed/headers.php index 8f9c4e4c8d50a..40913ec6aae74 100644 --- a/tests/phpunit/tests/oembed/headers.php +++ b/tests/phpunit/tests/oembed/headers.php @@ -11,6 +11,7 @@ class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase { /** * @requires function xdebug_get_headers + * @requires extension simplexml */ public function test_rest_pre_serve_request_headers() { $post = self::factory()->post->create_and_get( From d4737afaf75d3b30951505a0c7fe5a252d686514 Mon Sep 17 00:00:00 2001 From: Shane Rounce Date: Mon, 23 Nov 2026 13:37:42 +0000 Subject: [PATCH 2/6] Tests: Add the ticket reference for #66788. --- tests/phpunit/tests/oembed/controller.php | 2 ++ tests/phpunit/tests/oembed/headers.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/phpunit/tests/oembed/controller.php b/tests/phpunit/tests/oembed/controller.php index ef5efd7eaf9ff..78f21c4841e46 100644 --- a/tests/phpunit/tests/oembed/controller.php +++ b/tests/phpunit/tests/oembed/controller.php @@ -455,6 +455,8 @@ public function test_request_ms_child_in_root_blog() { } /** + * @ticket 66788 + * * @requires extension simplexml */ public function test_rest_pre_serve_request() { diff --git a/tests/phpunit/tests/oembed/headers.php b/tests/phpunit/tests/oembed/headers.php index 40913ec6aae74..f3396a7d26372 100644 --- a/tests/phpunit/tests/oembed/headers.php +++ b/tests/phpunit/tests/oembed/headers.php @@ -10,6 +10,8 @@ class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase { /** + * @ticket 66788 + * * @requires function xdebug_get_headers * @requires extension simplexml */ From 15e3cccc9d8b6d5a4a9a90aa282f3aa7729dbd40 Mon Sep 17 00:00:00 2001 From: Shane Rounce Date: Mon, 23 Nov 2026 13:39:59 +0000 Subject: [PATCH 3/6] Tests: Skip the remaining oEmbed tests that need SimpleXML. With the two response tests guarded, six more tests fail on a build without SimpleXML: `test_oembed_create_xml` uses the extension directly, and five discovery link tests expect the XML link, which is only output when the `SimpleXMLElement` class exists. The ticket annotation added to existing tests in the previous commit is removed; only the extension requirement is added. --- tests/phpunit/tests/oembed/controller.php | 5 +++-- tests/phpunit/tests/oembed/discovery.php | 13 +++++++++++++ tests/phpunit/tests/oembed/headers.php | 2 -- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/tests/oembed/controller.php b/tests/phpunit/tests/oembed/controller.php index 78f21c4841e46..aef68f068d6b0 100644 --- a/tests/phpunit/tests/oembed/controller.php +++ b/tests/phpunit/tests/oembed/controller.php @@ -185,6 +185,9 @@ public function test_wp_oembed_ensure_format() { $this->assertSame( 'json', wp_oembed_ensure_format( array() ) ); } + /** + * @requires extension simplexml + */ public function test_oembed_create_xml() { $actual = _oembed_create_xml( array( @@ -455,8 +458,6 @@ public function test_request_ms_child_in_root_blog() { } /** - * @ticket 66788 - * * @requires extension simplexml */ public function test_rest_pre_serve_request() { diff --git a/tests/phpunit/tests/oembed/discovery.php b/tests/phpunit/tests/oembed/discovery.php index e478786ce49e9..c0d01bdbdb431 100644 --- a/tests/phpunit/tests/oembed/discovery.php +++ b/tests/phpunit/tests/oembed/discovery.php @@ -16,6 +16,8 @@ public function test_add_oembed_discovery_links_front_page() { /** * @ticket 34971 + * + * @requires extension simplexml */ public function test_add_oembed_discovery_links_static_front_page() { update_option( 'show_on_front', 'page' ); @@ -40,6 +42,9 @@ public function test_add_oembed_discovery_links_static_front_page() { update_option( 'show_on_front', 'posts' ); } + /** + * @requires extension simplexml + */ public function test_add_oembed_discovery_links_to_post() { $post_id = self::factory()->post->create(); $this->go_to( get_permalink( $post_id ) ); @@ -54,6 +59,9 @@ public function test_add_oembed_discovery_links_to_post() { $this->assertSame( '', get_echo( 'wp_oembed_add_discovery_links' ), 'Expected filtering oembed_discovery_links to empty string to result in no wp_oembed_add_discovery_links() output.' ); } + /** + * @requires extension simplexml + */ public function test_add_oembed_discovery_links_to_page() { $post_id = self::factory()->post->create( array( @@ -69,6 +77,9 @@ public function test_add_oembed_discovery_links_to_page() { $this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) ); } + /** + * @requires extension simplexml + */ public function test_add_oembed_discovery_links_to_attachment() { $post_id = self::factory()->post->create(); $file = DIR_TESTDATA . '/images/canola.jpg'; @@ -107,6 +118,8 @@ public function test_wp_oembed_add_discovery_links_non_embeddable_post_type_outp /** * @ticket 64178 * @covers ::wp_oembed_add_discovery_links + * + * @requires extension simplexml */ public function test_wp_oembed_add_discovery_links_back_compat() { $action = 'wp_head'; diff --git a/tests/phpunit/tests/oembed/headers.php b/tests/phpunit/tests/oembed/headers.php index f3396a7d26372..40913ec6aae74 100644 --- a/tests/phpunit/tests/oembed/headers.php +++ b/tests/phpunit/tests/oembed/headers.php @@ -10,8 +10,6 @@ class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase { /** - * @ticket 66788 - * * @requires function xdebug_get_headers * @requires extension simplexml */ From 14ff0ecd8fa97d5c068b4c070f4c451af68d7827 Mon Sep 17 00:00:00 2001 From: Shane Rounce Date: Mon, 23 Nov 2026 16:41:22 +0000 Subject: [PATCH 4/6] Tests: Keep the oEmbed discovery tests running without SimpleXML. Instead of skipping the five discovery tests when SimpleXML is unavailable, only expect the XML discovery link when `SimpleXMLElement` exists, matching the condition in `wp_oembed_add_discovery_links()`. The JSON link, the `oembed_discovery_links` filter and the back-compat check for the two `wp_head` priorities are then still covered without the extension. Follow-up to review feedback from lancewillett. See #66788. --- tests/phpunit/tests/oembed/discovery.php | 33 +++++++++++------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/tests/phpunit/tests/oembed/discovery.php b/tests/phpunit/tests/oembed/discovery.php index c0d01bdbdb431..d6f94e6a5909d 100644 --- a/tests/phpunit/tests/oembed/discovery.php +++ b/tests/phpunit/tests/oembed/discovery.php @@ -16,8 +16,6 @@ public function test_add_oembed_discovery_links_front_page() { /** * @ticket 34971 - * - * @requires extension simplexml */ public function test_add_oembed_discovery_links_static_front_page() { update_option( 'show_on_front', 'page' ); @@ -35,23 +33,24 @@ public function test_add_oembed_discovery_links_static_front_page() { $this->assertQueryTrue( 'is_front_page', 'is_singular', 'is_page' ); $expected = '' . "\n"; - $expected .= '' . "\n"; + if ( class_exists( 'SimpleXMLElement' ) ) { + $expected .= '' . "\n"; + } $this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) ); update_option( 'show_on_front', 'posts' ); } - /** - * @requires extension simplexml - */ public function test_add_oembed_discovery_links_to_post() { $post_id = self::factory()->post->create(); $this->go_to( get_permalink( $post_id ) ); $this->assertQueryTrue( 'is_single', 'is_singular' ); $expected = '' . "\n"; - $expected .= '' . "\n"; + if ( class_exists( 'SimpleXMLElement' ) ) { + $expected .= '' . "\n"; + } $this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) ); @@ -59,9 +58,6 @@ public function test_add_oembed_discovery_links_to_post() { $this->assertSame( '', get_echo( 'wp_oembed_add_discovery_links' ), 'Expected filtering oembed_discovery_links to empty string to result in no wp_oembed_add_discovery_links() output.' ); } - /** - * @requires extension simplexml - */ public function test_add_oembed_discovery_links_to_page() { $post_id = self::factory()->post->create( array( @@ -72,14 +68,13 @@ public function test_add_oembed_discovery_links_to_page() { $this->assertQueryTrue( 'is_page', 'is_singular' ); $expected = '' . "\n"; - $expected .= '' . "\n"; + if ( class_exists( 'SimpleXMLElement' ) ) { + $expected .= '' . "\n"; + } $this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) ); } - /** - * @requires extension simplexml - */ public function test_add_oembed_discovery_links_to_attachment() { $post_id = self::factory()->post->create(); $file = DIR_TESTDATA . '/images/canola.jpg'; @@ -95,7 +90,9 @@ public function test_add_oembed_discovery_links_to_attachment() { $this->assertQueryTrue( 'is_attachment', 'is_singular', 'is_single' ); $expected = '' . "\n"; - $expected .= '' . "\n"; + if ( class_exists( 'SimpleXMLElement' ) ) { + $expected .= '' . "\n"; + } $this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) ); } @@ -118,8 +115,6 @@ public function test_wp_oembed_add_discovery_links_non_embeddable_post_type_outp /** * @ticket 64178 * @covers ::wp_oembed_add_discovery_links - * - * @requires extension simplexml */ public function test_wp_oembed_add_discovery_links_back_compat() { $action = 'wp_head'; @@ -146,7 +141,9 @@ public function test_wp_oembed_add_discovery_links_back_compat() { $this->assertSame( 1, $mock_action->get_call_count() ); $expected = '' . "\n"; - $expected .= '' . "\n"; + if ( class_exists( 'SimpleXMLElement' ) ) { + $expected .= '' . "\n"; + } $this->assertSame( $expected, $wp_head_output, 'Expected wp_head output to be the same as the wp_oembed_add_discovery_links() output.' ); $this->assertSame( $expected, get_echo( $callback ), 'Expected wp_oembed_add_discovery_links() output to be the same as the wp_head output when called outside of wp_head.' ); From 5e26f00548a9b19902834a81f6909b5291f1ccb5 Mon Sep 17 00:00:00 2001 From: Shane Rounce Date: Mon, 23 Nov 2026 16:43:28 +0000 Subject: [PATCH 5/6] Coding Standards: Fix assignment alignment in the oEmbed discovery tests. See #66788. --- tests/phpunit/tests/oembed/discovery.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/tests/oembed/discovery.php b/tests/phpunit/tests/oembed/discovery.php index d6f94e6a5909d..20bfcbb9372db 100644 --- a/tests/phpunit/tests/oembed/discovery.php +++ b/tests/phpunit/tests/oembed/discovery.php @@ -32,7 +32,7 @@ public function test_add_oembed_discovery_links_static_front_page() { $this->go_to( home_url() ); $this->assertQueryTrue( 'is_front_page', 'is_singular', 'is_page' ); - $expected = '' . "\n"; + $expected = '' . "\n"; if ( class_exists( 'SimpleXMLElement' ) ) { $expected .= '' . "\n"; } @@ -47,7 +47,7 @@ public function test_add_oembed_discovery_links_to_post() { $this->go_to( get_permalink( $post_id ) ); $this->assertQueryTrue( 'is_single', 'is_singular' ); - $expected = '' . "\n"; + $expected = '' . "\n"; if ( class_exists( 'SimpleXMLElement' ) ) { $expected .= '' . "\n"; } @@ -67,7 +67,7 @@ public function test_add_oembed_discovery_links_to_page() { $this->go_to( get_permalink( $post_id ) ); $this->assertQueryTrue( 'is_page', 'is_singular' ); - $expected = '' . "\n"; + $expected = '' . "\n"; if ( class_exists( 'SimpleXMLElement' ) ) { $expected .= '' . "\n"; } @@ -89,7 +89,7 @@ public function test_add_oembed_discovery_links_to_attachment() { $this->go_to( get_permalink( $attachment_id ) ); $this->assertQueryTrue( 'is_attachment', 'is_singular', 'is_single' ); - $expected = '' . "\n"; + $expected = '' . "\n"; if ( class_exists( 'SimpleXMLElement' ) ) { $expected .= '' . "\n"; } @@ -140,7 +140,7 @@ public function test_wp_oembed_add_discovery_links_back_compat() { $wp_head_output = get_echo( 'wp_head' ); $this->assertSame( 1, $mock_action->get_call_count() ); - $expected = '' . "\n"; + $expected = '' . "\n"; if ( class_exists( 'SimpleXMLElement' ) ) { $expected .= '' . "\n"; } From 71b4304d8f4bc55f4ad5491aa5cdb34979190b63 Mon Sep 17 00:00:00 2001 From: Shane Rounce Date: Tue, 24 Nov 2026 07:46:40 +0000 Subject: [PATCH 6/6] Tests: Require SimpleXML at class level in the oEmbed headers test. The test runs in a separate process. With Xdebug enabled and SimpleXML missing, PHPUnit reports an error while reading the skipped result from the child process. A class-level requirement skips before the child process starts. Props lancewillett. See #66788. --- tests/phpunit/tests/oembed/headers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/oembed/headers.php b/tests/phpunit/tests/oembed/headers.php index 40913ec6aae74..5f5799447f7b5 100644 --- a/tests/phpunit/tests/oembed/headers.php +++ b/tests/phpunit/tests/oembed/headers.php @@ -6,12 +6,12 @@ * @group oembed * @group oembed-headers * @group xdebug + * @requires extension simplexml */ class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase { /** * @requires function xdebug_get_headers - * @requires extension simplexml */ public function test_rest_pre_serve_request_headers() { $post = self::factory()->post->create_and_get(