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/dependencies/scripts.php

    r48937 r48939  
    10531053        $this->assertNonEmptyMultidimensionalArray( $wp_enqueue_code_editor );
    10541054
    1055         $this->assertEqualSets( array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ), array_keys( $wp_enqueue_code_editor ) );
    1056         $this->assertEqualSets(
     1055        $this->assertSameSets( array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ), array_keys( $wp_enqueue_code_editor ) );
     1056        $this->assertSameSets(
    10571057            array(
    10581058                'autoCloseBrackets',
     
    10761076        $this->assertEmpty( $wp_enqueue_code_editor['codemirror']['gutters'] );
    10771077
    1078         $this->assertEqualSets(
     1078        $this->assertSameSets(
    10791079            array(
    10801080                'errors',
     
    10881088        );
    10891089
    1090         $this->assertEqualSets(
     1090        $this->assertSameSets(
    10911091            array(
    10921092                'boss',
     
    11101110        );
    11111111
    1112         $this->assertEqualSets(
     1112        $this->assertSameSets(
    11131113            array(
    11141114                'tagname-lowercase',
     
    11401140        $this->assertNonEmptyMultidimensionalArray( $wp_enqueue_code_editor );
    11411141
    1142         $this->assertEqualSets( array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ), array_keys( $wp_enqueue_code_editor ) );
    1143         $this->assertEqualSets(
     1142        $this->assertSameSets( array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ), array_keys( $wp_enqueue_code_editor ) );
     1143        $this->assertSameSets(
    11441144            array(
    11451145                'continueComments',
     
    11591159        $this->assertEmpty( $wp_enqueue_code_editor['codemirror']['gutters'] );
    11601160
    1161         $this->assertEqualSets(
     1161        $this->assertSameSets(
    11621162            array(
    11631163                'errors',
     
    11711171        );
    11721172
    1173         $this->assertEqualSets(
     1173        $this->assertSameSets(
    11741174            array(
    11751175                'boss',
     
    11931193        );
    11941194
    1195         $this->assertEqualSets(
     1195        $this->assertSameSets(
    11961196            array(
    11971197                'tagname-lowercase',
     
    12341234        $this->assertNonEmptyMultidimensionalArray( $wp_enqueue_code_editor );
    12351235
    1236         $this->assertEqualSets( array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ), array_keys( $wp_enqueue_code_editor ) );
    1237         $this->assertEqualSets(
     1236        $this->assertSameSets( array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ), array_keys( $wp_enqueue_code_editor ) );
     1237        $this->assertSameSets(
    12381238            array(
    12391239                'autoCloseBrackets',
     
    12561256        );
    12571257
    1258         $this->assertEqualSets(
     1258        $this->assertSameSets(
    12591259            array(
    12601260                'errors',
     
    12681268        );
    12691269
    1270         $this->assertEqualSets(
     1270        $this->assertSameSets(
    12711271            array(
    12721272                'boss',
     
    12901290        );
    12911291
    1292         $this->assertEqualSets(
     1292        $this->assertSameSets(
    12931293            array(
    12941294                'tagname-lowercase',
     
    13281328        $this->assertNonEmptyMultidimensionalArray( $wp_enqueue_code_editor );
    13291329
    1330         $this->assertEqualSets( array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ), array_keys( $wp_enqueue_code_editor ) );
    1331         $this->assertEqualSets(
     1330        $this->assertSameSets( array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ), array_keys( $wp_enqueue_code_editor ) );
     1331        $this->assertSameSets(
    13321332            array(
    13331333                'autoCloseBrackets',
     
    13501350        );
    13511351
    1352         $this->assertEqualSets(
     1352        $this->assertSameSets(
    13531353            array(
    13541354                'errors',
     
    13621362        );
    13631363
    1364         $this->assertEqualSets(
     1364        $this->assertSameSets(
    13651365            array(
    13661366                'boss',
     
    13841384        );
    13851385
    1386         $this->assertEqualSets(
     1386        $this->assertSameSets(
    13871387            array(
    13881388                'tagname-lowercase',
Note: See TracChangeset for help on using the changeset viewer.