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/image/header.php

    r47198 r48937  
    2929            )
    3030        );
    31         $this->assertEquals( 1200, $dimensions['dst_width'] );
    32         $this->assertEquals( 230, $dimensions['dst_height'] );
     31        $this->assertSame( 1200, $dimensions['dst_width'] );
     32        $this->assertSame( 230, $dimensions['dst_height'] );
    3333
    3434    }
     
    4949            )
    5050        );
    51         $this->assertEquals( 1200, $dimensions['dst_width'] );
    52         $this->assertEquals( 230, $dimensions['dst_height'] );
     51        $this->assertSame( 1200, $dimensions['dst_width'] );
     52        $this->assertSame( 230, $dimensions['dst_height'] );
    5353
    5454    }
     
    6969            )
    7070        );
    71         $this->assertEquals( 1200, $dimensions['dst_width'] );
    72         $this->assertEquals( 900, $dimensions['dst_height'] );
     71        $this->assertSame( 1200, $dimensions['dst_width'] );
     72        $this->assertSame( 900, $dimensions['dst_height'] );
    7373
    7474    }
     
    8989            )
    9090        );
    91         $this->assertEquals( 1500, $dimensions['dst_width'] ); // Max width.
    92         $this->assertEquals( 230, $dimensions['dst_height'] );
     91        $this->assertSame( 1500, $dimensions['dst_width'] ); // Max width.
     92        $this->assertSame( 230, $dimensions['dst_height'] );
    9393
    9494    }
     
    109109            )
    110110        );
    111         $this->assertEquals( 1600, $dimensions['dst_width'] );
    112         $this->assertEquals( 1200, $dimensions['dst_height'] );
     111        $this->assertSame( 1600, $dimensions['dst_width'] );
     112        $this->assertSame( 1200, $dimensions['dst_height'] );
    113113
    114114    }
     
    127127
    128128        $object = $this->custom_image_header->create_attachment_object( $cropped, $id );
    129         $this->assertEquals( 'foo-cropped.png', $object['post_title'] );
    130         $this->assertEquals( 'http://localhost/' . $cropped, $object['guid'] );
    131         $this->assertEquals( 'custom-header', $object['context'] );
    132         $this->assertEquals( 'image/jpeg', $object['post_mime_type'] );
     129        $this->assertSame( 'foo-cropped.png', $object['post_title'] );
     130        $this->assertSame( 'http://localhost/' . $cropped, $object['guid'] );
     131        $this->assertSame( 'custom-header', $object['context'] );
     132        $this->assertSame( 'image/jpeg', $object['post_mime_type'] );
    133133    }
    134134
Note: See TracChangeset for help on using the changeset viewer.