diff --git a/tests/phpunit/tests/admin/includesTheme.php b/tests/phpunit/tests/admin/includesTheme.php index 0bb3044e6ba6e..a7e0249efcc3b 100644 --- a/tests/phpunit/tests/admin/includesTheme.php +++ b/tests/phpunit/tests/admin/includesTheme.php @@ -184,17 +184,52 @@ 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. + * Test that a mocked WordPress.org API response returns the expected translated list of theme features. * - * 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 + ); } /**