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/admin/includesTheme.php

    r51639 r52010  
    55class Tests_Admin_IncludesTheme extends WP_UnitTestCase {
    66
    7     function set_up() {
     7    public function set_up() {
    88        parent::set_up();
    99        $this->theme_root = DIR_TESTDATA . '/themedir1';
     
    1212        $GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root );
    1313
    14         add_filter( 'theme_root', array( $this, '_theme_root' ) );
    15         add_filter( 'stylesheet_root', array( $this, '_theme_root' ) );
    16         add_filter( 'template_root', array( $this, '_theme_root' ) );
     14        add_filter( 'theme_root', array( $this, 'filter_theme_root' ) );
     15        add_filter( 'stylesheet_root', array( $this, 'filter_theme_root' ) );
     16        add_filter( 'template_root', array( $this, 'filter_theme_root' ) );
    1717
    1818        // Clear caches.
     
    2121    }
    2222
    23     function tear_down() {
     23    public function tear_down() {
    2424        $GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
    25         remove_filter( 'theme_root', array( $this, '_theme_root' ) );
    26         remove_filter( 'stylesheet_root', array( $this, '_theme_root' ) );
    27         remove_filter( 'template_root', array( $this, '_theme_root' ) );
     25        remove_filter( 'theme_root', array( $this, 'filter_theme_root' ) );
     26        remove_filter( 'stylesheet_root', array( $this, 'filter_theme_root' ) );
     27        remove_filter( 'template_root', array( $this, 'filter_theme_root' ) );
    2828
    2929        wp_clean_themes_cache();
     
    3333
    3434    // Replace the normal theme root directory with our premade test directory.
    35     function _theme_root( $dir ) {
     35    public function filter_theme_root( $dir ) {
    3636        return $this->theme_root;
    3737    }
     
    4343     * @expectedDeprecated get_themes
    4444     */
    45     function test_page_templates() {
     45    public function test_page_templates() {
    4646        $theme = get_theme( 'Page Template Theme' );
    4747        $this->assertNotEmpty( $theme );
     
    7676     * @ticket 18375
    7777     */
    78     function test_page_templates_different_post_types() {
     78    public function test_page_templates_different_post_types() {
    7979        $theme = wp_get_theme( 'page-templates' );
    8080        $this->assertNotEmpty( $theme );
     
    102102     * @ticket 38766
    103103     */
    104     function test_page_templates_for_post_types_with_trailing_periods() {
     104    public function test_page_templates_for_post_types_with_trailing_periods() {
    105105        $theme = wp_get_theme( 'page-templates' );
    106106        $this->assertNotEmpty( $theme );
     
    134134     * @ticket 38696
    135135     */
    136     function test_page_templates_child_theme() {
     136    public function test_page_templates_child_theme() {
    137137        $theme = wp_get_theme( 'page-templates-child' );
    138138        $this->assertNotEmpty( $theme );
     
    217217     * @ticket 28121
    218218     */
    219     function test_get_theme_featured_list_api() {
     219    public function test_get_theme_featured_list_api() {
    220220        wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
    221221        $featured_list_api = get_theme_feature_list( true );
     
    231231     * @ticket 28121
    232232     */
    233     function test_get_theme_featured_list_hardcoded() {
     233    public function test_get_theme_featured_list_hardcoded() {
    234234        $featured_list_hardcoded = get_theme_feature_list( false );
    235235        $this->assertNonEmptyMultidimensionalArray( $featured_list_hardcoded );
Note: See TracChangeset for help on using the changeset viewer.