Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 40 additions & 5 deletions tests/phpunit/tests/admin/includesTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

/**
Expand Down
Loading