WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/10/2021 01:24:24 PM (10 months 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 [49904], [49925], [49992], [50012], [50013], [50065], [50075], [50131], [50150], [50157].

See #38266, #52482.

File:
1 edited

Legend:

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

    r50150 r50284  
    495495        $this->assertArrayHasKey( 'params', $data );
    496496        $this->assertArrayHasKey( 'failparam', $data['params'] );
    497         $this->assertEquals( 'Invalid. Super Invalid. Broken.', $data['params']['failparam'] );
     497        $this->assertSame( 'Invalid. Super Invalid. Broken.', $data['params']['failparam'] );
    498498    }
    499499
     
    525525        $this->assertArrayHasKey( 'details', $data );
    526526        $this->assertArrayHasKey( 'failparam', $data['details'] );
    527         $this->assertEquals(
     527        $this->assertSame(
    528528            array(
    529529                'code'    => 'invalid',
     
    758758        $this->assertArrayHasKey( 'params', $data );
    759759        $this->assertArrayHasKey( 'failparam', $data['params'] );
    760         $this->assertEquals( 'Invalid. Super Invalid. Broken.', $data['params']['failparam'] );
     760        $this->assertSame( 'Invalid. Super Invalid. Broken.', $data['params']['failparam'] );
    761761    }
    762762
     
    788788        $this->assertArrayHasKey( 'details', $data );
    789789        $this->assertArrayHasKey( 'failparam', $data['details'] );
    790         $this->assertEquals(
     790        $this->assertSame(
    791791            array(
    792792                'code'    => 'invalid',
Note: See TracChangeset for help on using the changeset viewer.