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/functions/wpListUtil.php

    r48937 r48939  
    7474                'key',
    7575                array(
     76                    'bar',
    7677                    'bar'   => 'foo',
    7778                    'value' => 'baz',
    78                     'bar',
    7979                ),
    8080            ),
     
    145145                'key',
    146146                array(
     147                    'bar',
    147148                    'bar'   => 'foo',
    148149                    'value' => 'baz',
    149                     'bar',
    150150                ),
    151151            ),
     
    162162     */
    163163    public function test_wp_list_pluck( $list, $field, $index_key, $expected ) {
    164         $this->assertEqualSetsWithIndex( $expected, wp_list_pluck( $list, $field, $index_key ) );
     164        $this->assertSameSetsWithIndex( $expected, wp_list_pluck( $list, $field, $index_key ) );
    165165    }
    166166
     
    10241024        $util  = new WP_List_Util( $input );
    10251025
    1026         $this->assertEqualSets( $input, $util->get_input() );
     1026        $this->assertSameSets( $input, $util->get_input() );
    10271027    }
    10281028
     
    10311031        $util  = new WP_List_Util( $input );
    10321032
    1033         $this->assertEqualSets( $input, $util->get_output() );
     1033        $this->assertSameSets( $input, $util->get_output() );
    10341034    }
    10351035
Note: See TracChangeset for help on using the changeset viewer.