WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/04/2020 07:01:00 AM (17 months 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/term/wpGetObjectTerms.php

    r48937 r48939  
    590590        );
    591591
    592         $this->assertEqualSets( array( $t1, $t2 ), $found );
     592        $this->assertSameSets( array( $t1, $t2 ), $found );
    593593    }
    594594
     
    744744        );
    745745
    746         $this->assertEqualSets( array( $terms[0], $terms[1] ), wp_list_pluck( $found, 'term_id' ) );
     746        $this->assertSameSets( array( $terms[0], $terms[1] ), wp_list_pluck( $found, 'term_id' ) );
    747747    }
    748748
     
    867867        );
    868868
    869         $this->assertEqualSets( array( $t1, $t2 ), wp_list_pluck( $found, 'term_id' ) );
     869        $this->assertSameSets( array( $t1, $t2 ), wp_list_pluck( $found, 'term_id' ) );
    870870
    871871        $num_queries = $wpdb->num_queries;
     
    893893        );
    894894
    895         $this->assertEqualSets( $posts, wp_list_pluck( $found, 'object_id' ) );
     895        $this->assertSameSets( $posts, wp_list_pluck( $found, 'object_id' ) );
    896896    }
    897897
     
    10001000        );
    10011001
    1002         $this->assertEqualSets( $expected, $actual );
     1002        $this->assertSameSets( $expected, $actual );
    10031003    }
    10041004}
Note: See TracChangeset for help on using the changeset viewer.