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/query/taxQuery.php

    r48937 r48939  
    298298        );
    299299
    300         $this->assertEqualSets( array( $p1, $p2 ), $q->posts );
     300        $this->assertSameSets( array( $p1, $p2 ), $q->posts );
    301301    }
    302302
     
    465465        );
    466466
    467         $this->assertEqualSets( array( $p1, $p3 ), $q->posts );
     467        $this->assertSameSets( array( $p1, $p3 ), $q->posts );
    468468    }
    469469
     
    512512        unregister_taxonomy( 'wptests_tax2' );
    513513
    514         $this->assertEqualSets( array( $p1, $p3, $p4 ), $q->posts );
     514        $this->assertSameSets( array( $p1, $p3, $p4 ), $q->posts );
    515515    }
    516516
     
    546546        );
    547547
    548         $this->assertEqualSets( array( $p2 ), $q->posts );
     548        $this->assertSameSets( array( $p2 ), $q->posts );
    549549    }
    550550
     
    581581        );
    582582
    583         $this->assertEqualSets( array( $p2 ), $q->posts );
     583        $this->assertSameSets( array( $p2 ), $q->posts );
    584584    }
    585585
     
    706706        );
    707707
    708         $this->assertEqualSets( array( $p1, $p2 ), $q->posts );
     708        $this->assertSameSets( array( $p1, $p2 ), $q->posts );
    709709    }
    710710
     
    752752        );
    753753
    754         $this->assertEqualSets( array( $p1, $p2 ), $q->posts );
     754        $this->assertSameSets( array( $p1, $p2 ), $q->posts );
    755755    }
    756756
     
    834834        _unregister_taxonomy( 'bar' );
    835835
    836         $this->assertEqualSets( array( $p1, $p2 ), $q->posts );
     836        $this->assertSameSets( array( $p1, $p2 ), $q->posts );
    837837    }
    838838
     
    908908        _unregister_taxonomy( 'bar' );
    909909
    910         $this->assertEqualSets( array( $p1, $p2 ), $q->posts );
     910        $this->assertSameSets( array( $p1, $p2 ), $q->posts );
    911911    }
    912912
     
    991991        _unregister_taxonomy( 'bar' );
    992992
    993         $this->assertEqualSets( array( $p1, $p2, $p3 ), $q->posts );
     993        $this->assertSameSets( array( $p1, $p2, $p3 ), $q->posts );
    994994    }
    995995
     
    16221622        );
    16231623
    1624         $this->assertEqualSets( array( $p ), $q->posts );
     1624        $this->assertSameSets( array( $p ), $q->posts );
    16251625    }
    16261626}
Note: See TracChangeset for help on using the changeset viewer.