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

    r48937 r48939  
    13791379
    13801380        $tags = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) );
    1381         $this->assertEqualSets( array( $tag_1['term_id'], $tag_2['term_id'] ), $tags );
     1381        $this->assertSameSets( array( $tag_1['term_id'], $tag_2['term_id'] ), $tags );
    13821382
    13831383        wp_update_post( $post );
    13841384
    13851385        $tags = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) );
    1386         $this->assertEqualSets( array( $tag_1['term_id'], $tag_2['term_id'] ), $tags );
     1386        $this->assertSameSets( array( $tag_1['term_id'], $tag_2['term_id'] ), $tags );
    13871387
    13881388        wp_update_post(
     
    13941394
    13951395        $tags = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) );
    1396         $this->assertEqualSets( array( $tag_2['term_id'], $tag_3['term_id'] ), $tags );
     1396        $this->assertSameSets( array( $tag_2['term_id'], $tag_3['term_id'] ), $tags );
    13971397    }
    13981398}
Note: See TracChangeset for help on using the changeset viewer.