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/customize/setting.php

    r51568 r52010  
    1818    public $undefined;
    1919
    20     function set_up() {
     20    public function set_up() {
    2121        parent::set_up();
    2222        require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
     
    2626    }
    2727
    28     function tear_down() {
     28    public function tear_down() {
    2929        $this->manager = null;
    3030        unset( $GLOBALS['wp_customize'] );
     
    3232    }
    3333
    34     function test_constructor_without_args() {
     34    public function test_constructor_without_args() {
    3535        $setting = new WP_Customize_Setting( $this->manager, 'foo' );
    3636        $this->assertSame( $this->manager, $setting->manager );
     
    8585     * @param WP_Customize_Setting $setting The setting object.
    8686     */
    87     function sanitize_js_callback_base64_for_testing( $value, $setting ) {
     87    public function sanitize_js_callback_base64_for_testing( $value, $setting ) {
    8888        return base64_encode( $value );
    8989    }
    9090
    91     function test_constructor_with_args() {
     91    public function test_constructor_with_args() {
    9292        $args    = array(
    9393            'type'                 => 'option',
     
    137137     * @see WP_Customize_Setting::value()
    138138     */
    139     function test_preview_standard_types_non_multidimensional() {
     139    public function test_preview_standard_types_non_multidimensional() {
    140140        wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
    141141        $_POST['customized'] = wp_slash( wp_json_encode( $this->post_data_overrides ) );
     
    216216     * @see WP_Customize_Setting::value()
    217217     */
    218     function test_preview_standard_types_multidimensional() {
     218    public function test_preview_standard_types_multidimensional() {
    219219        wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
    220220        $_POST['customized'] = wp_slash( wp_json_encode( $this->post_data_overrides ) );
     
    317317    protected $custom_type_data_previewed;
    318318
    319     function custom_type_getter( $name, $default = null ) {
     319    private function custom_type_getter( $name, $default = null ) {
    320320        if ( did_action( "customize_preview_{$name}" ) && array_key_exists( $name, $this->custom_type_data_previewed ) ) {
    321321            $value = $this->custom_type_data_previewed[ $name ];
     
    328328    }
    329329
    330     function custom_type_setter( $name, $value ) {
     330    private function custom_type_setter( $name, $value ) {
    331331        $this->custom_type_data_saved[ $name ] = $value;
    332332    }
     
    340340     * @return mixed|null
    341341     */
    342     function custom_type_value_filter( $default, $setting = null ) {
     342    public function custom_type_value_filter( $default, $setting = null ) {
    343343        $name = preg_replace( '/^customize_value_/', '', current_filter() );
    344344        $this->assertInstanceOf( 'WP_Customize_Setting', $setting );
     
    351351     * @param WP_Customize_Setting $setting
    352352     */
    353     function custom_type_preview( $setting ) {
     353    public function custom_type_preview( $setting ) {
    354354        $previewed_value = $setting->post_value( $this->undefined );
    355355        if ( $this->undefined !== $previewed_value ) {
     
    362362     * @see WP_Customize_Setting::preview()
    363363     */
    364     function test_preview_custom_type() {
     364    public function test_preview_custom_type() {
    365365        wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
    366366        $type                = 'custom_type';
     
    474474     * @ticket 30988
    475475     */
    476     function test_non_posted_setting_applying_default_value_in_preview() {
     476    public function test_non_posted_setting_applying_default_value_in_preview() {
    477477        $type    = 'option';
    478478        $name    = 'unset_option_without_post_value';
     
    492492     * @see WP_Customize_Setting::update()
    493493     */
    494     function test_update_custom_type() {
     494    public function test_update_custom_type() {
    495495        $type    = 'custom';
    496496        $name    = 'foo';
     
    527527     * @param WP_Customize_Setting $setting
    528528     */
    529     function handle_customize_update_custom_foo_action( $value, $setting = null ) {
     529    public function handle_customize_update_custom_foo_action( $value, $setting = null ) {
    530530        $this->assertSame( 'hello world \\o/', $value );
    531531        $this->assertInstanceOf( 'WP_Customize_Setting', $setting );
     
    538538     * @param WP_Customize_Setting $setting
    539539     */
    540     function handle_customize_save_custom_foo_action( $setting ) {
     540    public function handle_customize_save_custom_foo_action( $setting ) {
    541541        $this->assertInstanceOf( 'WP_Customize_Setting', $setting );
    542542        $this->assertSame( 'custom', $setting->type );
     
    551551     * @ticket 31428
    552552     */
    553     function test_is_current_blog_previewed() {
     553    public function test_is_current_blog_previewed() {
    554554        wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
    555555        $type       = 'option';
     
    573573     * @group ms-required
    574574     */
    575     function test_previewing_with_switch_to_blog() {
     575    public function test_previewing_with_switch_to_blog() {
    576576        wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    577577        $type       = 'option';
     
    595595     * @ticket 33499
    596596     */
    597     function test_option_autoloading() {
     597    public function test_option_autoloading() {
    598598        global $wpdb;
    599599        wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
Note: See TracChangeset for help on using the changeset viewer.