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/admin/includesTheme.php

    r48937 r48939  
    4949        switch_theme( $theme['Template'], $theme['Stylesheet'] );
    5050
    51         $this->assertEqualSetsWithIndex(
     51        $this->assertSameSetsWithIndex(
    5252            array(
    5353                'Top Level'                           => 'template-top-level.php',
     
    6363        switch_theme( $theme['Template'], $theme['Stylesheet'] );
    6464
    65         $this->assertEqualSetsWithIndex(
     65        $this->assertSameSetsWithIndex(
    6666            array(
    6767                'Top Level'                           => 'template-top-level.php',
     
    8282        switch_theme( $theme['Template'], $theme['Stylesheet'] );
    8383
    84         $this->assertEqualSetsWithIndex(
     84        $this->assertSameSetsWithIndex(
    8585            array(
    8686                'Top Level' => 'template-top-level-post-types.php',
     
    8989            get_page_templates( null, 'foo' )
    9090        );
    91         $this->assertEqualSetsWithIndex(
     91        $this->assertSameSetsWithIndex(
    9292            array(
    9393                'Top Level' => 'template-top-level-post-types.php',
     
    108108        switch_theme( $theme['Template'], $theme['Stylesheet'] );
    109109
    110         $this->assertEqualSetsWithIndex(
     110        $this->assertSameSetsWithIndex(
    111111            array(
    112112                'No Trailing Period'            => '38766/no-trailing-period-post-types.php',
     
    119119            get_page_templates( null, 'period' )
    120120        );
    121         $this->assertEqualSetsWithIndex(
     121        $this->assertSameSetsWithIndex(
    122122            array(
    123123                'No Trailing Period'            => '38766/no-trailing-period-post-types.php',
     
    140140        switch_theme( $theme['Template'], $theme['Stylesheet'] );
    141141
    142         $this->assertEqualSetsWithIndex(
     142        $this->assertSameSetsWithIndex(
    143143            array(
    144144                'Top Level'                  => 'template-top-level-post-types.php',
     
    150150        );
    151151
    152         $this->assertEqualSetsWithIndex(
     152        $this->assertSameSetsWithIndex(
    153153            array(
    154154                'Top Level' => 'template-top-level-post-types.php',
     
    158158        );
    159159
    160         $this->assertEqualSetsWithIndex(
     160        $this->assertSameSetsWithIndex(
    161161            array(
    162162                'Top Level'                           => 'template-top-level.php',
     
    181181        $post_templates = $theme->get_post_templates();
    182182
    183         $this->assertEqualSetsWithIndex(
     183        $this->assertSameSetsWithIndex(
    184184            array(
    185185                'template-top-level-post-types.php'       => 'Top Level',
     
    191191        );
    192192
    193         $this->assertEqualSetsWithIndex(
     193        $this->assertSameSetsWithIndex(
    194194            array(
    195195                'template-top-level-post-types.php'      => 'Top Level',
     
    199199        );
    200200
    201         $this->assertEqualSetsWithIndex(
     201        $this->assertSameSetsWithIndex(
    202202            array(
    203203                'template-top-level.php'      => 'Top Level',
Note: See TracChangeset for help on using the changeset viewer.