Tests: Check if image sizes were successfully retrieved in some REST API attachments controller tests.
This outputs a proper message in case of failure, instead of an obscure PHP error further in the test. Props TimothyBlynJacobs. See #50913, #51393. git-svn-id: https://develop.svn.wordpress.org/trunk@49044 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
da93663d01
commit
3bfa4606c7
@ -604,6 +604,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control
|
||||
$original_image_src = wp_get_attachment_image_src( $attachment_id, 'full' );
|
||||
remove_image_size( 'rest-api-test' );
|
||||
|
||||
$this->assertNotEmpty( $data['media_details']['sizes'] );
|
||||
$this->assertSame( $image_src[0], $data['media_details']['sizes']['rest-api-test']['source_url'] );
|
||||
$this->assertSame( 'image/jpeg', $data['media_details']['sizes']['rest-api-test']['mime_type'] );
|
||||
$this->assertSame( $original_image_src[0], $data['media_details']['sizes']['full']['source_url'] );
|
||||
@ -632,6 +633,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control
|
||||
remove_filter( 'wp_get_attachment_image_src', '__return_false' );
|
||||
remove_image_size( 'rest-api-test' );
|
||||
|
||||
$this->assertNotEmpty( $data['media_details']['sizes'] );
|
||||
$this->assertFalse( isset( $data['media_details']['sizes']['rest-api-test']['source_url'] ) );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user