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/post/nav-menu.php

    r51568 r52010  
    1010    public $menu_id;
    1111
    12     function set_up() {
     12    public function set_up() {
    1313        parent::set_up();
    1414
     
    4444    }
    4545
    46     function test_wp_get_associated_nav_menu_items() {
     46    public function test_wp_get_associated_nav_menu_items() {
    4747        $tag_id    = self::factory()->tag->create();
    4848        $cat_id    = self::factory()->category->create();
     
    141141     * @ticket 27113
    142142     */
    143     function test_orphan_nav_menu_item() {
     143    public function test_orphan_nav_menu_item() {
    144144
    145145        // Create an orphan nav menu item.
     
    206206     * @ticket 13910
    207207     */
    208     function test_wp_get_nav_menu_name() {
     208    public function test_wp_get_nav_menu_name() {
    209209        // Register a nav menu location.
    210210        register_nav_menu( 'primary', 'Primary Navigation' );
     
    225225     * @ticket 29460
    226226     */
    227     function test_orderby_name_by_default() {
     227    public function test_orderby_name_by_default() {
    228228        // We are going to create a random number of menus (min 2, max 10).
    229229        $menus_no = rand( 2, 10 );
     
    254254     * @ticket 35324
    255255     */
    256     function test_wp_setup_nav_menu_item_for_post_type_archive() {
     256    public function test_wp_setup_nav_menu_item_for_post_type_archive() {
    257257
    258258        $post_type_slug        = rand_str( 12 );
     
    287287     * @ticket 35324
    288288     */
    289     function test_wp_setup_nav_menu_item_for_post_type_archive_no_description() {
     289    public function test_wp_setup_nav_menu_item_for_post_type_archive_no_description() {
    290290
    291291        $post_type_slug        = rand_str( 12 );
     
    318318     * @ticket 35324
    319319     */
    320     function test_wp_setup_nav_menu_item_for_post_type_archive_custom_description() {
     320    public function test_wp_setup_nav_menu_item_for_post_type_archive_custom_description() {
    321321
    322322        $post_type_slug        = rand_str( 12 );
     
    353353     * @ticket 35324
    354354     */
    355     function test_wp_setup_nav_menu_item_for_unknown_post_type_archive_no_description() {
     355    public function test_wp_setup_nav_menu_item_for_unknown_post_type_archive_no_description() {
    356356
    357357        $post_type_slug = rand_str( 12 );
     
    374374     * @ticket 19038
    375375     */
    376     function test_wp_setup_nav_menu_item_for_trashed_post() {
     376    public function test_wp_setup_nav_menu_item_for_trashed_post() {
    377377        $post_id = self::factory()->post->create(
    378378            array(
     
    400400     * @ticket 35206
    401401     */
    402     function test_wp_nav_menu_whitespace_options() {
     402    public function test_wp_nav_menu_whitespace_options() {
    403403        $post_id1 = self::factory()->post->create();
    404404        $post_id2 = self::factory()->post->create();
     
    487487     * @ticket 24587
    488488     */
    489     function test_wp_nav_menu_filters_are_passed_args_object() {
     489    public function test_wp_nav_menu_filters_are_passed_args_object() {
    490490        $tag_id = self::factory()->tag->create();
    491491
     
    506506         */
    507507        // In function.
    508         add_filter( 'pre_wp_nav_menu', array( $this, '_confirm_second_param_args_object' ), 10, 2 );
    509         add_filter( 'wp_nav_menu_objects', array( $this, '_confirm_second_param_args_object' ), 10, 2 );
    510         add_filter( 'wp_nav_menu_items', array( $this, '_confirm_second_param_args_object' ), 10, 2 );
     508        add_filter( 'pre_wp_nav_menu', array( $this, 'confirm_second_param_args_object' ), 10, 2 );
     509        add_filter( 'wp_nav_menu_objects', array( $this, 'confirm_second_param_args_object' ), 10, 2 );
     510        add_filter( 'wp_nav_menu_items', array( $this, 'confirm_second_param_args_object' ), 10, 2 );
    511511
    512512        // In walker.
    513         add_filter( 'nav_menu_item_args', array( $this, '_confirm_nav_menu_item_args_object' ) );
    514 
    515         add_filter( 'nav_menu_css_class', array( $this, '_confirm_third_param_args_object' ), 10, 3 );
    516         add_filter( 'nav_menu_item_id', array( $this, '_confirm_third_param_args_object' ), 10, 3 );
    517         add_filter( 'nav_menu_link_attributes', array( $this, '_confirm_third_param_args_object' ), 10, 3 );
    518         add_filter( 'nav_menu_item_title', array( $this, '_confirm_third_param_args_object' ), 10, 3 );
    519 
    520         add_filter( 'walker_nav_menu_start_el', array( $this, '_confirm_forth_param_args_object' ), 10, 4 );
     513        add_filter( 'nav_menu_item_args', array( $this, 'confirm_nav_menu_item_args_object' ) );
     514
     515        add_filter( 'nav_menu_css_class', array( $this, 'confirm_third_param_args_object' ), 10, 3 );
     516        add_filter( 'nav_menu_item_id', array( $this, 'confirm_third_param_args_object' ), 10, 3 );
     517        add_filter( 'nav_menu_link_attributes', array( $this, 'confirm_third_param_args_object' ), 10, 3 );
     518        add_filter( 'nav_menu_item_title', array( $this, 'confirm_third_param_args_object' ), 10, 3 );
     519
     520        add_filter( 'walker_nav_menu_start_el', array( $this, 'confirm_forth_param_args_object' ), 10, 4 );
    521521
    522522        wp_nav_menu(
     
    532532         */
    533533        // In function.
    534         remove_filter( 'pre_wp_nav_menu', array( $this, '_confirm_second_param_args_object' ), 10, 2 );
    535         remove_filter( 'wp_nav_menu_objects', array( $this, '_confirm_second_param_args_object' ), 10, 2 );
    536         remove_filter( 'wp_nav_menu_items', array( $this, '_confirm_second_param_args_object' ), 10, 2 );
     534        remove_filter( 'pre_wp_nav_menu', array( $this, 'confirm_second_param_args_object' ), 10, 2 );
     535        remove_filter( 'wp_nav_menu_objects', array( $this, 'confirm_second_param_args_object' ), 10, 2 );
     536        remove_filter( 'wp_nav_menu_items', array( $this, 'confirm_second_param_args_object' ), 10, 2 );
    537537
    538538        // In walker.
    539         remove_filter( 'nav_menu_item_args', array( $this, '_confirm_nav_menu_item_args_object' ) );
    540 
    541         remove_filter( 'nav_menu_css_class', array( $this, '_confirm_third_param_args_object' ), 10, 3 );
    542         remove_filter( 'nav_menu_item_id', array( $this, '_confirm_third_param_args_object' ), 10, 3 );
    543         remove_filter( 'nav_menu_link_attributes', array( $this, '_confirm_third_param_args_object' ), 10, 3 );
    544         remove_filter( 'nav_menu_item_title', array( $this, '_confirm_third_param_args_object' ), 10, 3 );
    545 
    546         remove_filter( 'walker_nav_menu_start_el', array( $this, '_confirm_forth_param_args_object' ), 10, 4 );
     539        remove_filter( 'nav_menu_item_args', array( $this, 'confirm_nav_menu_item_args_object' ) );
     540
     541        remove_filter( 'nav_menu_css_class', array( $this, 'confirm_third_param_args_object' ), 10, 3 );
     542        remove_filter( 'nav_menu_item_id', array( $this, 'confirm_third_param_args_object' ), 10, 3 );
     543        remove_filter( 'nav_menu_link_attributes', array( $this, 'confirm_third_param_args_object' ), 10, 3 );
     544        remove_filter( 'nav_menu_item_title', array( $this, 'confirm_third_param_args_object' ), 10, 3 );
     545
     546        remove_filter( 'walker_nav_menu_start_el', array( $this, 'confirm_forth_param_args_object' ), 10, 4 );
    547547
    548548    }
     
    551551     * Run tests required to confrim Walker_Nav_Menu receives an $args object.
    552552     */
    553     function _confirm_nav_menu_item_args_object( $args ) {
     553    public function confirm_nav_menu_item_args_object( $args ) {
    554554        $this->assertIsObject( $args );
    555555        return $args;
    556556    }
    557557
    558     function _confirm_second_param_args_object( $ignored_1, $args ) {
     558    public function confirm_second_param_args_object( $ignored_1, $args ) {
    559559        $this->assertIsObject( $args );
    560560        return $ignored_1;
    561561    }
    562562
    563     function _confirm_third_param_args_object( $ignored_1, $ignored_2, $args ) {
     563    public function confirm_third_param_args_object( $ignored_1, $ignored_2, $args ) {
    564564        $this->assertIsObject( $args );
    565565        return $ignored_1;
    566566    }
    567567
    568     function _confirm_forth_param_args_object( $ignored_1, $ignored_2, $ignored_3, $args ) {
     568    public function confirm_forth_param_args_object( $ignored_1, $ignored_2, $ignored_3, $args ) {
    569569        $this->assertIsObject( $args );
    570570        return $ignored_1;
     
    575575     * @ticket 35272
    576576     */
    577     function test_no_front_page_class_applied() {
     577    public function test_no_front_page_class_applied() {
    578578        $page_id = self::factory()->post->create(
    579579            array(
     
    606606     * @ticket 35272
    607607     */
    608     function test_class_applied_to_front_page_item() {
     608    public function test_class_applied_to_front_page_item() {
    609609        $page_id = self::factory()->post->create(
    610610            array(
     
    639639     * @ticket 35272
    640640     */
    641     function test_class_not_applied_to_taxonomies_with_same_id_as_front_page_item() {
     641    public function test_class_not_applied_to_taxonomies_with_same_id_as_front_page_item() {
    642642        global $wpdb;
    643643
     
    682682     * @covers ::_wp_delete_customize_changeset_dependent_auto_drafts
    683683     */
    684     function test_wp_delete_customize_changeset_dependent_auto_drafts() {
     684    public function test_wp_delete_customize_changeset_dependent_auto_drafts() {
    685685        $auto_draft_post_id = $this->factory()->post->create(
    686686            array(
     
    736736     * @ticket 39800
    737737     */
    738     function test_parent_ancestor_for_post_archive() {
     738    public function test_parent_ancestor_for_post_archive() {
    739739
    740740        register_post_type(
     
    822822     * Provides IRI matching data for _wp_menu_item_classes_by_context() test.
    823823     */
    824     function get_iri_current_menu_items() {
     824    public function get_iri_current_menu_items() {
    825825        return array(
    826826            array( site_url( '/%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82/' ) ),
     
    837837     * @dataProvider get_iri_current_menu_items
    838838     */
    839     function test_iri_current_menu_item( $custom_link, $current = true ) {
     839    public function test_iri_current_menu_item( $custom_link, $current = true ) {
    840840        wp_update_nav_menu_item(
    841841            $this->menu_id,
     
    866866     * @group privacy
    867867     */
    868     function test_no_privacy_policy_class_applied() {
     868    public function test_no_privacy_policy_class_applied() {
    869869        $page_id = self::factory()->post->create(
    870870            array(
     
    897897     * @group privacy
    898898     */
    899     function test_class_applied_to_privacy_policy_page_item() {
     899    public function test_class_applied_to_privacy_policy_page_item() {
    900900        $page_id = self::factory()->post->create(
    901901            array(
     
    931931     * @dataProvider data_trim_url_for_custom_item
    932932     */
    933     function test_trim_url_for_custom_item( $custom_url, $correct_url ) {
     933    public function test_trim_url_for_custom_item( $custom_url, $correct_url ) {
    934934        $custom_item_id = wp_update_nav_menu_item(
    935935            $this->menu_id,
     
    950950     * Provides data for test_trim_url_for_custom_item().
    951951     */
    952     function data_trim_url_for_custom_item() {
     952    public function data_trim_url_for_custom_item() {
    953953        return array(
    954954            array( 'https://wordpress.org ', 'https://wordpress.org' ),
     
    965965     * @ticket 48011
    966966     */
    967     function test_wp_update_nav_menu_item_with_special_characters_in_category_name() {
     967    public function test_wp_update_nav_menu_item_with_special_characters_in_category_name() {
    968968        $category_name = 'Test Cat - \"Pre-Slashed\" Cat Name & >';
    969969
     
    10021002     * @ticket 52189
    10031003     */
    1004     function test_wp_update_nav_menu_item_with_post_date() {
     1004    public function test_wp_update_nav_menu_item_with_post_date() {
    10051005        $post_date     = '2020-12-28 11:26:35';
    10061006        $post_date_gmt = '2020-12-29 10:11:45';
Note: See TracChangeset for help on using the changeset viewer.