mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Tests: Use more specific assertions in image saving tests.
When passed a `WP_Image_Editor` instance as the `$image` parameter, `wp_save_image_file()` returns an array on success, so we can specifically check for an array instead of any non-empty result. Likewise, in PDF tests, when creating an attachment is expected to return an integer ID and not a `WP_Error` object, we can specifically check for that. Follow-up to [1061/tests], [38949], [39617], [42792], [53529], [53530], [53531], [55019], [55066]. See #56793. git-svn-id: https://develop.svn.wordpress.org/trunk@55070 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b223ec07ed
commit
3a63ed2939
@ -283,8 +283,8 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
||||
$ret = wp_save_image_file( $file, $img, $mime_type, 1 );
|
||||
|
||||
// Make assertions.
|
||||
$this->assertNotEmpty( $ret, 'Image failed to save - "empty" response returned.' );
|
||||
$this->assertNotWPError( $ret, 'Image failed to save - WP_Error returned.' );
|
||||
$this->assertIsArray( $ret, 'Image failed to save - non-array response returned.' );
|
||||
$this->assertSame( $mime_type, $this->get_mime_type( $ret['path'] ), 'Mime type of the saved image does not match.' );
|
||||
|
||||
// Clean up.
|
||||
@ -374,8 +374,8 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
||||
$ret = $img->save( $file, $mime_type );
|
||||
|
||||
// Make assertions.
|
||||
$this->assertNotEmpty( $ret, 'Image failed to save - "empty" response returned.' );
|
||||
$this->assertNotWPError( $ret, 'Image failed to save - WP_Error returned.' );
|
||||
$this->assertIsArray( $ret, 'Image failed to save - non-array response returned.' );
|
||||
$this->assertSame( $mime_type, $this->get_mime_type( $ret['path'] ), 'Mime type of the saved image did not override file name.' );
|
||||
|
||||
// Clean up.
|
||||
@ -420,8 +420,8 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
||||
$ret = $img->save( trailingslashit( $temp ) . $file );
|
||||
|
||||
// Make assertions.
|
||||
$this->assertNotEmpty( $ret, 'Image failed to save - "empty" response returned.' );
|
||||
$this->assertNotWPError( $ret, 'Image failed to save - WP Error returned.' );
|
||||
$this->assertIsArray( $ret, 'Image failed to save - non-array response returned.' );
|
||||
$this->assertSame( $mime_type, $this->get_mime_type( $ret['path'] ), 'Mime type of the saved image was not inferred correctly.' );
|
||||
|
||||
// Clean up.
|
||||
@ -679,7 +679,8 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertNotEmpty( $attachment_id );
|
||||
$this->assertNotWPError( $attachment_id, 'Could not create attachment - WP_Error returned.' );
|
||||
$this->assertIsInt( $attachment_id, 'Could not create attachment - non-integer response returned.' );
|
||||
|
||||
$temp_dir = get_temp_dir();
|
||||
|
||||
@ -756,7 +757,8 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertNotEmpty( $attachment_id );
|
||||
$this->assertNotWPError( $attachment_id, 'Could not create attachment - WP_Error returned.' );
|
||||
$this->assertIsInt( $attachment_id, 'Could not create attachment - non-integer response returned.' );
|
||||
|
||||
$temp_dir = get_temp_dir();
|
||||
|
||||
@ -829,7 +831,8 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertNotEmpty( $attachment_id );
|
||||
$this->assertNotWPError( $attachment_id, 'Could not create attachment - WP_Error returned.' );
|
||||
$this->assertIsInt( $attachment_id, 'Could not create attachment - non-integer response returned.' );
|
||||
|
||||
add_image_size( 'test-size', 100, 100 );
|
||||
add_filter( 'fallback_intermediate_image_sizes', array( $this, 'filter_fallback_intermediate_image_sizes' ), 10, 2 );
|
||||
|
||||
Loading…
Reference in New Issue
Block a user