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

    r51791 r52010  
    1010        public $valid_sidebar;
    1111
    12         function clean_up_global_scope() {
     12        public function clean_up_global_scope() {
    1313                global $wp_widget_factory, $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates;
    1414
     
    2222        }
    2323
    24         function tear_down() {
     24        public function tear_down() {
    2525                global $wp_customize;
    2626
     
    3434         * @see unregister_widget()
    3535         */
    36         function test_register_and_unregister_widget_core_widget() {
     36        public function test_register_and_unregister_widget_core_widget() {
    3737                global $wp_widget_factory;
    3838
     
    5353         * @ticket 28216
    5454         */
    55         function test_register_and_unregister_widget_instance() {
     55        public function test_register_and_unregister_widget_instance() {
    5656                global $wp_widget_factory, $wp_registered_widgets;
    5757
     
    130130         * @group sidebar
    131131         */
    132         function test_register_sidebars_single() {
     132        public function test_register_sidebars_single() {
    133133                global $wp_registered_sidebars;
    134134
     
    142142         * @group sidebar
    143143         */
    144         function test_register_sidebars_multiple() {
     144        public function test_register_sidebars_multiple() {
    145145                global $wp_registered_sidebars;
    146146
     
    164164         * @group sidebar
    165165         */
    166         function test_register_sidebar_with_no_id() {
     166        public function test_register_sidebar_with_no_id() {
    167167                global $wp_registered_sidebars;
    168168
     
    181181         * @group sidebar
    182182         */
    183         function test_unregister_sidebar_registered_with_no_id() {
     183        public function test_unregister_sidebar_registered_with_no_id() {
    184184                global $wp_registered_sidebars;
    185185
     
    200200         * @group sidebar
    201201         */
    202         function test_register_sidebar_with_string_id() {
     202        public function test_register_sidebar_with_string_id() {
    203203                global $wp_registered_sidebars;
    204204
     
    212212         * @group sidebar
    213213         */
    214         function test_unregister_sidebar_with_string_id() {
     214        public function test_unregister_sidebar_with_string_id() {
    215215                global $wp_registered_sidebars;
    216216
     
    225225         * @group sidebar
    226226         */
    227         function test_register_sidebar_with_numeric_id() {
     227        public function test_register_sidebar_with_numeric_id() {
    228228                global $wp_registered_sidebars;
    229229
     
    237237         * @group sidebar
    238238         */
    239         function test_unregister_sidebar_with_numeric_id() {
     239        public function test_unregister_sidebar_with_numeric_id() {
    240240                global $wp_registered_sidebars;
    241241
     
    293293         * Utility hook callback used to store a sidebar ID mid-function.
    294294         */
    295         function retrieve_sidebar_id( $index, $valid_sidebar ) {
     295        public function retrieve_sidebar_id( $index, $valid_sidebar ) {
    296296                $this->sidebar_index = $index;
    297297                $this->valid_sidebar = $valid_sidebar;
     
    301301         * @group sidebar
    302302         */
    303         function test_dynamic_sidebar_using_sidebar_registered_with_no_id() {
     303        public function test_dynamic_sidebar_using_sidebar_registered_with_no_id() {
    304304                $this->setExpectedIncorrectUsage( 'register_sidebar' );
    305305
     
    320320         * @group sidebar
    321321         */
    322         function test_dynamic_sidebar_using_invalid_sidebar_id() {
     322        public function test_dynamic_sidebar_using_invalid_sidebar_id() {
    323323                register_sidebar( array( 'id' => 'wp-unit-text' ) );
    324324
     
    338338         * @group sidebar
    339339         */
    340         function test_dynamic_sidebar_numeric_id() {
     340        public function test_dynamic_sidebar_numeric_id() {
    341341                $sidebar_id = 2;
    342342                register_sidebar( array( 'id' => $sidebar_id ) );
     
    352352         * @group sidebar
    353353         */
    354         function test_dynamic_sidebar_string_id() {
     354        public function test_dynamic_sidebar_string_id() {
    355355                $sidebar_id = 'wp-unit-tests';
    356356                register_sidebar( array( 'id' => $sidebar_id ) );
     
    366366         * @see WP_Widget_Search::form()
    367367         */
    368         function test_wp_widget_search_form() {
     368        public function test_wp_widget_search_form() {
    369369                $widget = new WP_Widget_Search( 'foo', 'Foo' );
    370370                ob_start();
     
    388388         * @see WP_Widget::form()
    389389         */
    390         function test_wp_widget_form() {
     390        public function test_wp_widget_form() {
    391391                $widget = new WP_Widget( 'foo', 'Foo' );
    392392                ob_start();
     
    400400         * @see WP_Widget::__construct()
    401401         */
    402         function test_wp_widget_constructor() {
     402        public function test_wp_widget_constructor() {
    403403                $id_base    = 'foo';
    404404                $name       = 'Foo';
     
    431431         * @dataProvider data_wp_widget_classname
    432432         */
    433         function test_wp_widget_classname( $expected, $widget_class ) {
     433        public function test_wp_widget_classname( $expected, $widget_class ) {
    434434                require_once DIR_TESTDATA . '/widgets/custom-widget-classes.php';
    435435
     
    453453         * }
    454454         */
    455         function data_wp_widget_classname() {
     455        public function data_wp_widget_classname() {
    456456                return array(
    457457                        array(
     
    474474         * @dataProvider data_wp_widget_get_field_name
    475475         */
    476         function test_wp_widget_get_field_name( $expected, $value_to_test ) {
     476        public function test_wp_widget_get_field_name( $expected, $value_to_test ) {
    477477                $widget = new WP_Widget( 'foo', 'Foo' );
    478478                $widget->_set( 2 );
     
    494494         * }
    495495         */
    496         function data_wp_widget_get_field_name() {
     496        public function data_wp_widget_get_field_name() {
    497497                return array(
    498498                        array(
     
    523523         * @dataProvider data_wp_widget_get_field_id
    524524         */
    525         function test_wp_widget_get_field_id( $expected, $value_to_test ) {
     525        public function test_wp_widget_get_field_id( $expected, $value_to_test ) {
    526526                $widget = new WP_Widget( 'foo', 'Foo' );
    527527                $widget->_set( 2 );
     
    544544         * }
    545545         */
    546         function data_wp_widget_get_field_id() {
     546        public function data_wp_widget_get_field_id() {
    547547                return array(
    548548                        array(
     
    572572         * @see WP_Widget::_register()
    573573         */
    574         function test_wp_widget__register() {
     574        public function test_wp_widget__register() {
    575575                global $wp_registered_widgets;
    576576
     
    594594         * @see WP_Widget::is_preview()
    595595         */
    596         function test_wp_widget_is_preview() {
     596        public function test_wp_widget_is_preview() {
    597597                global $wp_customize;
    598598
     
    617617         * @see WP_Widget::get_settings()
    618618         */
    619         function test_wp_widget_get_settings() {
     619        public function test_wp_widget_get_settings() {
    620620                global $wp_registered_widgets;
    621621
     
    654654         * @see WP_Widget::save_settings()
    655655         */
    656         function test_wp_widget_save_settings() {
     656        public function test_wp_widget_save_settings() {
    657657                global $wp_registered_widgets;
    658658
     
    685685         * @see WP_Widget::save_settings()
    686686         */
    687         function test_wp_widget_save_settings_delete() {
     687        public function test_wp_widget_save_settings_delete() {
    688688                global $wp_registered_widgets;
    689689
     
    702702         * @see wp_widget_control()
    703703         */
    704         function test_wp_widget_control() {
     704        public function test_wp_widget_control() {
    705705                global $wp_registered_widgets;
    706706
     
    780780        }
    781781
    782         function test_the_widget_custom_before_title_arg() {
     782        public function test_the_widget_custom_before_title_arg() {
    783783                register_widget( 'WP_Widget_Text' );
    784784
     
    809809         * @see \the_widget()
    810810         */
    811         function test_the_widget_with_unregistered_widget() {
     811        public function test_the_widget_with_unregistered_widget() {
    812812                $this->setExpectedIncorrectUsage( 'the_widget' );
    813813                the_widget( 'Widget_Class' );
     
    835835         * @param array $sidebars Sidebar slugs.
    836836         */
    837         function register_sidebars( $sidebars ) {
     837        private function register_sidebars( $sidebars ) {
    838838                foreach ( $sidebars as $sidebar ) {
    839839                        register_sidebar( array( 'id' => $sidebar ) );
     
    846846         * @covers ::retrieve_widgets
    847847         */
    848         function test_retrieve_widgets_with_theme_mod() {
     848        public function test_retrieve_widgets_with_theme_mod() {
    849849                global $sidebars_widgets, $_wp_sidebars_widgets;
    850850
     
    909909         * @covers ::retrieve_widgets
    910910         */
    911         function test_retrieve_widgets_with_sidebars_widgets_matching_registered_sidebars() {
     911        public function test_retrieve_widgets_with_sidebars_widgets_matching_registered_sidebars() {
    912912                global $sidebars_widgets;
    913913
     
    947947         * @covers ::retrieve_widgets
    948948         */
    949         function test_retrieve_widgets_with_sidebars_widgets_not_matching_registered_sidebars() {
     949        public function test_retrieve_widgets_with_sidebars_widgets_not_matching_registered_sidebars() {
    950950                global $sidebars_widgets, $_wp_sidebars_widgets;
    951951
     
    10391039         * @covers ::retrieve_widgets
    10401040         */
    1041         function test_retrieve_widgets_for_customizer() {
     1041        public function test_retrieve_widgets_for_customizer() {
    10421042                global $sidebars_widgets, $_wp_sidebars_widgets;
    10431043
     
    10831083        }
    10841084
    1085         function test_retrieve_widgets_with_single_widget() {
     1085        public function test_retrieve_widgets_with_single_widget() {
    10861086                global $sidebars_widgets;
    10871087
     
    11101110         * @covers ::retrieve_widgets
    11111111         */
    1112         function test_retrieve_widgets_move_orphaned_widgets_to_inactive() {
     1112        public function test_retrieve_widgets_move_orphaned_widgets_to_inactive() {
    11131113                global $sidebars_widgets;
    11141114
Note: See TracChangeset for help on using the changeset viewer.