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/option/siteOption.php

    r48937 r52010  
    55 */
    66class Tests_Option_SiteOption extends WP_UnitTestCase {
    7     function __return_foo() {
     7    public function __return_foo() {
    88        return 'foo';
    99    }
    1010
    11     function test_get_site_option_returns_false_if_option_does_not_exist() {
     11    public function test_get_site_option_returns_false_if_option_does_not_exist() {
    1212        $this->assertFalse( get_site_option( 'doesnotexist' ) );
    1313    }
    1414
    15     function test_get_site_option_returns_false_after_deletion() {
     15    public function test_get_site_option_returns_false_after_deletion() {
    1616        $key   = __FUNCTION__;
    1717        $value = __FUNCTION__;
     
    2121    }
    2222
    23     function test_get_site_option_returns_value() {
     23    public function test_get_site_option_returns_value() {
    2424        $key   = __FUNCTION__;
    2525        $value = __FUNCTION__;
     
    2828    }
    2929
    30     function test_get_site_option_returns_updated_value() {
     30    public function test_get_site_option_returns_updated_value() {
    3131        $key       = __FUNCTION__;
    3232        $value     = __FUNCTION__ . '_1';
     
    3737    }
    3838
    39     function test_get_site_option_does_not_exist_returns_filtered_default_with_no_default_provided() {
     39    public function test_get_site_option_does_not_exist_returns_filtered_default_with_no_default_provided() {
    4040        add_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) );
    4141        $site_option = get_site_option( 'doesnotexist' );
     
    4444    }
    4545
    46     function test_get_site_option_does_not_exist_returns_filtered_default_with_default_provided() {
     46    public function test_get_site_option_does_not_exist_returns_filtered_default_with_default_provided() {
    4747        add_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) );
    4848        $site_option = get_site_option( 'doesnotexist', 'bar' );
     
    5151    }
    5252
    53     function test_get_site_option_does_not_exist_returns_provided_default() {
     53    public function test_get_site_option_does_not_exist_returns_provided_default() {
    5454        $this->assertSame( 'bar', get_site_option( 'doesnotexist', 'bar' ) );
    5555    }
    5656
    57     function test_get_site_option_exists_does_not_return_provided_default() {
     57    public function test_get_site_option_exists_does_not_return_provided_default() {
    5858        $key   = __FUNCTION__;
    5959        $value = __FUNCTION__;
     
    6262    }
    6363
    64     function test_get_site_option_exists_does_not_return_filtered_default() {
     64    public function test_get_site_option_exists_does_not_return_filtered_default() {
    6565        $key   = __FUNCTION__;
    6666        $value = __FUNCTION__;
     
    7272    }
    7373
    74     function test_add_site_option_returns_true_for_new_option() {
     74    public function test_add_site_option_returns_true_for_new_option() {
    7575        $key   = __FUNCTION__;
    7676        $value = __FUNCTION__;
     
    7878    }
    7979
    80     function test_add_site_option_returns_false_for_existing_option() {
     80    public function test_add_site_option_returns_false_for_existing_option() {
    8181        $key   = __FUNCTION__;
    8282        $value = __FUNCTION__;
     
    8585    }
    8686
    87     function test_update_site_option_returns_false_for_same_value() {
     87    public function test_update_site_option_returns_false_for_same_value() {
    8888        $key   = __FUNCTION__;
    8989        $value = __FUNCTION__;
     
    9292    }
    9393
    94     function test_update_site_option_returns_true_for_new_value() {
     94    public function test_update_site_option_returns_true_for_new_value() {
    9595        $key       = 'key';
    9696        $value     = 'value1';
     
    100100    }
    101101
    102     function test_delete_site_option_returns_true_if_option_exists() {
     102    public function test_delete_site_option_returns_true_if_option_exists() {
    103103        $key   = __FUNCTION__;
    104104        $value = __FUNCTION__;
     
    107107    }
    108108
    109     function test_delete_site_option_returns_false_if_option_does_not_exist() {
     109    public function test_delete_site_option_returns_false_if_option_does_not_exist() {
    110110        $key   = __FUNCTION__;
    111111        $value = __FUNCTION__;
     
    115115    }
    116116
    117     function test_site_option_add_and_get_serialized_array() {
     117    public function test_site_option_add_and_get_serialized_array() {
    118118        $key   = __FUNCTION__;
    119119        $value = array(
     
    125125    }
    126126
    127     function test_site_option_add_and_get_serialized_object() {
     127    public function test_site_option_add_and_get_serialized_object() {
    128128        $key        = __FUNCTION__;
    129129        $value      = new stdClass();
     
    139139     * @ticket 15497
    140140     */
    141     function test_update_adds_falsey_value() {
     141    public function test_update_adds_falsey_value() {
    142142        $key   = __FUNCTION__;
    143143        $value = 0;
     
    154154     * @ticket 18955
    155155     */
    156     function test_get_doesnt_cache_default_value() {
     156    public function test_get_doesnt_cache_default_value() {
    157157        $option  = __FUNCTION__;
    158158        $default = 'a default';
Note: See TracChangeset for help on using the changeset viewer.