From 1ce9ce6b702fd4ea89ffc78d0461068f6504c21b Mon Sep 17 00:00:00 2001 From: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com> Date: Fri, 18 Sep 2026 15:07:31 +0300 Subject: [PATCH 1/2] Build/Test Tools: Mock the external HTTP request in the `get_theme_feature_list()` test. Answer the Themes API request in `test_get_theme_featured_list_api()` with a fixed response through `pre_http_request`, and move the test out of the `external-http` group. The test asserted only a non-empty multidimensional array. `get_theme_feature_list()` returns the hard-coded list when the request fails, so a rate-limited response passed too. The test now asserts the exact translated output, with one feature slug that core does not know. --- tests/phpunit/tests/admin/includesTheme.php | 40 ++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/tests/admin/includesTheme.php b/tests/phpunit/tests/admin/includesTheme.php index 0bb3044e6ba6e..cd9ad98a3d2d6 100644 --- a/tests/phpunit/tests/admin/includesTheme.php +++ b/tests/phpunit/tests/admin/includesTheme.php @@ -188,13 +188,51 @@ public function test_page_templates_child_theme() { * * Differences in the structure can also trigger failure by causing PHP notices/warnings. * - * @group external-http * @ticket 28121 */ public function test_get_theme_featured_list_api() { wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); + + add_filter( + 'pre_http_request', + static function () { + return array( + 'headers' => array(), + 'body' => wp_json_encode( + array( + 'Subject' => array( 'blog', 'news' ), + 'Features' => array( 'custom-logo', 'unknown-feature' ), + 'Layout' => array( 'one-column' ), + ) + ), + 'response' => array( + 'code' => 200, + 'message' => 'OK', + ), + 'cookies' => array(), + 'filename' => null, + ); + } + ); + $featured_list_api = get_theme_feature_list( true ); $this->assertNonEmptyMultidimensionalArray( $featured_list_api ); + $this->assertSame( + array( + 'Subject' => array( + 'blog' => 'Blog', + 'news' => 'News', + ), + 'Features' => array( + 'custom-logo' => 'Custom Logo', + 'unknown-feature' => 'unknown-feature', + ), + 'Layout' => array( + 'one-column' => 'One Column', + ), + ), + $featured_list_api + ); } /** From bcdcfd269d6986fdbb41c4732067794433df024b Mon Sep 17 00:00:00 2001 From: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com> Date: Fri, 18 Sep 2026 16:39:23 +0300 Subject: [PATCH 2/2] Remove a redundant assertion and update the test description. `assertSame()` on the exact output already covers the non-empty multidimensional array check. The docblock now says that the response is mocked. --- tests/phpunit/tests/admin/includesTheme.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/phpunit/tests/admin/includesTheme.php b/tests/phpunit/tests/admin/includesTheme.php index cd9ad98a3d2d6..a7e0249efcc3b 100644 --- a/tests/phpunit/tests/admin/includesTheme.php +++ b/tests/phpunit/tests/admin/includesTheme.php @@ -184,9 +184,7 @@ public function test_page_templates_child_theme() { } /** - * Test that the list of theme features pulled from the WordPress.org API returns the expected data structure. - * - * Differences in the structure can also trigger failure by causing PHP notices/warnings. + * Test that a mocked WordPress.org API response returns the expected translated list of theme features. * * @ticket 28121 */ @@ -216,7 +214,6 @@ static function () { ); $featured_list_api = get_theme_feature_list( true ); - $this->assertNonEmptyMultidimensionalArray( $featured_list_api ); $this->assertSame( array( 'Subject' => array(