WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/07/2021 10:32:56 AM (3 months 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.php

    r51335 r51367  
    768768        $response = wpmu_validate_user_signup( $user_data['user_login'], $user_data['user_email'] );
    769769        $this->assertInstanceOf( 'WP_Error', $response['errors'] );
    770         $this->assertSame( 0, count( $response['errors']->get_error_codes() ) );
     770        $this->assertCount( 0, $response['errors']->get_error_codes() );
    771771    }
    772772
     
    17291729
    17301730        // Number of exported users.
    1731         $this->assertSame( 1, count( $actual['data'] ) );
     1731        $this->assertCount( 1, $actual['data'] );
    17321732
    17331733        // Number of exported user properties.
    1734         $this->assertSame( 11, count( $actual['data'][0]['data'] ) );
     1734        $this->assertCount( 11, $actual['data'][0]['data'] );
    17351735    }
    17361736
     
    18631863
    18641864        // Number of exported users.
    1865         $this->assertSame( 1, count( $actual['data'] ) );
     1865        $this->assertCount( 1, $actual['data'] );
    18661866
    18671867        // Number of exported user properties (the 11 core properties,
    18681868        // plus 1 additional from the filter).
    1869         $this->assertSame( 12, count( $actual['data'][0]['data'] ) );
     1869        $this->assertCount( 12, $actual['data'][0]['data'] );
    18701870
    18711871        // Check that the item added by the filter was retained.
     
    18951895
    18961896        // Number of exported users.
    1897         $this->assertSame( 1, count( $actual['data'] ) );
     1897        $this->assertCount( 1, $actual['data'] );
    18981898
    18991899        // Number of exported user properties
    19001900        // (the 11 core properties, plus 1 additional from the filter).
    1901         $this->assertSame( 12, count( $actual['data'][0]['data'] ) );
     1901        $this->assertCount( 12, $actual['data'][0]['data'] );
    19021902
    19031903        // Check that the duplicate 'name' => 'User ID' was stripped.
Note: See TracChangeset for help on using the changeset viewer.