mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 02:34:38 +00:00
Media: Add a $wp_error parameter to wp_insert_attachment() to give it parity with wp_insert_post().
Fixes #37813 Props grapplerulrich, mrahmadawais git-svn-id: https://develop.svn.wordpress.org/trunk@38408 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1796,6 +1796,25 @@ EOF;
|
||||
);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 37813
|
||||
*/
|
||||
public function test_return_type_when_inserting_attachment_with_error_in_data() {
|
||||
$data = array(
|
||||
'post_status' => 'public',
|
||||
'post_content' => 'Attachment content',
|
||||
'post_title' => 'Attachment Title',
|
||||
'post_date' => '2012-02-30 00:00:00',
|
||||
);
|
||||
|
||||
$attachment_id = wp_insert_attachment( $data, '', 0, true );
|
||||
$this->assertWPError( $attachment_id );
|
||||
$this->assertEquals( 'invalid_date', $attachment_id->get_error_code() );
|
||||
|
||||
$attachment_id = wp_insert_attachment( $data, '', 0 );
|
||||
$this->assertSame( 0, $attachment_id );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user