Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (3 years 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/newTerm.php

    r46586 r48937  
    1919        $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'username', 'password', array() ) );
    2020        $this->assertIXRError( $result );
    21         $this->assertEquals( 403, $result->code );
     21        $this->assertSame( 403, $result->code );
    2222    }
    2323
     
    2727        $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => '' ) ) );
    2828        $this->assertIXRError( $result );
    29         $this->assertEquals( 403, $result->code );
    30         $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
     29        $this->assertSame( 403, $result->code );
     30        $this->assertSame( __( 'Invalid taxonomy.' ), $result->message );
    3131    }
    3232
     
    3636        $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'not_existing' ) ) );
    3737        $this->assertIXRError( $result );
    38         $this->assertEquals( 403, $result->code );
    39         $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
     38        $this->assertSame( 403, $result->code );
     39        $this->assertSame( __( 'Invalid taxonomy.' ), $result->message );
    4040    }
    4141
     
    4545        $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'subscriber', 'subscriber', array( 'taxonomy' => 'category' ) ) );
    4646        $this->assertIXRError( $result );
    47         $this->assertEquals( 401, $result->code );
    48         $this->assertEquals( __( 'Sorry, you are not allowed to create terms in this taxonomy.' ), $result->message );
     47        $this->assertSame( 401, $result->code );
     48        $this->assertSame( __( 'Sorry, you are not allowed to create terms in this taxonomy.' ), $result->message );
    4949    }
    5050
     
    6464        );
    6565        $this->assertIXRError( $result );
    66         $this->assertEquals( 403, $result->code );
    67         $this->assertEquals( __( 'The term name cannot be empty.' ), $result->message );
     66        $this->assertSame( 403, $result->code );
     67        $this->assertSame( __( 'The term name cannot be empty.' ), $result->message );
    6868    }
    6969
     
    8484        );
    8585        $this->assertIXRError( $result );
    86         $this->assertEquals( 403, $result->code );
    87         $this->assertEquals( __( 'This taxonomy is not hierarchical.' ), $result->message );
     86        $this->assertSame( 403, $result->code );
     87        $this->assertSame( __( 'This taxonomy is not hierarchical.' ), $result->message );
    8888    }
    8989
     
    104104        );
    105105        $this->assertIXRError( $result );
    106         $this->assertEquals( 500, $result->code );
     106        $this->assertSame( 500, $result->code );
    107107    }
    108108
     
    123123        );
    124124        $this->assertIXRError( $result );
    125         $this->assertEquals( 403, $result->code );
    126         $this->assertEquals( __( 'Parent term does not exist.' ), $result->message );
     125        $this->assertSame( 403, $result->code );
     126        $this->assertSame( __( 'Parent term does not exist.' ), $result->message );
    127127    }
    128128
Note: See TracChangeset for help on using the changeset viewer.