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
This commit is contained in:
Tonya Mork 2023-03-06 16:27:23 +00:00
parent f08a0e2a3b
commit cd9d0eadf1

View File

@ -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)'
);
}