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

    r48937 r48939  
    124124            );
    125125
    126             $this->assertEqualSets( array( self::$site_ids['www.w.org/'] ), $found );
     126            $this->assertSameSets( array( self::$site_ids['www.w.org/'] ), $found );
    127127        }
    128128
     
    150150            );
    151151
    152             $this->assertEqualSets( $expected, $found );
     152            $this->assertSameSets( $expected, $found );
    153153        }
    154154
     
    164164            );
    165165
    166             $this->assertEqualSets( $expected, $found );
     166            $this->assertSameSets( $expected, $found );
    167167        }
    168168
     
    200200            );
    201201
    202             $this->assertEqualSets( $expected, $found );
     202            $this->assertSameSets( $expected, $found );
    203203        }
    204204
     
    218218            );
    219219
    220             $this->assertEqualSets( $expected, $found );
     220            $this->assertSameSets( $expected, $found );
    221221        }
    222222
     
    266266            );
    267267
    268             $this->assertEqualSets( $expected, $found );
     268            $this->assertSameSets( $expected, $found );
    269269        }
    270270
     
    297297            );
    298298
    299             $this->assertEqualSets( $expected, $found );
     299            $this->assertSameSets( $expected, $found );
    300300        }
    301301
     
    316316            );
    317317
    318             $this->assertEqualSets( $expected, $found );
     318            $this->assertSameSets( $expected, $found );
    319319        }
    320320
     
    335335            );
    336336
    337             $this->assertEqualSets( $expected, $found );
     337            $this->assertSameSets( $expected, $found );
    338338        }
    339339
     
    352352            );
    353353
    354             $this->assertEqualSets( $expected, $found );
     354            $this->assertSameSets( $expected, $found );
    355355        }
    356356
     
    372372            );
    373373
    374             $this->assertEqualSets( $expected, $found );
     374            $this->assertSameSets( $expected, $found );
    375375        }
    376376
     
    393393            );
    394394
    395             $this->assertEqualSets( $expected, $found );
     395            $this->assertSameSets( $expected, $found );
    396396        }
    397397
     
    411411            );
    412412
    413             $this->assertEqualSets( $expected, $found );
     413            $this->assertSameSets( $expected, $found );
    414414        }
    415415
     
    428428            );
    429429
    430             $this->assertEqualSets( $expected, $found );
     430            $this->assertSameSets( $expected, $found );
    431431        }
    432432
     
    456456            );
    457457
    458             $this->assertEqualSets( array_values( self::$site_ids ), $found );
     458            $this->assertSameSets( array_values( self::$site_ids ), $found );
    459459        }
    460460
     
    470470            );
    471471
    472             $this->assertEqualSets( array_values( self::$site_ids ), $found );
     472            $this->assertSameSets( array_values( self::$site_ids ), $found );
    473473        }
    474474
     
    484484            );
    485485
    486             $this->assertEqualSets( array_values( self::$site_ids ), $found );
     486            $this->assertSameSets( array_values( self::$site_ids ), $found );
    487487        }
    488488
     
    498498            );
    499499
    500             $this->assertEqualSets( array_values( self::$site_ids ), $found );
     500            $this->assertSameSets( array_values( self::$site_ids ), $found );
    501501        }
    502502
     
    524524            );
    525525
    526             $this->assertEqualSets( array_values( self::$site_ids ), $found );
     526            $this->assertSameSets( array_values( self::$site_ids ), $found );
    527527        }
    528528
     
    538538            );
    539539
    540             $this->assertEqualSets( array_diff( array_values( self::$site_ids ), array( self::$site_ids['www.w.org/make/'] ) ), $found );
     540            $this->assertSameSets( array_diff( array_values( self::$site_ids ), array( self::$site_ids['www.w.org/make/'] ) ), $found );
    541541        }
    542542
     
    554554            );
    555555
    556             $this->assertEqualSets( $expected, $found );
     556            $this->assertSameSets( $expected, $found );
    557557        }
    558558
     
    582582            );
    583583
    584             $this->assertEqualSets( $expected, $found );
     584            $this->assertSameSets( $expected, $found );
    585585        }
    586586
     
    596596            );
    597597
    598             $this->assertEqualSets( array_values( self::$site_ids ), $found );
     598            $this->assertSameSets( array_values( self::$site_ids ), $found );
    599599        }
    600600
     
    612612            );
    613613
    614             $this->assertEqualSets( $expected, $found );
     614            $this->assertSameSets( $expected, $found );
    615615        }
    616616
     
    641641            );
    642642
    643             $this->assertEqualSets( $expected, $found );
     643            $this->assertSameSets( $expected, $found );
    644644        }
    645645
     
    661661            );
    662662
    663             $this->assertEqualSets( $expected, $found );
     663            $this->assertSameSets( $expected, $found );
    664664        }
    665665
     
    679679            );
    680680
    681             $this->assertEqualSets( $expected, $found );
     681            $this->assertSameSets( $expected, $found );
    682682        }
    683683
     
    752752            );
    753753
    754             $this->assertEqualSets( $expected, $found );
     754            $this->assertSameSets( $expected, $found );
    755755        }
    756756
     
    770770            );
    771771
    772             $this->assertEqualSets( $expected, $found );
     772            $this->assertSameSets( $expected, $found );
    773773        }
    774774
     
    787787            );
    788788
    789             $this->assertEqualSets( $expected, $found );
     789            $this->assertSameSets( $expected, $found );
    790790        }
    791791
     
    906906                $this->assertSame( $expected, $found );
    907907            } else {
    908                 $this->assertEqualSets( $expected, $found );
     908                $this->assertSameSets( $expected, $found );
    909909            }
    910910        }
Note: See TracChangeset for help on using the changeset viewer.