Make WordPress Core


Ignore:
Timestamp:
09/04/2020 07:01:00 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Tests: Introduce assertSameSets() and assertSameSetsWithIndex(), and use them where appropriate.

This ensures that not only the array values being compared are equal, but also that their type is the same.

These new methods replace most of the existing instances of assertEqualSets() and assertEqualSetsWithIndex().

Going forward, stricter type checking by using assertSameSets() or assertSameSetsWithIndex() should generally be preferred, to make the tests more reliable.

Follow-up to [48937].

See #38266.

File:
1 edited

Legend:

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

    r48937 r48939  
    107107
    108108        $tag_items = wp_get_associated_nav_menu_items( $tag_id, 'taxonomy', 'post_tag' );
    109         $this->assertEqualSets( array( $tag_insert ), $tag_items );
     109        $this->assertSameSets( array( $tag_insert ), $tag_items );
    110110        $cat_items = wp_get_associated_nav_menu_items( $cat_id, 'taxonomy', 'category' );
    111         $this->assertEqualSets( array( $cat_insert ), $cat_items );
     111        $this->assertSameSets( array( $cat_insert ), $cat_items );
    112112        $post_items = wp_get_associated_nav_menu_items( $post_id );
    113         $this->assertEqualSets( array( $post_insert ), $post_items );
     113        $this->assertSameSets( array( $post_insert ), $post_items );
    114114        $post_2_items = wp_get_associated_nav_menu_items( $post_2_id );
    115         $this->assertEqualSets( array( $post_2_insert ), $post_2_items );
     115        $this->assertSameSets( array( $post_2_insert ), $post_2_items );
    116116        $page_items = wp_get_associated_nav_menu_items( $page_id );
    117         $this->assertEqualSets( array( $page_insert ), $page_items );
     117        $this->assertSameSets( array( $page_insert ), $page_items );
    118118
    119119        wp_delete_term( $tag_id, 'post_tag' );
    120120        $tag_items = wp_get_associated_nav_menu_items( $tag_id, 'taxonomy', 'post_tag' );
    121         $this->assertEqualSets( array(), $tag_items );
     121        $this->assertSameSets( array(), $tag_items );
    122122
    123123        wp_delete_term( $cat_id, 'category' );
    124124        $cat_items = wp_get_associated_nav_menu_items( $cat_id, 'taxonomy', 'category' );
    125         $this->assertEqualSets( array(), $cat_items );
     125        $this->assertSameSets( array(), $cat_items );
    126126
    127127        wp_delete_post( $post_id, true );
    128128        $post_items = wp_get_associated_nav_menu_items( $post_id );
    129         $this->assertEqualSets( array(), $post_items );
     129        $this->assertSameSets( array(), $post_items );
    130130
    131131        wp_delete_post( $post_2_id, true );
    132132        $post_2_items = wp_get_associated_nav_menu_items( $post_2_id );
    133         $this->assertEqualSets( array(), $post_2_items );
     133        $this->assertSameSets( array(), $post_2_items );
    134134
    135135        wp_delete_post( $page_id, true );
    136136        $page_items = wp_get_associated_nav_menu_items( $page_id );
    137         $this->assertEqualSets( array(), $page_items );
     137        $this->assertSameSets( array(), $page_items );
    138138    }
    139139
Note: See TracChangeset for help on using the changeset viewer.