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

    r48937 r48939  
    280280
    281281        $expected = array( 'post' );
    282         $this->assertEqualSets( $expected, $tax->object_type );
     282        $this->assertSameSets( $expected, $tax->object_type );
    283283    }
    284284
     
    495495        );
    496496
    497         $this->assertEqualSets( array( $t2, $t1 ), get_ancestors( $t3, 'wptests_tax' ) );
     497        $this->assertSameSets( array( $t2, $t1 ), get_ancestors( $t3, 'wptests_tax' ) );
    498498        _unregister_taxonomy( 'wptests_tax' );
    499499    }
     
    507507        );
    508508
    509         $this->assertEqualSets( array(), get_ancestors( $p, 'wptests_tax' ) );
     509        $this->assertSameSets( array(), get_ancestors( $p, 'wptests_tax' ) );
    510510    }
    511511
     
    541541        );
    542542
    543         $this->assertEqualSets( array( $p2, $p1 ), get_ancestors( $p3, 'wptests_pt' ) );
     543        $this->assertSameSets( array( $p2, $p1 ), get_ancestors( $p3, 'wptests_pt' ) );
    544544        _unregister_post_type( 'wptests_pt' );
    545545    }
     
    586586        );
    587587
    588         $this->assertEqualSets( array( $p1 ), get_ancestors( $p2, 'wptests_conflict', 'post_type' ) );
    589         $this->assertEqualSets( array( $t1 ), get_ancestors( $t2, 'wptests_conflict', 'taxonomy' ) );
    590         $this->assertEqualSets( array( $t1 ), get_ancestors( $t2, 'wptests_conflict' ) );
     588        $this->assertSameSets( array( $p1 ), get_ancestors( $p2, 'wptests_conflict', 'post_type' ) );
     589        $this->assertSameSets( array( $t1 ), get_ancestors( $t2, 'wptests_conflict', 'taxonomy' ) );
     590        $this->assertSameSets( array( $t1 ), get_ancestors( $t2, 'wptests_conflict' ) );
    591591        _unregister_post_type( 'wptests_pt' );
    592592    }
Note: See TracChangeset for help on using the changeset viewer.