Make WordPress Core


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

    r48937 r48939  
    191191        $matching_posts = wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' );
    192192
    193         $this->assertEqualSets( array( $p1, $p2 ), $matching_posts );
     193        $this->assertSameSets( array( $p1, $p2 ), $matching_posts );
    194194    }
    195195
     
    235235        $matching_posts = wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' );
    236236
    237         $this->assertEqualSets( array( $p1, $p2, $p3 ), $matching_posts );
     237        $this->assertSameSets( array( $p1, $p2, $p3 ), $matching_posts );
    238238    }
    239239
     
    282282        $matching_posts = wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' );
    283283
    284         $this->assertEqualSets( array( $p1, $p2, $p3 ), $matching_posts );
     284        $this->assertSameSets( array( $p1, $p2, $p3 ), $matching_posts );
    285285    }
    286286
     
    319319        $matching_posts = wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' );
    320320
    321         $this->assertEqualSets( array( $p1, $p2 ), $matching_posts );
     321        $this->assertSameSets( array( $p1, $p2 ), $matching_posts );
    322322    }
    323323
     
    363363        $matching_posts = wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' );
    364364
    365         $this->assertEqualSets( array( $p1, $p2, $p3 ), $matching_posts );
     365        $this->assertSameSets( array( $p1, $p2, $p3 ), $matching_posts );
    366366    }
    367367
     
    410410        $matching_posts = wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' );
    411411
    412         $this->assertEqualSets( array( $p1, $p2, $p3 ), $matching_posts );
     412        $this->assertSameSets( array( $p1, $p2, $p3 ), $matching_posts );
    413413    }
    414414
     
    437437        $this->go_to( $url );
    438438
    439         $this->assertEqualSets( array( $p1, $p2 ), wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ) );
     439        $this->assertSameSets( array( $p1, $p2 ), wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ) );
    440440    }
    441441
     
    466466        $this->go_to( $url );
    467467
    468         $this->assertEqualSets( array( $p1, $p2, $p3 ), wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ) );
     468        $this->assertSameSets( array( $p1, $p2, $p3 ), wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ) );
    469469    }
    470470
     
    498498        $this->go_to( $url );
    499499
    500         $this->assertEqualSets( array( $p1, $p2, $p3 ), wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ) );
     500        $this->assertSameSets( array( $p1, $p2, $p3 ), wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ) );
    501501    }
    502502
Note: See TracChangeset for help on using the changeset viewer.