Make WordPress Core


Ignore:
Timestamp:
07/07/2021 10:32:56 AM (3 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use more appropriate assertions in various tests.

This replaces instances of assertSame( [number], count( ... ) ) with assertCount() to use native PHPUnit functionality.

Follow-up to [51335], [51337].

See #53363.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/user/query.php

    r51196 r51367  
    138138
    139139        // +1 for the default user created during installation.
    140         $this->assertSame( 13, count( $users ) );
     140        $this->assertCount( 13, $users );
    141141        foreach ( $users as $user ) {
    142142            $this->assertInstanceOf( 'WP_User', $user );
     
    150150        );
    151151        $users = $users->get_results();
    152         $this->assertSame( 13, count( $users ) );
     152        $this->assertCount( 13, $users );
    153153        foreach ( $users as $user ) {
    154154            $this->assertInstanceOf( 'WP_User', $user );
     
    503503        $users = new WP_User_Query( array( 'blog_id' => get_current_blog_id() ) );
    504504        $users = $users->get_results();
    505         $this->assertSame( 13, count( $users ) );
     505        $this->assertCount( 13, $users );
    506506
    507507        $users = new WP_User_Query(
     
    512512        );
    513513        $users = $users->get_results();
    514         $this->assertSame( 10, count( $users ) );
     514        $this->assertCount( 10, $users );
    515515
    516516        $users = new WP_User_Query(
     
    521521        );
    522522        $users = $users->get_results();
    523         $this->assertSame( 2, count( $users ) );
     523        $this->assertCount( 2, $users );
    524524
    525525        $users = new WP_User_Query(
     
    530530        );
    531531        $users = $users->get_results();
    532         $this->assertSame( 13, count( $users ) );
     532        $this->assertCount( 13, $users );
    533533    }
    534534
     
    13151315        $users          = $wp_user_search->get_results();
    13161316
    1317         $this->assertSame( 2, count( $users ) );
     1317        $this->assertCount( 2, $users );
    13181318    }
    13191319
     
    13241324        $wp_user_search = new WP_User_Query( array( 'role__in' => array( 'subscriber', 'editor' ) ) );
    13251325        $users          = $wp_user_search->get_results();
    1326         $this->assertSame( 5, count( $users ) );
     1326        $this->assertCount( 5, $users );
    13271327    }
    13281328
     
    13371337        );
    13381338
    1339         $this->assertSame( 2, count( $users ) );
     1339        $this->assertCount( 2, $users );
    13401340    }
    13411341
     
    13731373        );
    13741374
    1375         $this->assertSame( 2, count( $users ) );
     1375        $this->assertCount( 2, $users );
    13761376    }
    13771377
     
    13931393        $users = $users->get_results();
    13941394
    1395         $this->assertSame( 2, count( $users ) );
     1395        $this->assertCount( 2, $users );
    13961396
    13971397        foreach ( $users as $user ) {
     
    14081408
    14091409        // +1 for the default user created during installation.
    1410         $this->assertSame( 8, count( $users ) );
     1410        $this->assertCount( 8, $users );
    14111411        foreach ( $users as $user ) {
    14121412            $this->assertInstanceOf( 'WP_User', $user );
     
    14371437        );
    14381438
    1439         $this->assertSame( 2, count( $users ) );
     1439        $this->assertCount( 2, $users );
    14401440    }
    14411441
     
    14831483
    14841484        // Check results.
    1485         $this->assertSame( 1, count( $users ) );
     1485        $this->assertCount( 1, $users );
    14861486        $this->assertSame( self::$editor_ids[0], (int) $users[0]->ID );
    14871487    }
     
    14981498
    14991499        // +1 for the default user created during installation.
    1500         $this->assertSame( 11, count( $users ) );
     1500        $this->assertCount( 11, $users );
    15011501
    15021502        $users = get_users(
     
    15071507
    15081508        // +1 for the default user created during installation.
    1509         $this->assertSame( 10, count( $users ) );
     1509        $this->assertCount( 10, $users );
    15101510    }
    15111511
     
    15251525        );
    15261526
    1527         $this->assertSame( 5, count( $users ) );
     1527        $this->assertCount( 5, $users );
    15281528
    15291529        $users = get_users(
     
    15341534        );
    15351535
    1536         $this->assertSame( 3, count( $users ) );
     1536        $this->assertCount( 3, $users );
    15371537    }
    15381538
     
    15511551        );
    15521552
    1553         $this->assertSame( 1, count( $users ) );
     1553        $this->assertCount( 1, $users );
    15541554    }
    15551555
     
    15691569
    15701570        // +1 for the default user created during installation.
    1571         $this->assertSame( 12, count( $users ) );
     1571        $this->assertCount( 12, $users );
    15721572
    15731573        $users = get_users(
     
    15781578
    15791579        // +1 for the default user created during installation.
    1580         $this->assertSame( 10, count( $users ) );
     1580        $this->assertCount( 10, $users );
    15811581    }
    15821582
Note: See TracChangeset for help on using the changeset viewer.