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

    r48937 r48939  
    154154        );
    155155
    156         $this->assertEqualSets( array( $p2 ), $q->posts );
     156        $this->assertSameSets( array( $p2 ), $q->posts );
    157157    }
    158158
     
    181181        );
    182182
    183         $this->assertEqualSets( array( $p2 ), $q->posts );
     183        $this->assertSameSets( array( $p2 ), $q->posts );
    184184    }
    185185
     
    214214        );
    215215
    216         $this->assertEqualSets( array( $p3 ), $q->posts );
     216        $this->assertSameSets( array( $p3 ), $q->posts );
    217217    }
    218218
     
    247247        );
    248248
    249         $this->assertEqualSets( array( $p1, $p3 ), $q->posts );
     249        $this->assertSameSets( array( $p1, $p3 ), $q->posts );
    250250    }
    251251
     
    293293        );
    294294
    295         $this->assertEqualSets( array( $p2 ), $q->posts );
     295        $this->assertSameSets( array( $p2 ), $q->posts );
    296296    }
    297297
     
    346346        );
    347347
    348         $this->assertEqualSets( array( $p1, $p3 ), $q->posts );
     348        $this->assertSameSets( array( $p1, $p3 ), $q->posts );
    349349
    350350        $q = new WP_Query(
     
    355355        );
    356356
    357         $this->assertEqualSets( array( $p1, $p2 ), $q->posts );
     357        $this->assertSameSets( array( $p1, $p2 ), $q->posts );
    358358
    359359        $q = new WP_Query(
     
    364364        );
    365365
    366         $this->assertEqualSets( array( $p2 ), $q->posts );
     366        $this->assertSameSets( array( $p2 ), $q->posts );
    367367    }
    368368
Note: See TracChangeset for help on using the changeset viewer.