Changeset 35309 for trunk/tests/phpunit/tests/image/intermediate_size.php
- Timestamp:
- 10/21/2015 01:58:52 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/image/intermediate_size.php
r35243 r35309 6 6 */ 7 7 class Tests_Image_Intermediate_Size extends WP_UnitTestCase { 8 protected $ids = array();9 10 8 function tearDown() { 11 9 $this->remove_added_uploads(); … … 13 11 } 14 12 15 /** 16 * Upload files and create attachements for testing 17 */ 18 private function _make_attachment( $file, $parent_post_id = 0 ) { 13 public function _make_attachment( $file, $parent_post_id = 0 ) { 19 14 $contents = file_get_contents( $file ); 20 15 $upload = wp_upload_bits( basename( $file ), null, $contents ); 21 16 22 $type = ''; 23 if ( ! empty( $upload['type'] ) ) { 24 $type = $upload['type']; 25 } else { 26 $mime = wp_check_filetype( $upload['file'] ); 27 if ( $mime ) { 28 $type = $mime['type']; 29 } 30 } 31 32 $attachment = array( 33 'post_title' => basename( $upload['file'] ), 34 'post_content' => '', 35 'post_type' => 'attachment', 36 'post_parent' => $parent_post_id, 37 'post_mime_type' => $type, 38 'guid' => $upload['url'], 39 ); 40 41 // Save the data 42 $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $parent_post_id ); 43 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); 44 45 $this->ids[] = $id; 46 return $id; 17 return parent::_make_attachment( $upload, $parent_post_id ); 47 18 } 48 19
Note: See TracChangeset
for help on using the changeset viewer.