Make WordPress Core

Changeset 55467


Ignore:
Timestamp:
03/06/2023 04:27:23 PM (19 months ago)
Author:
hellofromTonya
Message:

Tests: Improve Tests_Media::test_wp_generate_attachment_metadata_doesnt_generate_sizes_for_150_square_image().

Changes:

  • from assertEquals() to assertSame(). Why? To ensure both the return value and data type match the expected results.
  • the expected height and width from string to integer data types. Why integer? getimagesize() (within wp_getimagesize()) will return an integer for both height and weight.
  • adds the ticket annotation.
  • adds assertion failure messages. Why? To denote which assertion failed, which aids in debugging efforts.

Follow-up to [55278].

Props costdev, peterwilsoncc, mukesh27, ankitmaru, hellofromTonya.
See #56800, #57370.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/media.php

    r55318 r55467  
    39363936    /**
    39373937     * Test that an image size isn't generated if it matches the original image size.
     3938     *
     3939     * @ticket 57370
    39383940     */
    39393941    public function test_wp_generate_attachment_metadata_doesnt_generate_sizes_for_150_square_image() {
     
    39503952
    39513953        $metadata = wp_generate_attachment_metadata( $attachment_id, $file );
    3952         $this->assertEquals(
     3954        $this->assertSame(
    39533955            array(),
    3954             $metadata['sizes']
    3955         );
    3956         $this->assertEquals(
     3956            $metadata['sizes'],
     3957            'The sizes should be an empty array'
     3958        );
     3959        $this->assertSame(
    39573960            'test-square-150.jpg',
    3958             basename( $metadata['file'] )
    3959         );
    3960         $this->assertEquals(
    3961             '150',
    3962             $metadata['width']
    3963         );
    3964         $this->assertEquals(
    3965             '150',
    3966             $metadata['height']
     3961            basename( $metadata['file'] ),
     3962            'The file basename should match the given filename'
     3963        );
     3964        $this->assertSame(
     3965            150,
     3966            $metadata['width'],
     3967            'The width should be 150 (integer)'
     3968        );
     3969        $this->assertSame(
     3970            150,
     3971            $metadata['height'],
     3972            'The height should be 150 (integer)'
    39673973        );
    39683974    }
Note: See TracChangeset for help on using the changeset viewer.