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/pomo/noopTranslations.php

    r46586 r48937  
    1919
    2020    function test_get_header() {
    21         $this->assertEquals( false, $this->noop->get_header( 'Content-Type' ) );
     21        $this->assertFalse( $this->noop->get_header( 'Content-Type' ) );
    2222    }
    2323
    2424    function test_add_entry() {
    2525        $this->noop->add_entry( $this->entry );
    26         $this->assertEquals( array(), $this->noop->entries );
     26        $this->assertSame( array(), $this->noop->entries );
    2727    }
    2828
    2929    function test_set_header() {
    3030        $this->noop->set_header( 'header', 'value' );
    31         $this->assertEquals( array(), $this->noop->headers );
     31        $this->assertSame( array(), $this->noop->headers );
    3232    }
    3333
    3434    function test_translate_entry() {
    3535        $this->noop->add_entry( $this->entry );
    36         $this->assertEquals( false, $this->noop->translate_entry( $this->entry ) );
     36        $this->assertFalse( $this->noop->translate_entry( $this->entry ) );
    3737    }
    3838
    3939    function test_translate() {
    4040        $this->noop->add_entry( $this->entry );
    41         $this->assertEquals( 'baba', $this->noop->translate( 'baba' ) );
     41        $this->assertSame( 'baba', $this->noop->translate( 'baba' ) );
    4242    }
    4343
    4444    function test_plural() {
    4545        $this->noop->add_entry( $this->plural_entry );
    46         $this->assertEquals( 'dyado', $this->noop->translate_plural( 'dyado', 'dyados', 1 ) );
    47         $this->assertEquals( 'dyados', $this->noop->translate_plural( 'dyado', 'dyados', 11 ) );
    48         $this->assertEquals( 'dyados', $this->noop->translate_plural( 'dyado', 'dyados', 0 ) );
     46        $this->assertSame( 'dyado', $this->noop->translate_plural( 'dyado', 'dyados', 1 ) );
     47        $this->assertSame( 'dyados', $this->noop->translate_plural( 'dyado', 'dyados', 11 ) );
     48        $this->assertSame( 'dyados', $this->noop->translate_plural( 'dyado', 'dyados', 0 ) );
    4949    }
    5050}
Note: See TracChangeset for help on using the changeset viewer.