Make WordPress Core


Ignore:
Timestamp:
11/09/2020 03:43:14 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use assertSame() in some newly introduced 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.

Follow-up to [48937], [48939], [48940], [48944].

See #38266.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-search-controller.php

    r49365 r49547  
    570570                        )
    571571                );
    572                 $this->assertEquals( 200, $response->get_status() );
    573                 $this->assertEqualSets(
     572                $this->assertSame( 200, $response->get_status() );
     573                $this->assertSameSets(
    574574                        array(
    575575                                0 => 1, // That is the default category.
     
    595595                );
    596596
    597                 $this->assertEquals( 200, $response->get_status() );
    598                 $this->assertEqualSets(
     597                $this->assertSame( 200, $response->get_status() );
     598                $this->assertSameSets(
    599599                        array(
    600600                                0 => 1, // That is the default category.
     
    635635                        )
    636636                );
    637                 $this->assertEquals( 200, $response->get_status() );
    638                 $this->assertEqualSets(
     637                $this->assertSame( 200, $response->get_status() );
     638                $this->assertSameSets(
    639639                        array(
    640640                                0 => 1, // This is the default category.
     
    660660                );
    661661
    662                 $this->assertEquals( 200, $response->get_status() );
    663                 $this->assertEqualSets(
     662                $this->assertSame( 200, $response->get_status() );
     663                $this->assertSameSets(
    664664                        array(
    665665                                self::$my_category_id,
     
    683683                );
    684684
    685                 $this->assertEquals( 200, $response->get_status() );
    686                 $this->assertEqualSets(
     685                $this->assertSame( 200, $response->get_status() );
     686                $this->assertSameSets(
    687687                        array(
    688688                                self::$my_tag_id,
     
    706706                );
    707707
    708                 $this->assertEquals( 200, $response->get_status() );
     708                $this->assertSame( 200, $response->get_status() );
    709709                $this->assertEmpty( $response->get_data() );
    710710        }
     
    722722                        )
    723723                );
    724                 $this->assertEquals( 200, $response->get_status() );
     724                $this->assertSame( 200, $response->get_status() );
    725725                $this->assertContains(
    726726                        'Aside',
     
    743743                );
    744744
    745                 $this->assertEquals( 200, $response->get_status() );
     745                $this->assertSame( 200, $response->get_status() );
    746746                $this->assertContains(
    747747                        'Aside',
     
    765765                );
    766766
    767                 $this->assertEquals( 200, $response->get_status() );
     767                $this->assertSame( 200, $response->get_status() );
    768768                $this->assertEmpty( $response->get_data() );
    769769        }
Note: See TracChangeset for help on using the changeset viewer.