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/siteIcon.php

    r47198 r48937  
    3737        }
    3838
    39         $this->assertEquals( $sizes, $image_sizes );
     39        $this->assertSame( $sizes, $image_sizes );
    4040    }
    4141
     
    5353
    5454        // All icon sizes should be part of the array, including sizes added through the filter.
    55         $this->assertEquals( $sizes, $image_sizes );
     55        $this->assertSame( $sizes, $image_sizes );
    5656
    5757        // Remove custom size.
     
    7373        }
    7474
    75         $this->assertEquals( $sizes, $image_sizes );
     75        $this->assertSame( $sizes, $image_sizes );
    7676    }
    7777
     
    9393
    9494        // All icon sizes should be part of the array, including sizes added through the filter.
    95         $this->assertEquals( $sizes, $image_sizes );
     95        $this->assertSame( $sizes, $image_sizes );
    9696
    9797        // Remove custom size.
     
    106106        $object = $this->wp_site_icon->create_attachment_object( $cropped, $attachment_id );
    107107
    108         $this->assertEquals( $object['post_title'], 'cropped-test-image.jpg' );
    109         $this->assertEquals( $object['context'], 'site-icon' );
    110         $this->assertEquals( $object['post_mime_type'], 'image/jpeg' );
    111         $this->assertEquals( $object['post_content'], $cropped );
    112         $this->assertEquals( $object['guid'], $cropped );
     108        $this->assertSame( $object['post_title'], 'cropped-test-image.jpg' );
     109        $this->assertSame( $object['context'], 'site-icon' );
     110        $this->assertSame( $object['post_mime_type'], 'image/jpeg' );
     111        $this->assertSame( $object['post_content'], $cropped );
     112        $this->assertSame( $object['guid'], $cropped );
    113113    }
    114114
Note: See TracChangeset for help on using the changeset viewer.