Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (4 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/general/wpError.php

    r48858 r48937  
    6161        $wp_error = new WP_Error( 'code' );
    6262
    63         $this->assertSame( null, $wp_error->get_error_data( 'code' ) );
     63        $this->assertNull( $wp_error->get_error_data( 'code' ) );
    6464    }
    6565
     
    273273     */
    274274    public function test_get_error_data_with_empty_code_and_no_errors_should_evaluate_as_null() {
    275         $this->assertSame( null, $this->wp_error->get_error_data() );
     275        $this->assertNull( $this->wp_error->get_error_data() );
    276276    }
    277277
     
    282282        $this->wp_error->add( 'code', 'message' );
    283283
    284         $this->assertSame( null, $this->wp_error->get_error_data() );
     284        $this->assertNull( $this->wp_error->get_error_data() );
    285285    }
    286286
     
    292292        $this->wp_error->add( 'code2', 'message2' );
    293293
    294         $this->assertSame( null, $this->wp_error->get_error_data() );
     294        $this->assertNull( $this->wp_error->get_error_data() );
    295295    }
    296296
     
    331331     */
    332332    public function test_get_error_data_with_code_and_no_errors_should_evaluate_as_null() {
    333         $this->assertSame( null, $this->wp_error->get_error_data( 'code' ) );
     333        $this->assertNull( $this->wp_error->get_error_data( 'code' ) );
    334334    }
    335335
     
    340340        $this->wp_error->add( 'code', 'message' );
    341341
    342         $this->assertSame( null, $this->wp_error->get_error_data( 'code' ) );
     342        $this->assertNull( $this->wp_error->get_error_data( 'code' ) );
    343343    }
    344344
     
    451451        $this->wp_error->add( 'code', '' );
    452452
    453         $this->assertSame( null, $this->wp_error->get_error_data( 'code' ) );
     453        $this->assertNull( $this->wp_error->get_error_data( 'code' ) );
    454454    }
    455455
     
    469469        $this->wp_error->add( 'code', 'message' );
    470470
    471         $this->assertSame( null, $this->wp_error->get_error_data( 'code' ) );
     471        $this->assertNull( $this->wp_error->get_error_data( 'code' ) );
    472472    }
    473473
Note: See TracChangeset for help on using the changeset viewer.