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/rest-api/rest-pages-controller.php

    r48937 r48939  
    185185        $data     = $response->get_data();
    186186        $this->assertSame( 2, count( $data ) );
    187         $this->assertEqualSets( array( $id2, $id4 ), wp_list_pluck( $data, 'id' ) );
     187        $this->assertSameSets( array( $id2, $id4 ), wp_list_pluck( $data, 'id' ) );
    188188    }
    189189
     
    255255        $response = rest_get_server()->dispatch( $request );
    256256        $data     = $response->get_data();
    257         $this->assertEqualSets( array( $id1, $id2, $id3, $id4 ), wp_list_pluck( $data, 'id' ) );
     257        $this->assertSameSets( array( $id1, $id2, $id3, $id4 ), wp_list_pluck( $data, 'id' ) );
    258258
    259259        // Filter to 'menu_order'.
     
    261261        $response = rest_get_server()->dispatch( $request );
    262262        $data     = $response->get_data();
    263         $this->assertEqualSets( array( $id4 ), wp_list_pluck( $data, 'id' ) );
     263        $this->assertSameSets( array( $id4 ), wp_list_pluck( $data, 'id' ) );
    264264
    265265        // Order by 'menu order'.
Note: See TracChangeset for help on using the changeset viewer.