WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (17 months ago)
Author:
SergeyBiryukov
Message:

Tests: First pass at using assertSame() instead of assertEquals() in most of the unit tests.

This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using assertSame() should generally be preferred to assertEquals() where appropriate, to make the tests more reliable.

Props johnbillion, jrf, SergeyBiryukov.
See #38266.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php

    r46586 r48937  
    1818        $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'username', 'password', 'category', 0 ) );
    1919        $this->assertIXRError( $result );
    20         $this->assertEquals( 403, $result->code );
     20        $this->assertSame( 403, $result->code );
    2121    }
    2222
     
    2626        $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', '', 0 ) );
    2727        $this->assertIXRError( $result );
    28         $this->assertEquals( 403, $result->code );
    29         $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
     28        $this->assertSame( 403, $result->code );
     29        $this->assertSame( __( 'Invalid taxonomy.' ), $result->message );
    3030    }
    3131
     
    3535        $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', 'not_existing', 0 ) );
    3636        $this->assertIXRError( $result );
    37         $this->assertEquals( 403, $result->code );
    38         $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
     37        $this->assertSame( 403, $result->code );
     38        $this->assertSame( __( 'Invalid taxonomy.' ), $result->message );
    3939    }
    4040
     
    4444        $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', 'category', self::$term_id ) );
    4545        $this->assertIXRError( $result );
    46         $this->assertEquals( 401, $result->code );
    47         $this->assertEquals( __( 'Sorry, you are not allowed to delete this term.' ), $result->message );
     46        $this->assertSame( 401, $result->code );
     47        $this->assertSame( __( 'Sorry, you are not allowed to delete this term.' ), $result->message );
    4848    }
    4949
     
    5353        $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'editor', 'editor', 'category', '' ) );
    5454        $this->assertIXRError( $result );
    55         $this->assertEquals( 500, $result->code );
    56         $this->assertEquals( __( 'Empty Term.' ), $result->message );
     55        $this->assertSame( 500, $result->code );
     56        $this->assertSame( __( 'Empty Term.' ), $result->message );
    5757    }
    5858
     
    6262        $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'editor', 'editor', 'category', 9999 ) );
    6363        $this->assertIXRError( $result );
    64         $this->assertEquals( 404, $result->code );
    65         $this->assertEquals( __( 'Invalid term ID.' ), $result->message );
     64        $this->assertSame( 404, $result->code );
     65        $this->assertSame( __( 'Invalid term ID.' ), $result->message );
    6666    }
    6767
Note: See TracChangeset for help on using the changeset viewer.