@@ -232,7 +232,40 @@ public function test_get_post_templates_child_theme() {
232232 */
233233 public function test_get_theme_featured_list_api () {
234234 wp_set_current_user ( self ::factory ()->user ->create ( array ( 'role ' => 'administrator ' ) ) );
235+
236+ /*
237+ * Detect and suppress the wp_trigger_error() call that themes_api() fires on an
238+ * HTTPS failure, which PHPUnit would otherwise convert to a test exception.
239+ * Skip instead of fail when the API is unavailable.
240+ */
241+ $ api_error_message = null ;
242+
243+ $ detect_api_error = static function ( $ function_name , $ message ) use ( &$ api_error_message ) {
244+ if ( 'themes_api ' === $ function_name ) {
245+ $ api_error_message = $ message ;
246+ }
247+ };
248+ add_action ( 'wp_trigger_error_always_run ' , $ detect_api_error , 10 , 3 );
249+
250+ $ suppress_api_error = static function ( $ trigger , $ function_name ) {
251+ if ( 'themes_api ' === $ function_name ) {
252+ return false ;
253+ }
254+ return $ trigger ;
255+ };
256+ add_filter ( 'wp_trigger_error_trigger_error ' , $ suppress_api_error , 10 , 2 );
257+
235258 $ featured_list_api = get_theme_feature_list ( true );
259+
260+ remove_action ( 'wp_trigger_error_always_run ' , $ detect_api_error );
261+ remove_filter ( 'wp_trigger_error_trigger_error ' , $ suppress_api_error );
262+
263+ if ( null !== $ api_error_message ) {
264+ $ this ->markTestSkipped (
265+ sprintf ( 'WordPress.org Themes API is not available: %s ' , wp_strip_all_tags ( $ api_error_message ) )
266+ );
267+ }
268+
236269 $ this ->assertNonEmptyMultidimensionalArray ( $ featured_list_api );
237270 }
238271
@@ -241,7 +274,6 @@ public function test_get_theme_featured_list_api() {
241274 *
242275 * Differences in the structure can also trigger failure by causing PHP notices/warnings.
243276 *
244- * @group external-http
245277 * @ticket 28121
246278 */
247279 public function test_get_theme_featured_list_hardcoded () {
0 commit comments