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/ajax/ManageThemes.php

    r47198 r48939  
    7171        );
    7272
    73         $this->assertEqualSets( $expected, $response );
     73        $this->assertSameSets( $expected, $response );
    7474    }
    7575
     
    9393                'update'       => 'theme',
    9494                'slug'         => 'foo',
    95                 'errorMessage' => 'Sorry, you are not allowed to update themes for this site.',
    9695                'oldVersion'   => '',
    9796                'newVersion'   => '',
     97                'errorMessage' => 'Sorry, you are not allowed to update themes for this site.',
    9898            ),
    9999        );
    100100
    101         $this->assertEqualSets( $expected, $response );
     101        $this->assertSameSets( $expected, $response );
    102102    }
    103103
     
    129129                'update'       => 'theme',
    130130                'slug'         => 'twentyten',
    131                 'errorMessage' => 'The theme is at the latest version.',
    132131                'oldVersion'   => $theme->get( 'Version' ),
    133132                'newVersion'   => '',
    134133                'debug'        => array( 'The theme is at the latest version.' ),
     134                'errorMessage' => 'The theme is at the latest version.',
    135135            ),
    136136        );
    137137
    138         $this->assertEqualSets( $expected, $response );
     138        $this->assertSameSets( $expected, $response );
    139139    }
    140140
     
    162162                'oldVersion'   => '1.0',
    163163                'newVersion'   => '',
     164                'debug'        => array( 'The theme is at the latest version.' ),
    164165                'errorMessage' => 'The theme is at the latest version.',
    165                 'debug'        => array( 'The theme is at the latest version.' ),
    166166            ),
    167167        );
    168168
    169         $this->assertEqualSets( $expected, $response );
     169        $this->assertSameSets( $expected, $response );
    170170    }
    171171}
Note: See TracChangeset for help on using the changeset viewer.