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/user/query.php

    r48937 r48939  
    848848        $expected = array( self::$author_ids[0] );
    849849
    850         $this->assertEqualSets( $expected, $found );
     850        $this->assertSameSets( $expected, $found );
    851851    }
    852852
     
    889889        $expected = array( self::$author_ids[1], self::$author_ids[2] );
    890890
    891         $this->assertEqualSets( $expected, $found );
     891        $this->assertSameSets( $expected, $found );
    892892    }
    893893
     
    930930        $expected = array( self::$author_ids[2] );
    931931
    932         $this->assertEqualSets( $expected, $found );
     932        $this->assertSameSets( $expected, $found );
    933933    }
    934934
     
    975975        $expected = array( self::$author_ids[1] );
    976976
    977         $this->assertEqualSets( $expected, $found );
     977        $this->assertSameSets( $expected, $found );
    978978    }
    979979
     
    10051005        $expected = array( self::$author_ids[0], self::$author_ids[1] );
    10061006
    1007         $this->assertEqualSets( $expected, $found );
     1007        $this->assertSameSets( $expected, $found );
    10081008    }
    10091009
     
    10431043        $expected = array( self::$author_ids[0], self::$author_ids[1] );
    10441044
    1045         $this->assertEqualSets( $expected, $found );
     1045        $this->assertSameSets( $expected, $found );
    10461046    }
    10471047
     
    10671067
    10681068        $this->assertContains( "AND user_nicename = 'peter'", $q->query_where );
    1069         $this->assertEqualSets( $expected, $found );
     1069        $this->assertSameSets( $expected, $found );
    10701070    }
    10711071
     
    11051105
    11061106        $this->assertContains( "AND user_nicename IN ( 'peter','paul','mary' )", $q->query_where );
    1107         $this->assertEqualSets( $expected, $found );
     1107        $this->assertSameSets( $expected, $found );
    11081108    }
    11091109
     
    12021202
    12031203        $this->assertContains( "AND user_login = '$user_login'", $q->query_where );
    1204         $this->assertEqualSets( $expected, $found );
     1204        $this->assertSameSets( $expected, $found );
    12051205    }
    12061206
     
    12231223
    12241224        $this->assertContains( "AND user_login IN ( '$user_login1','$user_login2','$user_login3' )", $q->query_where );
    1225         $this->assertEqualSets( $expected, $found );
     1225        $this->assertSameSets( $expected, $found );
    12261226    }
    12271227
Note: See TracChangeset for help on using the changeset viewer.