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/getPostType.php

    r47122 r48937  
    3333        $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'username', 'password', 'post' ) );
    3434        $this->assertIXRError( $result );
    35         $this->assertEquals( 403, $result->code );
     35        $this->assertSame( 403, $result->code );
    3636    }
    3737
     
    4141        $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'editor', 'editor', 'foobar' ) );
    4242        $this->assertIXRError( $result );
    43         $this->assertEquals( 403, $result->code );
     43        $this->assertSame( 403, $result->code );
    4444    }
    4545
     
    5656        $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'subscriber', 'subscriber', 'post' ) );
    5757        $this->assertIXRError( $result );
    58         $this->assertEquals( 401, $result->code );
     58        $this->assertSame( 401, $result->code );
    5959    }
    6060
     
    125125
    126126        // Check expected values.
    127         $this->assertEquals( $this->cpt_name, $result['name'] );
     127        $this->assertSame( $this->cpt_name, $result['name'] );
    128128        foreach ( $this->cpt_args as $key => $value ) {
    129             $this->assertEquals( $value, $result[ $key ] );
     129            $this->assertSame( $value, $result[ $key ] );
    130130        }
    131131    }
Note: See TracChangeset for help on using the changeset viewer.