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/oembed/getResponseData.php

    r47615 r48937  
    134134        $data = get_oembed_response_data( $post, 1000 );
    135135
    136         $this->assertEquals( 600, $data['width'] );
    137         $this->assertEquals( 338, $data['height'] );
     136        $this->assertSame( 600, $data['width'] );
     137        $this->assertSame( 338, $data['height'] );
    138138    }
    139139
     
    143143        $data = get_oembed_response_data( $post, 100 );
    144144
    145         $this->assertEquals( 200, $data['width'] );
    146         $this->assertEquals( 200, $data['height'] );
     145        $this->assertSame( 200, $data['width'] );
     146        $this->assertSame( 200, $data['height'] );
    147147    }
    148148
     
    152152        $data = get_oembed_response_data( $post, '400;" DROP TABLES' );
    153153
    154         $this->assertEquals( 400, $data['width'] );
    155         $this->assertEquals( 225, $data['height'] );
     154        $this->assertSame( 400, $data['width'] );
     155        $this->assertSame( 225, $data['height'] );
    156156
    157157        $data = get_oembed_response_data( $post, "lol this isn't even a number?!?!?" );
    158158
    159         $this->assertEquals( 200, $data['width'] );
    160         $this->assertEquals( 200, $data['height'] );
     159        $this->assertSame( 200, $data['width'] );
     160        $this->assertSame( 200, $data['height'] );
    161161    }
    162162
Note: See TracChangeset for help on using the changeset viewer.