From cd9d0eadf145c2a60d776c27f6e58ea3277f0a6b Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Mon, 6 Mar 2023 16:27:23 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@55467 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/media.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php index 8e76c43807..1817af955b 100644 --- a/tests/phpunit/tests/media.php +++ b/tests/phpunit/tests/media.php @@ -3935,6 +3935,8 @@ EOF; /** * Test that an image size isn't generated if it matches the original image size. + * + * @ticket 57370 */ public function test_wp_generate_attachment_metadata_doesnt_generate_sizes_for_150_square_image() { $temp_dir = get_temp_dir(); @@ -3949,21 +3951,25 @@ EOF; ); $metadata = wp_generate_attachment_metadata( $attachment_id, $file ); - $this->assertEquals( + $this->assertSame( array(), - $metadata['sizes'] + $metadata['sizes'], + 'The sizes should be an empty array' ); - $this->assertEquals( + $this->assertSame( 'test-square-150.jpg', - basename( $metadata['file'] ) + basename( $metadata['file'] ), + 'The file basename should match the given filename' ); - $this->assertEquals( - '150', - $metadata['width'] + $this->assertSame( + 150, + $metadata['width'], + 'The width should be 150 (integer)' ); - $this->assertEquals( - '150', - $metadata['height'] + $this->assertSame( + 150, + $metadata['height'], + 'The height should be 150 (integer)' ); }