Make WordPress Core


Ignore:
Timestamp:
10/21/2015 01:58:52 AM (10 years ago)
Author:
wonderboymusic
Message:

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

Fixes #34075.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php

    r25002 r35309  
    2323        $contents = file_get_contents( $filename );
    2424        $upload = wp_upload_bits(basename($filename), null, $contents);
    25         $mime = wp_check_filetype( $filename );
    26         $this->attachment_data = array(
    27             'post_title' => basename( $upload['file'] ),
    28             'post_content' => '',
    29             'post_type' => 'attachment',
    30             'post_parent' => $this->post_id,
    31             'post_mime_type' => $mime['type'],
    32             'guid' => $upload[ 'url' ]
    33         );
    3425
    35         $id = wp_insert_attachment( $this->attachment_data, $upload[ 'file' ], $this->post_id );
    36         wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );
    37         $this->attachment_id = $id;
     26        $this->attachment_id = $this->_make_attachment( $upload, $this->post_id );
     27        $this->attachment_data = get_post( $this->attachment_id, ARRAY_A );
    3828
    3929        set_post_thumbnail( $this->post_id, $this->attachment_id );
     
    4232    function tearDown() {
    4333        remove_theme_support( 'post-thumbnails' );
     34
     35        $this->remove_added_uploads();
    4436
    4537        parent::tearDown();
Note: See TracChangeset for help on using the changeset viewer.