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/post/wpPostType.php

    r46586 r48939  
    2323        $post_type_supports_after = get_all_post_type_supports( $post_type );
    2424
    25         $this->assertEqualSets(
     25        $this->assertSameSets(
    2626            array(
    2727                'title'  => true,
     
    3030            $post_type_supports
    3131        );
    32         $this->assertEqualSets( array(), $post_type_supports_after );
     32        $this->assertSameSets( array(), $post_type_supports_after );
    3333    }
    3434
     
    5252        $post_type_supports_after = get_all_post_type_supports( $post_type );
    5353
    54         $this->assertEqualSets(
     54        $this->assertSameSets(
    5555            array(
    5656                'editor'    => true,
     
    6060            $post_type_supports
    6161        );
    62         $this->assertEqualSets( array(), $post_type_supports_after );
     62        $this->assertSameSets( array(), $post_type_supports_after );
    6363    }
    6464
     
    8989        $post_type_supports_after = get_all_post_type_supports( $post_type );
    9090
    91         $this->assertEqualSets(
     91        $this->assertSameSets(
    9292            array(
    9393                'support_with_args'    => array(
     
    101101            $post_type_supports
    102102        );
    103         $this->assertEqualSets( array(), $post_type_supports_after );
     103        $this->assertSameSets( array(), $post_type_supports_after );
    104104    }
    105105
     
    214214        unset( $wp_post_types[ $post_type ] );
    215215
    216         $this->assertEqualSets( array( 'post_tag' ), $taxonomies );
    217         $this->assertEqualSets( array(), $taxonomies_after );
     216        $this->assertSameSets( array( 'post_tag' ), $taxonomies );
     217        $this->assertSameSets( array(), $taxonomies_after );
    218218    }
    219219}
Note: See TracChangeset for help on using the changeset viewer.