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/multisite/siteMeta.php

    r48937 r48939  
    122122            );
    123123
    124             $this->assertEqualSets( $expected, $found );
     124            $this->assertSameSets( $expected, $found );
    125125        }
    126126
     
    137137            $expected = array( 'bar', 'baz' );
    138138
    139             $this->assertEqualSets( $expected, $found );
     139            $this->assertSameSets( $expected, $found );
    140140        }
    141141
     
    300300            );
    301301
    302             $this->assertEqualSets( array( self::$site_id ), $found );
     302            $this->assertSameSets( array( self::$site_id ), $found );
    303303
    304304            add_site_meta( self::$site_id2, 'foo', 'bar' );
     
    316316            );
    317317
    318             $this->assertEqualSets( array( self::$site_id, self::$site_id2 ), $found );
     318            $this->assertSameSets( array( self::$site_id, self::$site_id2 ), $found );
    319319        }
    320320
     
    343343            );
    344344
    345             $this->assertEqualSets( array( self::$site_id ), $found );
     345            $this->assertSameSets( array( self::$site_id ), $found );
    346346
    347347            update_site_meta( self::$site_id2, 'foo', 'bar' );
     
    359359            );
    360360
    361             $this->assertEqualSets( array( self::$site_id, self::$site_id2 ), $found );
     361            $this->assertSameSets( array( self::$site_id, self::$site_id2 ), $found );
    362362        }
    363363
     
    386386            );
    387387
    388             $this->assertEqualSets( array( self::$site_id, self::$site_id2 ), $found );
     388            $this->assertSameSets( array( self::$site_id, self::$site_id2 ), $found );
    389389
    390390            delete_site_meta( self::$site_id2, 'foo', 'bar' );
     
    402402            );
    403403
    404             $this->assertEqualSets( array( self::$site_id ), $found );
     404            $this->assertSameSets( array( self::$site_id ), $found );
    405405        }
    406406    }
Note: See TracChangeset for help on using the changeset viewer.