diff --git a/tests/phpunit/includes/testcase.php b/tests/phpunit/includes/testcase.php index 899050455d..0528cfffa7 100644 --- a/tests/phpunit/includes/testcase.php +++ b/tests/phpunit/includes/testcase.php @@ -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. * diff --git a/tests/phpunit/tests/admin/includesTheme.php b/tests/phpunit/tests/admin/includesTheme.php index 522615c8a0..223560d98d 100644 --- a/tests/phpunit/tests/admin/includesTheme.php +++ b/tests/phpunit/tests/admin/includesTheme.php @@ -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 ); + } }