Make WordPress Core


Ignore:
Timestamp:
09/04/2020 07:01:00 AM (3 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/term/meta.php

    r48937 r48939  
    6767        );
    6868
    69         $this->assertEqualSets( $expected, $found );
     69        $this->assertSameSets( $expected, $found );
    7070    }
    7171
     
    7979        $expected = array( 'bar', 'baz' );
    8080
    81         $this->assertEqualSets( $expected, $found );
     81        $this->assertSameSets( $expected, $found );
    8282    }
    8383
     
    246246        );
    247247
    248         $this->assertEqualSets( array( $terms[0] ), $found );
     248        $this->assertSameSets( array( $terms[0] ), $found );
    249249
    250250        add_term_meta( $terms[1], 'foo', 'bar' );
     
    264264        );
    265265
    266         $this->assertEqualSets( array( $terms[0], $terms[1] ), $found );
     266        $this->assertSameSets( array( $terms[0], $terms[1] ), $found );
    267267    }
    268268
     
    288288        );
    289289
    290         $this->assertEqualSets( array( $terms[0] ), $found );
     290        $this->assertSameSets( array( $terms[0] ), $found );
    291291
    292292        update_term_meta( $terms[1], 'foo', 'bar' );
     
    306306        );
    307307
    308         $this->assertEqualSets( array( $terms[0], $terms[1] ), $found );
     308        $this->assertSameSets( array( $terms[0], $terms[1] ), $found );
    309309    }
    310310
     
    330330        );
    331331
    332         $this->assertEqualSets( array( $terms[0], $terms[1] ), $found );
     332        $this->assertSameSets( array( $terms[0], $terms[1] ), $found );
    333333
    334334        delete_term_meta( $terms[1], 'foo', 'bar' );
     
    348348        );
    349349
    350         $this->assertEqualSets( array( $terms[0] ), $found );
     350        $this->assertSameSets( array( $terms[0] ), $found );
    351351    }
    352352
Note: See TracChangeset for help on using the changeset viewer.