WordPress.org

Make WordPress Core

Changeset 39906


Ignore:
Timestamp:
01/15/17 06:50:00 (9 months ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/tests/phpunit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase.php

    r39626 r39906  
    438438        ksort( $actual ); 
    439439        $this->assertEquals( $expected, $actual ); 
     440    } 
     441 
     442    /** 
     443     * Asserts that the given variable is a multidimensional array, and that all arrays are non-empty. 
     444     * 
     445     * @param array $array 
     446     */ 
     447    function assertNonEmptyMultidimensionalArray( $array ) { 
     448        $this->assertTrue( is_array( $array ) ); 
     449        $this->assertNotEmpty( $array ); 
     450 
     451        foreach( $array as $sub_array ) { 
     452            $this->assertTrue( is_array( $sub_array ) ); 
     453            $this->assertNotEmpty( $sub_array ); 
     454        } 
    440455    } 
    441456 
  • trunk/tests/phpunit/tests/admin/includesTheme.php

    r39236 r39906  
    137137        $this->assertEquals( array(), get_page_templates( null, 'bar' ) ); 
    138138    } 
     139 
     140    /** 
     141     * Test that the list of theme features pulled from the WordPress.org API returns the expected data structure. 
     142     * 
     143     * Differences in the structure can also trigger failure by causing PHP notices/warnings. 
     144     * 
     145     * @group external-http 
     146     * @ticket 28121 
     147     */ 
     148    function test_get_theme_featured_list_api() { 
     149        wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); 
     150        $featured_list_api = get_theme_feature_list( true ); 
     151        $this->assertNonEmptyMultidimensionalArray( $featured_list_api ); 
     152    } 
     153 
     154    /** 
     155     * Test that the list of theme features hardcoded into Core returns the expected data structure. 
     156     * 
     157     * Differences in the structure can also trigger failure by causing PHP notices/warnings. 
     158     * 
     159     * @group external-http 
     160     * @ticket 28121 
     161     */ 
     162    function test_get_theme_featured_list_hardcoded() { 
     163        $featured_list_hardcoded = get_theme_feature_list( false ); 
     164        $this->assertNonEmptyMultidimensionalArray( $featured_list_hardcoded ); 
     165    } 
    139166} 
Note: See TracChangeset for help on using the changeset viewer.