Unit Tests: consolidate the many separate implementations of _make_attachment() into a helper method on WP_UnitTestCase.

Fixes #34075.


git-svn-id: https://develop.svn.wordpress.org/trunk@35309 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-10-21 01:58:52 +00:00
parent ede4050ace
commit f5921a0c98
8 changed files with 39 additions and 166 deletions
+4 -12
View File
@@ -22,19 +22,9 @@ class Tests_XMLRPC_wp_getMediaItem extends WP_XMLRPC_UnitTestCase {
$filename = ( DIR_TESTDATA.'/images/waffles.jpg' );
$contents = file_get_contents( $filename );
$upload = wp_upload_bits(basename($filename), null, $contents);
$mime = wp_check_filetype( $filename );
$this->attachment_data = array(
'post_title' => basename( $upload['file'] ),
'post_content' => '',
'post_type' => 'attachment',
'post_parent' => $this->post_id,
'post_mime_type' => $mime['type'],
'guid' => $upload[ 'url' ]
);
$id = wp_insert_attachment( $this->attachment_data, $upload[ 'file' ], $this->post_id );
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );
$this->attachment_id = $id;
$this->attachment_id = $this->_make_attachment( $upload, $this->post_id );
$this->attachment_data = get_post( $this->attachment_id, ARRAY_A );
set_post_thumbnail( $this->post_id, $this->attachment_id );
}
@@ -42,6 +32,8 @@ class Tests_XMLRPC_wp_getMediaItem extends WP_XMLRPC_UnitTestCase {
function tearDown() {
remove_theme_support( 'post-thumbnails' );
$this->remove_added_uploads();
parent::tearDown();
}