Changeset 35309 for trunk/tests/phpunit/includes/testcase.php
- Timestamp:
- 10/21/2015 01:58:52 AM (10 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/includes/testcase.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/testcase.php
r35258 r35309 421 421 $GLOBALS['wp_the_query'] = new WP_Query(); 422 422 $GLOBALS['wp_query'] = $GLOBALS['wp_the_query']; 423 423 424 424 $public_query_vars = $GLOBALS['wp']->public_query_vars; 425 425 $private_query_vars = $GLOBALS['wp']->private_query_vars; … … 724 724 $wp_rewrite->flush_rules(); 725 725 } 726 727 function _make_attachment($upload, $parent_post_id = 0) { 728 $type = ''; 729 if ( !empty($upload['type']) ) { 730 $type = $upload['type']; 731 } else { 732 $mime = wp_check_filetype( $upload['file'] ); 733 if ($mime) 734 $type = $mime['type']; 735 } 736 737 $attachment = array( 738 'post_title' => basename( $upload['file'] ), 739 'post_content' => '', 740 'post_type' => 'attachment', 741 'post_parent' => $parent_post_id, 742 'post_mime_type' => $type, 743 'guid' => $upload[ 'url' ], 744 ); 745 746 // Save the data 747 $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $parent_post_id ); 748 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); 749 return $id; 750 } 726 751 }
Note: See TracChangeset
for help on using the changeset viewer.