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/widgets.php

    r51568 r52010  
    2121    protected $backup_registered_sidebars;
    2222
    23     function set_up() {
     23    public function set_up() {
    2424        parent::set_up();
    2525        require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
     
    7979    }
    8080
    81     function clean_up_global_scope() {
     81    public function clean_up_global_scope() {
    8282        global $wp_widget_factory, $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates;
    8383
     
    9191    }
    9292
    93     function tear_down() {
     93    public function tear_down() {
    9494        $this->manager = null;
    9595        unset( $GLOBALS['wp_customize'] );
     
    9999    }
    100100
    101     function set_customized_post_data( $customized ) {
     101    private function set_customized_post_data( $customized ) {
    102102        $_POST['customized'] = wp_slash( wp_json_encode( $customized ) );
    103103        if ( $this->manager ) {
     
    108108    }
    109109
    110     function do_customize_boot_actions() {
     110    private function do_customize_boot_actions() {
    111111        $_SERVER['REQUEST_METHOD'] = 'POST';
    112112        $_REQUEST['nonce']         = wp_create_nonce( 'preview-customize_' . $this->manager->theme()->get_stylesheet() );
     
    118118    }
    119119
    120     function remove_widgets_block_editor() {
     120    public function remove_widgets_block_editor() {
    121121        remove_theme_support( 'widgets-block-editor' );
    122122    }
     
    125125     * Test WP_Customize_Widgets::__construct()
    126126     */
    127     function test_construct() {
     127    public function test_construct() {
    128128        $this->assertInstanceOf( 'WP_Customize_Widgets', $this->manager->widgets );
    129129        $this->assertSame( $this->manager, $this->manager->widgets->manager );
     
    137137     * @ticket 36660
    138138     */
    139     function test_customize_register_with_deleted_sidebars() {
     139    public function test_customize_register_with_deleted_sidebars() {
    140140        $sidebar_id = 'sidebar-1';
    141141        delete_option( 'sidebars_widgets' );
     
    229229     * @see WP_Customize_Widgets::get_selective_refreshable_widgets()
    230230     */
    231     function test_get_selective_refreshable_widgets_when_theme_supports() {
     231    public function test_get_selective_refreshable_widgets_when_theme_supports() {
    232232        global $wp_widget_factory;
    233233        add_action( 'widgets_init', array( $this, 'override_search_widget_customize_selective_refresh' ), 90 );
     
    249249     * @see WP_Customize_Widgets::get_selective_refreshable_widgets()
    250250     */
    251     function test_get_selective_refreshable_widgets_when_no_theme_supports() {
     251    public function test_get_selective_refreshable_widgets_when_no_theme_supports() {
    252252        add_action( 'widgets_init', array( $this, 'override_search_widget_customize_selective_refresh' ), 90 );
    253253        remove_theme_support( 'customize-selective-refresh-widgets' );
     
    263263     * @see Tests_WP_Customize_Widgets::test_get_selective_refreshable_widgets_when_no_theme_supports()
    264264     */
    265     function override_search_widget_customize_selective_refresh() {
     265    public function override_search_widget_customize_selective_refresh() {
    266266        global $wp_widget_factory;
    267267        $wp_widget_factory->widgets['WP_Widget_Search']->widget_options['customize_selective_refresh'] = false;
     
    273273     * @see WP_Customize_Widgets::is_widget_selective_refreshable()
    274274     */
    275     function test_is_widget_selective_refreshable() {
     275    public function test_is_widget_selective_refreshable() {
    276276        add_action( 'widgets_init', array( $this, 'override_search_widget_customize_selective_refresh' ), 90 );
    277277        add_theme_support( 'customize-selective-refresh-widgets' );
     
    289289     * @ticket 36389
    290290     */
    291     function test_register_settings() {
     291    public function test_register_settings() {
    292292        add_theme_support( 'customize-selective-refresh-widgets' );
    293293
     
    341341     * @ticket 36389
    342342     */
    343     function test_register_settings_without_selective_refresh() {
     343    public function test_register_settings_without_selective_refresh() {
    344344        remove_theme_support( 'customize-selective-refresh-widgets' );
    345345        $this->test_register_settings();
     
    351351     * @ticket 36389
    352352     */
    353     function test_register_settings_with_late_theme_support_added() {
     353    public function test_register_settings_with_late_theme_support_added() {
    354354        remove_theme_support( 'customize-selective-refresh-widgets' );
    355355        add_action( 'after_setup_theme', array( $this, 'add_customize_selective_refresh_theme_support' ), 100 );
     
    360360     * Add customize-selective-refresh-widgets theme support.
    361361     */
    362     function add_customize_selective_refresh_theme_support() {
     362    public function add_customize_selective_refresh_theme_support() {
    363363        add_theme_support( 'customize-selective-refresh-widgets' );
    364364    }
     
    367367     * Test WP_Customize_Widgets::get_setting_args()
    368368     */
    369     function test_get_setting_args() {
     369    public function test_get_setting_args() {
    370370        add_theme_support( 'customize-selective-refresh-widgets' );
    371371        $this->do_customize_boot_actions();
     
    448448    }
    449449
    450     function filter_widget_customizer_setting_args( $args, $id ) {
     450    public function filter_widget_customizer_setting_args( $args, $id ) {
    451451        $args['uppercase_id_set_by_filter'] = strtoupper( $id );
    452452        return $args;
     
    456456     * Test WP_Customize_Widgets::sanitize_widget_js_instance() and WP_Customize_Widgets::sanitize_widget_instance()
    457457     */
    458     function test_sanitize_widget_js_instance() {
     458    public function test_sanitize_widget_js_instance() {
    459459        $this->do_customize_boot_actions();
    460460
     
    487487     * @ticket 53489
    488488     */
    489     function test_sanitize_widget_instance_raw_instance() {
     489    public function test_sanitize_widget_instance_raw_instance() {
    490490        remove_action( 'widgets_init', array( $this, 'remove_widgets_block_editor' ) );
    491491        $this->do_customize_boot_actions();
     
    514514     * @ticket 53489
    515515     */
    516     function test_sanitize_widget_instance_with_no_show_instance_in_rest() {
     516    public function test_sanitize_widget_instance_with_no_show_instance_in_rest() {
    517517        global $wp_widget_factory;
    518518
     
    545545     * @ticket 53479
    546546     */
    547     function test_sanitize_widget_instance_empty_instance() {
     547    public function test_sanitize_widget_instance_empty_instance() {
    548548        $this->do_customize_boot_actions();
    549549        $this->assertSame( $this->manager->widgets->sanitize_widget_instance( array() ), array() );
     
    555555     * @return array
    556556     */
    557     function get_test_widget_control_args() {
     557    private function get_test_widget_control_args() {
    558558        global $wp_registered_widgets;
    559559        require_once ABSPATH . '/wp-admin/includes/widgets.php';
     
    576576     * @see WP_Customize_Widgets::get_widget_control()
    577577     */
    578     function test_get_widget_control() {
     578    public function test_get_widget_control() {
    579579        $this->do_customize_boot_actions();
    580580        $widget_control = $this->manager->widgets->get_widget_control( $this->get_test_widget_control_args() );
     
    589589     * @see WP_Customize_Widgets::get_widget_control_parts()
    590590     */
    591     function test_get_widget_control_parts() {
     591    public function test_get_widget_control_parts() {
    592592        $this->do_customize_boot_actions();
    593593        $widget_control_parts = $this->manager->widgets->get_widget_control_parts( $this->get_test_widget_control_args() );
     
    605605     * @see WP_Widget_Form_Customize_Control::json()
    606606     */
    607     function test_wp_widget_form_customize_control_json() {
     607    public function test_wp_widget_form_customize_control_json() {
    608608        $this->do_customize_boot_actions();
    609609        $control = $this->manager->get_control( 'widget_search[2]' );
     
    627627     * @see WP_Customize_Widgets::is_panel_active()
    628628     */
    629     function test_is_panel_active() {
     629    public function test_is_panel_active() {
    630630        global $wp_registered_sidebars;
    631631        $this->do_customize_boot_actions();
     
    644644     * @see WP_Customize_Widgets::call_widget_update()
    645645     */
    646     function test_call_widget_update() {
     646    public function test_call_widget_update() {
    647647
    648648        $widget_number = 2;
     
    700700     * @see WP_Customize_Widgets::customize_dynamic_partial_args()
    701701     */
    702     function test_customize_dynamic_partial_args() {
     702    public function test_customize_dynamic_partial_args() {
    703703        do_action( 'customize_register', $this->manager );
    704704
     
    726726     * @see WP_Customize_Widgets::selective_refresh_init()
    727727     */
    728     function test_selective_refresh_init_with_theme_support() {
     728    public function test_selective_refresh_init_with_theme_support() {
    729729        add_theme_support( 'customize-selective-refresh-widgets' );
    730730        $this->manager->widgets->selective_refresh_init();
     
    740740     * @see WP_Customize_Widgets::selective_refresh_init()
    741741     */
    742     function test_selective_refresh_init_without_theme_support() {
     742    public function test_selective_refresh_init_without_theme_support() {
    743743        remove_theme_support( 'customize-selective-refresh-widgets' );
    744744        $this->manager->widgets->selective_refresh_init();
     
    754754     * @see WP_Customize_Widgets::customize_preview_enqueue()
    755755     */
    756     function test_customize_preview_enqueue() {
     756    public function test_customize_preview_enqueue() {
    757757        $this->manager->widgets->customize_preview_enqueue();
    758758        $this->assertTrue( wp_script_is( 'customize-preview-widgets', 'enqueued' ) );
     
    769769     * @see WP_Customize_Widgets::end_dynamic_sidebar()
    770770     */
    771     function test_filter_dynamic_sidebar_params() {
     771    public function test_filter_dynamic_sidebar_params() {
    772772        global $wp_registered_sidebars;
    773773        register_sidebar(
     
    824824     * @see WP_Customize_Widgets::render_widget_partial()
    825825     */
    826     function test_render_widget_partial() {
     826    public function test_render_widget_partial() {
    827827        add_theme_support( 'customize-selective-refresh-widgets' );
    828828        $this->do_customize_boot_actions();
Note: See TracChangeset for help on using the changeset viewer.