Changeset 35309 for trunk/tests/phpunit/tests/ajax/MediaEdit.php
- Timestamp:
- 10/21/2015 01:58:52 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/ajax/MediaEdit.php
r29120 r35309 16 16 17 17 /** 18 * List of media thumbnail ids19 * @var array20 */21 protected $_ids = array();22 23 /**24 * Set up the test fixture.25 */26 public function setUp() {27 parent::setUp();28 }29 30 /**31 18 * Tear down the test fixture. 32 19 */ 33 20 public function tearDown() { 34 21 // Cleanup 35 foreach ( $this->_ids as $id ) { 36 wp_delete_attachment( $id, true ); 37 } 38 22 $this->remove_added_uploads(); 39 23 parent::tearDown(); 40 }41 42 /**43 * Function snagged from ./tests/post/attachments.php44 */45 function _make_attachment($upload, $parent_post_id = 0) {46 $type = '';47 if ( !empty($upload['type']) ) {48 $type = $upload['type'];49 } else {50 $mime = wp_check_filetype( $upload['file'] );51 if ($mime)52 $type = $mime['type'];53 }54 55 $attachment = array(56 'post_title' => basename( $upload['file'] ),57 'post_content' => '',58 'post_type' => 'attachment',59 'post_parent' => $parent_post_id,60 'post_mime_type' => $type,61 'guid' => $upload[ 'url' ],62 );63 64 // Save the data65 $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $parent_post_id );66 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );67 return $this->_ids[] = $id;68 24 } 69 25
Note: See TracChangeset
for help on using the changeset viewer.