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

    r48937 r48939  
    2424        $data     = $response->get_data();
    2525        $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] );
    26         $this->assertEqualSets( array( 'embed', 'view', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
     26        $this->assertSameSets( array( 'embed', 'view', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
    2727        // Single.
    2828        $request  = new WP_REST_Request( 'OPTIONS', '/wp/v2/statuses/publish' );
     
    3030        $data     = $response->get_data();
    3131        $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] );
    32         $this->assertEqualSets( array( 'embed', 'view', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
     32        $this->assertSameSets( array( 'embed', 'view', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
    3333    }
    3434
     
    5252        $data = $response->get_data();
    5353        $this->assertSame( 6, count( $data ) );
    54         $this->assertEqualSets(
     54        $this->assertSameSets(
    5555            array(
    5656                'publish',
     
    213213        $this->assertSame( $status_obj->show_in_admin_all_list, $data['show_in_list'] );
    214214        $this->assertSame( $status_obj->name, $data['slug'] );
    215         $this->assertEqualSets(
     215        $this->assertSameSets(
    216216            array(
    217217                'archives',
Note: See TracChangeset for help on using the changeset viewer.