Themes: Add a unit test for `get_theme_feature_list()` to make sure that the list of theme features pulled from the WordPress.org API returns the expected data structure.
Props iandunn. Fixes #28121. git-svn-id: https://develop.svn.wordpress.org/trunk@39906 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1348f5f3fe
commit
40f076d756
|
@ -439,6 +439,21 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
|
|||
$this->assertEquals( $expected, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the given variable is a multidimensional array, and that all arrays are non-empty.
|
||||
*
|
||||
* @param array $array
|
||||
*/
|
||||
function assertNonEmptyMultidimensionalArray( $array ) {
|
||||
$this->assertTrue( is_array( $array ) );
|
||||
$this->assertNotEmpty( $array );
|
||||
|
||||
foreach( $array as $sub_array ) {
|
||||
$this->assertTrue( is_array( $sub_array ) );
|
||||
$this->assertNotEmpty( $sub_array );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify WordPress's query internals as if a given URL has been requested.
|
||||
*
|
||||
|
|
|
@ -136,4 +136,31 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
|
|||
), get_page_templates() );
|
||||
$this->assertEquals( array(), get_page_templates( null, 'bar' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @group external-http
|
||||
* @ticket 28121
|
||||
*/
|
||||
function test_get_theme_featured_list_api() {
|
||||
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
|
||||
$featured_list_api = get_theme_feature_list( true );
|
||||
$this->assertNonEmptyMultidimensionalArray( $featured_list_api );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the list of theme features hardcoded into Core returns the expected data structure.
|
||||
*
|
||||
* Differences in the structure can also trigger failure by causing PHP notices/warnings.
|
||||
*
|
||||
* @group external-http
|
||||
* @ticket 28121
|
||||
*/
|
||||
function test_get_theme_featured_list_hardcoded() {
|
||||
$featured_list_hardcoded = get_theme_feature_list( false );
|
||||
$this->assertNonEmptyMultidimensionalArray( $featured_list_hardcoded );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue