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/rest-api/rest-blocks-controller.php

    r46586 r48937  
    134134
    135135                $response = rest_get_server()->dispatch( $request );
    136                 $this->assertEquals( $expected_status, $response->get_status() );
     136                $this->assertSame( $expected_status, $response->get_status() );
    137137
    138138                break;
     
    142142
    143143                $response = rest_get_server()->dispatch( $request );
    144                 $this->assertEquals( $expected_status, $response->get_status() );
     144                $this->assertSame( $expected_status, $response->get_status() );
    145145
    146146                break;
     
    166166
    167167                $response = rest_get_server()->dispatch( $request );
    168                 $this->assertEquals( $expected_status, $response->get_status() );
     168                $this->assertSame( $expected_status, $response->get_status() );
    169169
    170170                $request = new WP_REST_Request( 'DELETE', '/wp/v2/blocks/' . $post_id );
    171171
    172172                $response = rest_get_server()->dispatch( $request );
    173                 $this->assertEquals( $expected_status, $response->get_status() );
     173                $this->assertSame( $expected_status, $response->get_status() );
    174174
    175175                wp_delete_post( $post_id );
     
    187187
    188188                $response = rest_get_server()->dispatch( $request );
    189                 $this->assertEquals( $expected_status, $response->get_status() );
     189                $this->assertSame( $expected_status, $response->get_status() );
    190190
    191191                $request = new WP_REST_Request( 'DELETE', '/wp/v2/blocks/' . self::$post_id );
    192192
    193193                $response = rest_get_server()->dispatch( $request );
    194                 $this->assertEquals( $expected_status, $response->get_status() );
     194                $this->assertSame( $expected_status, $response->get_status() );
    195195
    196196                break;
     
    213213        $data     = $response->get_data();
    214214
    215         $this->assertEquals(
     215        $this->assertSame(
    216216            array(
    217217                'raw' => 'My cool block',
     
    219219            $data['title']
    220220        );
    221         $this->assertEquals(
     221        $this->assertSame(
    222222            array(
    223223                'raw'       => '<!-- wp:paragraph --><p>Hello!</p><!-- /wp:paragraph -->',
Note: See TracChangeset for help on using the changeset viewer.