Make WordPress Core


Ignore:
Timestamp:
11/04/2021 03:22:47 PM (5 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/meta.php

    r51568 r52010  
    77        protected $updated_mids = array();
    88
    9         function set_up() {
     9        public function set_up() {
    1010                parent::set_up();
    1111                $this->author         = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) );
    … …  
    1414        }
    1515
    16         function _meta_sanitize_cb( $meta_value, $meta_key, $meta_type ) {
     16        public function meta_sanitize_cb( $meta_value, $meta_key, $meta_type ) {
    1717                return 'sanitized';
    1818        }
    1919
    20         function test_sanitize_meta() {
     20        public function test_sanitize_meta() {
    2121                $meta = sanitize_meta( 'some_meta', 'unsanitized', 'post' );
    2222                $this->assertSame( 'unsanitized', $meta );
    2323
    24                 register_meta( 'post', 'some_meta', array( $this, '_meta_sanitize_cb' ) );
     24                register_meta( 'post', 'some_meta', array( $this, 'meta_sanitize_cb' ) );
    2525                $meta = sanitize_meta( 'some_meta', 'unsanitized', 'post' );
    2626                $this->assertSame( 'sanitized', $meta );
    2727        }
    2828
    29         function test_delete_metadata_by_mid() {
     29        public function test_delete_metadata_by_mid() {
    3030                // Let's try and delete a non-existing ID, non existing meta.
    3131                $this->assertFalse( delete_metadata_by_mid( 'user', 0 ) );
    … …  
    4242        }
    4343
    44         function test_update_metadata_by_mid() {
     44        public function test_update_metadata_by_mid() {
    4545                // Setup.
    4646                $meta = get_metadata_by_mid( 'user', $this->meta_id );
    … …  
    105105        }
    106106
    107         function test_metadata_exists() {
     107        public function test_metadata_exists() {
    108108                $this->assertFalse( metadata_exists( 'user', $this->author->ID, 'foobarbaz' ) );
    109109                $this->assertTrue( metadata_exists( 'user', $this->author->ID, 'meta_key' ) );
    … …  
    115115         * @ticket 22746
    116116         */
    117         function test_metadata_exists_with_filter() {
     117        public function test_metadata_exists_with_filter() {
    118118                // Let's see if it returns the correct value when adding a filter.
    119119                add_filter( 'get_user_metadata', '__return_zero' );
    … …  
    126126         * @ticket 18158
    127127         */
    128         function test_user_metadata_not_exists() {
     128        public function test_user_metadata_not_exists() {
    129129                $u = get_users(
    130130                        array(
    … …  
    199199        }
    200200
    201         function test_metadata_slashes() {
     201        public function test_metadata_slashes() {
    202202                $key       = __FUNCTION__;
    203203                $value     = 'Test\\singleslash';
    … …  
    232232         * @ticket 16814
    233233         */
    234         function test_meta_type_cast() {
     234        public function test_meta_type_cast() {
    235235                $post_id1 = self::factory()->post->create();
    236236                add_post_meta( $post_id1, 'num_as_longtext', 123 );
    … …  
    302302        }
    303303
    304         function test_meta_cache_order_asc() {
     304        public function test_meta_cache_order_asc() {
    305305                $post_id = self::factory()->post->create();
    306306                $colors  = array( 'red', 'blue', 'yellow', 'green' );
    … …  
    322322         * @ticket 28315
    323323         */
    324         function test_non_numeric_object_id() {
     324        public function test_non_numeric_object_id() {
    325325                $this->assertFalse( add_metadata( 'user', array( 1 ), 'meta_key', 'meta_value' ) );
    326326                $this->assertFalse( update_metadata( 'user', array( 1 ), 'meta_key', 'meta_new_value' ) );
    … …  
    333333         * @ticket 28315
    334334         */
    335         function test_non_numeric_meta_id() {
     335        public function test_non_numeric_meta_id() {
    336336                $this->assertFalse( get_metadata_by_mid( 'user', array( 1 ) ) );
    337337                $this->assertFalse( update_metadata_by_mid( 'user', array( 1 ), 'meta_new_value' ) );
    … …  
    342342         * @ticket 37746
    343343         */
    344         function test_negative_meta_id() {
     344        public function test_negative_meta_id() {
    345345                $negative_mid = $this->meta_id * -1;
    346346
    … …  
    354354         * @ticket 37746
    355355         */
    356         function test_floating_meta_id() {
     356        public function test_floating_meta_id() {
    357357                $floating_mid = $this->meta_id + 0.1337;
    358358
    … …  
    366366         * @ticket 37746
    367367         */
    368         function test_string_point_zero_meta_id() {
     368        public function test_string_point_zero_meta_id() {
    369369                $meta_id = add_metadata( 'user', $this->author->ID, 'meta_key', 'meta_value_2' );
    370370
Note: See TracChangeset for help on using the changeset viewer.