Make WordPress Core


Ignore:
Timestamp:
11/04/2021 03:22:47 PM (3 years ago)
Author:
hellofromTonya
Message:

Coding Standards: Add visibility to methods in tests/phpunit/tests/.

Adds a public visibility to test fixtures, tests, data providers, and callbacks methods.

Adds a private visibility to helper methods within test classes.

Renames callbacks and helpers that previously started with a _ prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit.

Props costdev, jrf, hellofromTonya.
Fixes #54177.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/theme.php

    r51580 r52010  
    2323    );
    2424
    25     function set_up() {
     25    public function set_up() {
    2626        global $wp_theme_directories;
    2727
     
    3131        $wp_theme_directories        = array( WP_CONTENT_DIR . '/themes' );
    3232
    33         add_filter( 'extra_theme_headers', array( $this, '_theme_data_extra_headers' ) );
     33        add_filter( 'extra_theme_headers', array( $this, 'theme_data_extra_headers' ) );
    3434        wp_clean_themes_cache();
    3535        unset( $GLOBALS['wp_themes'] );
    3636    }
    3737
    38     function tear_down() {
     38    public function tear_down() {
    3939        global $wp_theme_directories;
    4040
    4141        $wp_theme_directories = $this->wp_theme_directories;
    4242
    43         remove_filter( 'extra_theme_headers', array( $this, '_theme_data_extra_headers' ) );
     43        remove_filter( 'extra_theme_headers', array( $this, 'theme_data_extra_headers' ) );
    4444        wp_clean_themes_cache();
    4545        unset( $GLOBALS['wp_themes'] );
     
    4848    }
    4949
    50     function test_wp_get_themes_default() {
     50    public function test_wp_get_themes_default() {
    5151        $themes = wp_get_themes();
    5252        $this->assertInstanceOf( 'WP_Theme', $themes[ $this->theme_slug ] );
     
    6262     * @expectedDeprecated get_themes
    6363     */
    64     function test_get_themes_default() {
     64    public function test_get_themes_default() {
    6565        $themes = get_themes();
    6666        $this->assertInstanceOf( 'WP_Theme', $themes[ $this->theme_name ] );
     
    7676     * @expectedDeprecated get_themes
    7777     */
    78     function test_get_theme() {
     78    public function test_get_theme() {
    7979        $themes = get_themes();
    8080        foreach ( array_keys( $themes ) as $name ) {
     
    8787    }
    8888
    89     function test_wp_get_theme() {
     89    public function test_wp_get_theme() {
    9090        $themes = wp_get_themes();
    9191        foreach ( $themes as $theme ) {
     
    102102     * @expectedDeprecated get_themes
    103103     */
    104     function test_get_themes_contents() {
     104    public function test_get_themes_contents() {
    105105        $themes = get_themes();
    106106        // Generic tests that should hold true for any theme.
     
    168168    }
    169169
    170     function test_wp_get_theme_contents() {
     170    public function test_wp_get_theme_contents() {
    171171        $theme = wp_get_theme( $this->theme_slug );
    172172
     
    193193     * @ticket 29925
    194194     */
    195     function test_default_theme_in_default_theme_list() {
     195    public function test_default_theme_in_default_theme_list() {
    196196        $latest_default_theme = WP_Theme::get_core_default_theme();
    197197        if ( ! $latest_default_theme->exists() || 'twenty' !== substr( $latest_default_theme->get_stylesheet(), 0, 6 ) ) {
     
    201201    }
    202202
    203     function test_default_themes_have_textdomain() {
     203    public function test_default_themes_have_textdomain() {
    204204        foreach ( $this->default_themes as $theme ) {
    205205            if ( wp_get_theme( $theme )->exists() ) {
     
    212212     * @ticket 48566
    213213     */
    214     function test_year_in_readme() {
     214    public function test_year_in_readme() {
    215215        // This test is designed to only run on trunk/master.
    216216        $this->skipOnAutomatedBranches();
     
    240240     * @expectedDeprecated get_theme_data
    241241     */
    242     function test_extra_theme_headers() {
     242    public function test_extra_theme_headers() {
    243243        $wp_theme = wp_get_theme( $this->theme_slug );
    244244        $this->assertNotEmpty( $wp_theme->get( 'License' ) );
     
    252252    }
    253253
    254     function _theme_data_extra_headers() {
     254    public function theme_data_extra_headers() {
    255255        return array( 'License' );
    256256    }
     
    260260     * @expectedDeprecated get_current_theme
    261261     */
    262     function test_switch_theme() {
     262    public function test_switch_theme() {
    263263        $themes = get_themes();
    264264
     
    331331    }
    332332
    333     function test_switch_theme_bogus() {
     333    public function test_switch_theme_bogus() {
    334334        // Try switching to a theme that doesn't exist.
    335335        $template = rand_str();
     
    353353     * @covers ::_wp_keep_alive_customize_changeset_dependent_auto_drafts
    354354     */
    355     function test_wp_keep_alive_customize_changeset_dependent_auto_drafts() {
     355    public function test_wp_keep_alive_customize_changeset_dependent_auto_drafts() {
    356356        $nav_created_post_ids = $this->factory()->post->create_many(
    357357            2,
     
    622622     * @ticket 49406
    623623     *
    624      * @dataProvider _dp_register_theme_support_validation
     624     * @dataProvider data_register_theme_support_validation
    625625     *
    626626     * @param string $error_code The error code expected.
     
    634634    }
    635635
    636     public function _dp_register_theme_support_validation() {
     636    public function data_register_theme_support_validation() {
    637637        return array(
    638638            array(
Note: See TracChangeset for help on using the changeset viewer.