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

    r47122 r48939  
    8282        $expected = self::$post_ids[4];
    8383
    84         $this->assertEqualSets( $found_post_ids, $expected );
     84        $this->assertSameSets( $found_post_ids, $expected );
    8585    }
    8686
     
    100100        $expected = self::$post_ids[5];
    101101
    102         $this->assertEqualSets( $found_post_ids, $expected );
     102        $this->assertSameSets( $found_post_ids, $expected );
    103103    }
    104104
     
    118118        $expected = array();
    119119
    120         $this->assertEqualSets( $found_post_ids, $expected );
     120        $this->assertSameSets( $found_post_ids, $expected );
    121121    }
    122122    public function test_operator_less_than() {
     
    144144        }
    145145
    146         $this->assertEqualSets( $found_post_ids, $expected );
     146        $this->assertSameSets( $found_post_ids, $expected );
    147147    }
    148148
     
    162162        $expected = array();
    163163
    164         $this->assertEqualSets( $found_post_ids, $expected );
     164        $this->assertSameSets( $found_post_ids, $expected );
    165165    }
    166166
     
    190190        }
    191191
    192         $this->assertEqualSets( $found_post_ids, $expected );
     192        $this->assertSameSets( $found_post_ids, $expected );
    193193
    194194    }
     
    214214        }
    215215
    216         $this->assertEqualSets( $found_post_ids, $expected );
     216        $this->assertSameSets( $found_post_ids, $expected );
    217217    }
    218218
     
    232232        $expected = array();
    233233
    234         $this->assertEqualSets( $found_post_ids, $expected );
     234        $this->assertSameSets( $found_post_ids, $expected );
    235235    }
    236236
     
    256256        }
    257257
    258         $this->assertEqualSets( $found_post_ids, $expected );
     258        $this->assertSameSets( $found_post_ids, $expected );
    259259    }
    260260
     
    274274        $expected = array();
    275275
    276         $this->assertEqualSets( $found_post_ids, $expected );
     276        $this->assertSameSets( $found_post_ids, $expected );
    277277    }
    278278
     
    295295        }
    296296
    297         $this->assertEqualSets( $found_post_ids, $expected );
     297        $this->assertSameSets( $found_post_ids, $expected );
    298298    }
    299299
     
    313313        $expected = array();
    314314
    315         $this->assertEqualSets( $found_post_ids, $expected );
     315        $this->assertSameSets( $found_post_ids, $expected );
    316316    }
    317317
     
    330330        $expected = self::$post_ids[5];
    331331
    332         $this->assertEqualSets( $found_post_ids, $expected );
     332        $this->assertSameSets( $found_post_ids, $expected );
    333333    }
    334334
     
    354354        }
    355355
    356         $this->assertEqualSets( $found_post_ids, $expected );
     356        $this->assertSameSets( $found_post_ids, $expected );
    357357    }
    358358
     
    369369        $expected = self::$post_ids[5];
    370370
    371         $this->assertEqualSets( $found_post_ids, $expected );
     371        $this->assertSameSets( $found_post_ids, $expected );
    372372    }
    373373}
Note: See TracChangeset for help on using the changeset viewer.