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/image/site_icon.php

    r35299 r35309  
    159159
    160160        $upload = wp_upload_bits( basename( $filename ), null, $contents );
    161         $type   = '';
    162         if ( ! empty( $upload['type'] ) ) {
    163             $type = $upload['type'];
    164         } else {
    165             $mime = wp_check_filetype( $upload['file'] );
    166             if ( $mime ) {
    167                 $type = $mime['type'];
    168             }
    169         }
    170161
    171         $attachment = array(
    172             'post_title'     => basename( $upload['file'] ),
    173             'post_content'   => $upload['url'],
    174             'post_type'      => 'attachment',
    175             'post_mime_type' => $type,
    176             'guid'           => $upload['url'],
    177         );
    178 
    179         // Save the data
    180         $this->attachment_id  = wp_insert_attachment( $attachment, $upload['file'] );
    181         wp_update_attachment_metadata( $this->attachment_id, wp_generate_attachment_metadata( $this->attachment_id, $upload['file'] ) );
    182 
     162        $this->attachment_id = $this->_make_attachment( $upload );
    183163        return $this->attachment_id;
    184164    }
Note: See TracChangeset for help on using the changeset viewer.