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

    r47198 r48937  
    5555        $imagick_image_editor->resize( 100, 50 );
    5656
    57         $this->assertEquals(
     57        $this->assertSame(
    5858            array(
    5959                'width'  => 75,
     
    9292        );
    9393
    94         $this->assertEquals( $expected_array, $resized );
     94        $this->assertSame( $expected_array, $resized );
    9595
    9696        // Now, verify real dimensions are as expected.
     
    364364
    365365        $this->assertNotNull( $resized );
    366         $this->assertEquals( $expected_array, $resized );
     366        $this->assertSame( $expected_array, $resized );
    367367
    368368        foreach ( $resized as $key => $image_data ) {
     
    389389        $imagick_image_editor->resize( 100, 50, true );
    390390
    391         $this->assertEquals(
     391        $this->assertSame(
    392392            array(
    393393                'width'  => 100,
     
    409409        $imagick_image_editor->crop( 0, 0, 50, 50 );
    410410
    411         $this->assertEquals(
     411        $this->assertSame(
    412412            array(
    413413                'width'  => 50,
     
    434434        $imagick_image_editor->rotate( 180 );
    435435
    436         $this->assertEquals( $color_top_left, $property->getValue( $imagick_image_editor )->getImagePixelColor( 99, 99 )->getColor() );
     436        $this->assertSame( $color_top_left, $property->getValue( $imagick_image_editor )->getImagePixelColor( 99, 99 )->getColor() );
    437437    }
    438438
     
    453453        $imagick_image_editor->flip( true, false );
    454454
    455         $this->assertEquals( $color_top_left, $property->getValue( $imagick_image_editor )->getImagePixelColor( 0, 99 )->getColor() );
     455        $this->assertSame( $color_top_left, $property->getValue( $imagick_image_editor )->getImagePixelColor( 0, 99 )->getColor() );
    456456    }
    457457
     
    559559
    560560        // The orientation value 3 is equivalent to rotated upside down (180 degrees).
    561         $this->assertEquals( 3, intval( $data['orientation'] ), 'Orientation value read from does not match image file Exif data: ' . $file );
     561        $this->assertSame( 3, intval( $data['orientation'] ), 'Orientation value read from does not match image file Exif data: ' . $file );
    562562
    563563        $temp_file = wp_tempnam( $file );
     
    571571
    572572        // Make sure the image is no longer in The Upside Down Exif orientation.
    573         $this->assertEquals( 1, intval( $data['orientation'] ), 'Orientation Exif data was not updated after rotating image: ' . $file );
     573        $this->assertSame( 1, intval( $data['orientation'] ), 'Orientation Exif data was not updated after rotating image: ' . $file );
    574574
    575575        // Remove both the generated file ending in .tmp and tmp.jpg due to wp_tempnam().
Note: See TracChangeset for help on using the changeset viewer.