Make WordPress Core


Ignore:
Timestamp:
03/19/2023 12:03:30 PM (15 months ago)
Author:
SergeyBiryukov
Message:

Tests: Use the data_ prefix for various data provider methods.

This aims to bring more consistency to the test suite, as the vast majority of data providers already use that prefix.

Includes moving some data providers next to the tests they are used in.

Follow-up to [55464].

See #57841.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/nav-menu.php

    r55035 r55562  
    967967
    968968    /**
     969     * @ticket 43401
     970     * @dataProvider data_iri_current_menu_item
     971     */
     972    public function test_iri_current_menu_item( $custom_link, $current = true ) {
     973        wp_update_nav_menu_item(
     974            $this->menu_id,
     975            0,
     976            array(
     977                'menu-item-status' => 'publish',
     978                'menu-item-type'   => 'custom',
     979                'menu-item-url'    => $custom_link,
     980            )
     981        );
     982
     983        $this->go_to( site_url( '/%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82/' ) );
     984
     985        $menu_items = wp_get_nav_menu_items( $this->menu_id );
     986        _wp_menu_item_classes_by_context( $menu_items );
     987
     988        $classes = $menu_items[0]->classes;
     989
     990        if ( $current ) {
     991            $this->assertContains( 'current-menu-item', $classes );
     992        } else {
     993            $this->assertNotContains( 'current-menu-item', $classes );
     994        }
     995    }
     996
     997    /**
    969998     * Provides IRI matching data for _wp_menu_item_classes_by_context() test.
    970999     */
    971     public function get_iri_current_menu_items() {
     1000    public function data_iri_current_menu_item() {
    9721001        return array(
    9731002            array( site_url( '/%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82/' ) ),
     
    9811010
    9821011    /**
    983      * @ticket 43401
    984      * @dataProvider get_iri_current_menu_items
    985      */
    986     public function test_iri_current_menu_item( $custom_link, $current = true ) {
    987         wp_update_nav_menu_item(
    988             $this->menu_id,
    989             0,
    990             array(
    991                 'menu-item-status' => 'publish',
    992                 'menu-item-type'   => 'custom',
    993                 'menu-item-url'    => $custom_link,
    994             )
    995         );
    996 
    997         $this->go_to( site_url( '/%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82/' ) );
    998 
    999         $menu_items = wp_get_nav_menu_items( $this->menu_id );
    1000         _wp_menu_item_classes_by_context( $menu_items );
    1001 
    1002         $classes = $menu_items[0]->classes;
    1003 
    1004         if ( $current ) {
    1005             $this->assertContains( 'current-menu-item', $classes );
    1006         } else {
    1007             $this->assertNotContains( 'current-menu-item', $classes );
    1008         }
    1009     }
    1010 
    1011     /**
    10121012     * @ticket 44005
    10131013     * @group privacy
Note: See TracChangeset for help on using the changeset viewer.