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/general/template.php

    r34983 r35309  
    155155
    156156        $upload = wp_upload_bits( basename( $filename ), null, $contents );
    157         $type   = '';
    158         if ( ! empty( $upload['type'] ) ) {
    159             $type = $upload['type'];
    160         } else {
    161             $mime = wp_check_filetype( $upload['file'] );
    162             if ( $mime ) {
    163                 $type = $mime['type'];
    164             }
    165         }
     157        $this->site_icon_url = $upload['url'];
    166158
    167         $attachment = array(
    168             'post_title'     => basename( $upload['file'] ),
    169             'post_content'   => $upload['url'],
    170             'post_type'      => 'attachment',
    171             'post_mime_type' => $type,
    172             'guid'           => $upload['url'],
    173         );
    174159
    175160        // Save the data
    176         $this->site_icon_url = $upload['url'];
    177         $this->site_icon_id  = wp_insert_attachment( $attachment, $upload['file'] );
    178         wp_update_attachment_metadata( $this->site_icon_id, wp_generate_attachment_metadata( $this->site_icon_id, $upload['file'] ) );
     161        $this->site_icon_id = $this->_make_attachment( $upload );
     162        return $this->site_icon_id;
    179163    }
    180164}
Note: See TracChangeset for help on using the changeset viewer.