WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/04/2020 07:01:00 AM (3 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/wpDeleteObjectTermRelationships.php

    r46586 r48939  
    2020        // Confirm the setup.
    2121        $terms = wp_get_object_terms( $object_id, array( 'wptests_tax1', 'wptests_tax2' ), array( 'fields' => 'ids' ) );
    22         $this->assertEqualSets( array( $t1, $t2 ), $terms );
     22        $this->assertSameSets( array( $t1, $t2 ), $terms );
    2323
    2424        // wp_delete_object_term_relationships() doesn't have a return value.
     
    2626        $terms = wp_get_object_terms( $object_id, array( 'wptests_tax1', 'wptests_tax2' ), array( 'fields' => 'ids' ) );
    2727
    28         $this->assertEqualSets( array( $t1 ), $terms );
     28        $this->assertSameSets( array( $t1 ), $terms );
    2929    }
    3030
     
    4646        // Confirm the setup.
    4747        $terms = wp_get_object_terms( $object_id, array( 'wptests_tax1', 'wptests_tax2', 'wptests_tax3' ), array( 'fields' => 'ids' ) );
    48         $this->assertEqualSets( array( $t1, $t2, $t3 ), $terms );
     48        $this->assertSameSets( array( $t1, $t2, $t3 ), $terms );
    4949
    5050        // wp_delete_object_term_relationships() doesn't have a return value.
     
    5252        $terms = wp_get_object_terms( $object_id, array( 'wptests_tax1', 'wptests_tax2', 'wptests_tax3' ), array( 'fields' => 'ids' ) );
    5353
    54         $this->assertEqualSets( array( $t2 ), $terms );
     54        $this->assertSameSets( array( $t2 ), $terms );
    5555    }
    5656}
Note: See TracChangeset for help on using the changeset viewer.