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

    r48798 r48937  
    187187                $this->assertNotEmpty( $ret );
    188188                $this->assertNotWPError( $ret );
    189                 $this->assertEquals( $mime_type, $this->get_mime_type( $ret['path'] ) );
     189                $this->assertSame( $mime_type, $this->get_mime_type( $ret['path'] ) );
    190190
    191191                // Clean up.
     
    229229            $this->assertNotEmpty( $ret );
    230230            $this->assertNotWPError( $ret );
    231             $this->assertEquals( $mime_type, $this->get_mime_type( $ret['path'] ) );
     231            $this->assertSame( $mime_type, $this->get_mime_type( $ret['path'] ) );
    232232
    233233            // Clean up.
     
    284284                $this->assertNotEmpty( $ret );
    285285                $this->assertNotWPError( $ret );
    286                 $this->assertEquals( $mime_type, $this->get_mime_type( $ret['path'] ) );
     286                $this->assertSame( $mime_type, $this->get_mime_type( $ret['path'] ) );
    287287                unlink( $ret['path'] );
    288288            }
     
    320320
    321321            $this->assertInstanceOf( 'WP_Error', $loaded );
    322             $this->assertEquals( 'error_loading_image', $loaded->get_error_code() );
     322            $this->assertSame( 'error_loading_image', $loaded->get_error_code() );
    323323        }
    324324    }
     
    342342        $image = wp_get_image_editor( $file );
    343343        $size  = $image->get_size();
    344         $this->assertEquals( 100, $size['height'] );
    345         $this->assertEquals( 100, $size['width'] );
     344        $this->assertSame( 100, $size['height'] );
     345        $this->assertSame( 100, $size['width'] );
    346346
    347347        unlink( $file );
     
    377377        $image = wp_get_image_editor( $file );
    378378        $size  = $image->get_size();
    379         $this->assertEquals( 100, $size['height'] );
    380         $this->assertEquals( 100, $size['width'] );
     379        $this->assertSame( 100, $size['height'] );
     380        $this->assertSame( 100, $size['width'] );
    381381
    382382        unlink( $file );
Note: See TracChangeset for help on using the changeset viewer.