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

    r48937 r48939  
    164164
    165165        $this->assertNotWPError( $response );
    166         $this->assertEqualSetsWithIndex( $this->get_user_location(), $response['location'] );
     166        $this->assertSameSetsWithIndex( $this->get_user_location(), $response['location'] );
    167167        $this->assertSame( gmdate( 'l, M j, Y', strtotime( 'next Sunday 1pm' ) ), $response['events'][0]['formatted_date'] );
    168168        $this->assertSame( '1:00 pm', $response['events'][0]['formatted_time'] );
     
    185185
    186186        $this->assertNotWPError( $cached_events );
    187         $this->assertEqualSetsWithIndex( $this->get_user_location(), $cached_events['location'] );
     187        $this->assertSameSetsWithIndex( $this->get_user_location(), $cached_events['location'] );
    188188        $this->assertSame( gmdate( 'l, M j, Y', strtotime( 'next Sunday 1pm' ) ), $cached_events['events'][0]['formatted_date'] );
    189189        $this->assertSame( '1:00 pm', $cached_events['events'][0]['formatted_time'] );
Note: See TracChangeset for help on using the changeset viewer.