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/image/siteIcon.php

    r51568 r52010  
    1313    public $attachment_id = 0;
    1414
    15     function set_up() {
     15    public function set_up() {
    1616        parent::set_up();
    1717
     
    1919    }
    2020
    21     function tear_down() {
    22         $this->_remove_custom_logo();
     21    public function tear_down() {
     22        $this->remove_custom_logo();
    2323        $this->remove_added_uploads();
    2424        parent::tear_down();
    2525    }
    2626
    27     function _remove_custom_logo() {
     27    private function remove_custom_logo() {
    2828        remove_theme_mod( 'custom_logo' );
    2929    }
    3030
    31     function test_intermediate_image_sizes() {
     31    public function test_intermediate_image_sizes() {
    3232        $image_sizes = $this->wp_site_icon->intermediate_image_sizes( array() );
    3333
     
    4040    }
    4141
    42     function test_intermediate_image_sizes_with_filter() {
    43         add_filter( 'site_icon_image_sizes', array( $this, '_custom_test_sizes' ) );
     42    public function test_intermediate_image_sizes_with_filter() {
     43        add_filter( 'site_icon_image_sizes', array( $this, 'custom_test_sizes' ) );
    4444        $image_sizes = $this->wp_site_icon->intermediate_image_sizes( array() );
    4545
     
    5858        unset( $this->wp_site_icon->site_icon_sizes[ array_search( 321, $this->wp_site_icon->site_icon_sizes, true ) ] );
    5959        // Remove the filter we added.
    60         remove_filter( 'site_icon_image_sizes', array( $this, '_custom_test_sizes' ) );
     60        remove_filter( 'site_icon_image_sizes', array( $this, 'custom_test_sizes' ) );
    6161    }
    6262
    63     function test_additional_sizes() {
     63    public function test_additional_sizes() {
    6464        $image_sizes = $this->wp_site_icon->additional_sizes( array() );
    6565
     
    7676    }
    7777
    78     function test_additional_sizes_with_filter() {
    79         add_filter( 'site_icon_image_sizes', array( $this, '_custom_test_sizes' ) );
     78    public function test_additional_sizes_with_filter() {
     79        add_filter( 'site_icon_image_sizes', array( $this, 'custom_test_sizes' ) );
    8080        $image_sizes = $this->wp_site_icon->additional_sizes( array() );
    8181
     
    9999    }
    100100
    101     function test_create_attachment_object() {
    102         $attachment_id = $this->_insert_attachment();
     101    public function test_create_attachment_object() {
     102        $attachment_id = $this->insert_attachment();
    103103        $parent_url    = get_post( $attachment_id )->guid;
    104104        $cropped       = str_replace( wp_basename( $parent_url ), 'cropped-test-image.jpg', $parent_url );
     
    113113    }
    114114
    115     function test_insert_cropped_attachment() {
    116         $attachment_id = $this->_insert_attachment();
     115    public function test_insert_cropped_attachment() {
     116        $attachment_id = $this->insert_attachment();
    117117        $parent_url    = get_post( $attachment_id )->guid;
    118118        $cropped       = str_replace( wp_basename( $parent_url ), 'cropped-test-image.jpg', $parent_url );
     
    125125    }
    126126
    127     function test_delete_attachment_data() {
    128         $attachment_id = $this->_insert_attachment();
     127    public function test_delete_attachment_data() {
     128        $attachment_id = $this->insert_attachment();
    129129        update_option( 'site_icon', $attachment_id );
    130130
     
    137137     * @ticket 34368
    138138     */
    139     function test_get_post_metadata() {
    140         $attachment_id = $this->_insert_attachment();
     139    public function test_get_post_metadata() {
     140        $attachment_id = $this->insert_attachment();
    141141        update_option( 'site_icon', $attachment_id );
    142142
     
    150150    }
    151151
    152     function _custom_test_sizes( $sizes ) {
     152    public function custom_test_sizes( $sizes ) {
    153153        $sizes[] = 321;
    154154
     
    156156    }
    157157
    158     function _insert_attachment() {
     158    private function insert_attachment() {
    159159        if ( $this->attachment_id ) {
    160160            return $this->attachment_id;
Note: See TracChangeset for help on using the changeset viewer.