<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[35309] trunk/tests/phpunit: Unit Tests: consolidate the many separate implementations of `_make_attachment()` into a helper method on `WP_UnitTestCase`.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/35309">35309</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/35309","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>wonderboymusic</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-10-21 01:58:52 +0000 (Wed, 21 Oct 2015)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Unit Tests: consolidate the many separate implementations of `_make_attachment()` into a helper method on `WP_UnitTestCase`.
Fixes <a href="https://core.trac.wordpress.org/ticket/34075">#34075</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunitincludestestcasephp">trunk/tests/phpunit/includes/testcase.php</a></li>
<li><a href="#trunktestsphpunittestsajaxMediaEditphp">trunk/tests/phpunit/tests/ajax/MediaEdit.php</a></li>
<li><a href="#trunktestsphpunittestsgeneraltemplatephp">trunk/tests/phpunit/tests/general/template.php</a></li>
<li><a href="#trunktestsphpunittestsimageheaderphp">trunk/tests/phpunit/tests/image/header.php</a></li>
<li><a href="#trunktestsphpunittestsimageintermediate_sizephp">trunk/tests/phpunit/tests/image/intermediate_size.php</a></li>
<li><a href="#trunktestsphpunittestsimagesite_iconphp">trunk/tests/phpunit/tests/image/site_icon.php</a></li>
<li><a href="#trunktestsphpunittestspostattachmentsphp">trunk/tests/phpunit/tests/post/attachments.php</a></li>
<li><a href="#trunktestsphpunittestsxmlrpcwpgetMediaItemphp">trunk/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunitincludestestcasephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/includes/testcase.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/includes/testcase.php 2015-10-20 22:44:44 UTC (rev 35308)
+++ trunk/tests/phpunit/includes/testcase.php 2015-10-21 01:58:52 UTC (rev 35309)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -420,7 +420,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> unset($GLOBALS['wp_query'], $GLOBALS['wp_the_query']);
</span><span class="cx" style="display: block; padding: 0 10px"> $GLOBALS['wp_the_query'] = new WP_Query();
</span><span class="cx" style="display: block; padding: 0 10px"> $GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $public_query_vars = $GLOBALS['wp']->public_query_vars;
</span><span class="cx" style="display: block; padding: 0 10px"> $private_query_vars = $GLOBALS['wp']->private_query_vars;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -723,4 +723,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_rewrite->set_permalink_structure( $structure );
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_rewrite->flush_rules();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ function _make_attachment($upload, $parent_post_id = 0) {
+ $type = '';
+ if ( !empty($upload['type']) ) {
+ $type = $upload['type'];
+ } else {
+ $mime = wp_check_filetype( $upload['file'] );
+ if ($mime)
+ $type = $mime['type'];
+ }
+
+ $attachment = array(
+ 'post_title' => basename( $upload['file'] ),
+ 'post_content' => '',
+ 'post_type' => 'attachment',
+ 'post_parent' => $parent_post_id,
+ 'post_mime_type' => $type,
+ 'guid' => $upload[ 'url' ],
+ );
+
+ // Save the data
+ $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $parent_post_id );
+ wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );
+ return $id;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsajaxMediaEditphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/ajax/MediaEdit.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/ajax/MediaEdit.php 2015-10-20 22:44:44 UTC (rev 35308)
+++ trunk/tests/phpunit/tests/ajax/MediaEdit.php 2015-10-21 01:58:52 UTC (rev 35309)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -15,59 +15,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Ajax_MediaEdit extends WP_Ajax_UnitTestCase {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * List of media thumbnail ids
- * @var array
- */
- protected $_ids = array();
-
- /**
- * Set up the test fixture.
- */
- public function setUp() {
- parent::setUp();
- }
-
- /**
</del><span class="cx" style="display: block; padding: 0 10px"> * Tear down the test fixture.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function tearDown() {
</span><span class="cx" style="display: block; padding: 0 10px"> // Cleanup
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $this->_ids as $id ) {
- wp_delete_attachment( $id, true );
- }
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->remove_added_uploads();
</ins><span class="cx" style="display: block; padding: 0 10px"> parent::tearDown();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Function snagged from ./tests/post/attachments.php
- */
- function _make_attachment($upload, $parent_post_id = 0) {
- $type = '';
- if ( !empty($upload['type']) ) {
- $type = $upload['type'];
- } else {
- $mime = wp_check_filetype( $upload['file'] );
- if ($mime)
- $type = $mime['type'];
- }
-
- $attachment = array(
- 'post_title' => basename( $upload['file'] ),
- 'post_content' => '',
- 'post_type' => 'attachment',
- 'post_parent' => $parent_post_id,
- 'post_mime_type' => $type,
- 'guid' => $upload[ 'url' ],
- );
-
- // Save the data
- $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $parent_post_id );
- wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );
- return $this->_ids[] = $id;
- }
-
- /**
</del><span class="cx" style="display: block; padding: 0 10px"> * @ticket 22985
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function testCropImageThumbnail() {
</span></span></pre></div>
<a id="trunktestsphpunittestsgeneraltemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/general/template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/general/template.php 2015-10-20 22:44:44 UTC (rev 35308)
+++ trunk/tests/phpunit/tests/general/template.php 2015-10-21 01:58:52 UTC (rev 35309)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -154,27 +154,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $contents = file_get_contents( $filename );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $upload = wp_upload_bits( basename( $filename ), null, $contents );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $type = '';
- if ( ! empty( $upload['type'] ) ) {
- $type = $upload['type'];
- } else {
- $mime = wp_check_filetype( $upload['file'] );
- if ( $mime ) {
- $type = $mime['type'];
- }
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->site_icon_url = $upload['url'];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $attachment = array(
- 'post_title' => basename( $upload['file'] ),
- 'post_content' => $upload['url'],
- 'post_type' => 'attachment',
- 'post_mime_type' => $type,
- 'guid' => $upload['url'],
- );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Save the data
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->site_icon_url = $upload['url'];
- $this->site_icon_id = wp_insert_attachment( $attachment, $upload['file'] );
- wp_update_attachment_metadata( $this->site_icon_id, wp_generate_attachment_metadata( $this->site_icon_id, $upload['file'] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->site_icon_id = $this->_make_attachment( $upload );
+ return $this->site_icon_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsimageheaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/image/header.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/image/header.php 2015-10-20 22:44:44 UTC (rev 35308)
+++ trunk/tests/phpunit/tests/image/header.php 2015-10-21 01:58:52 UTC (rev 35309)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -104,8 +104,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_create_attachment_object() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $custom_image_header;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $id = wp_insert_attachment( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => 'foo.png',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -123,8 +121,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_insert_cropped_attachment() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $custom_image_header;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $id = wp_insert_attachment( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => 'foo.png',
</span></span></pre></div>
<a id="trunktestsphpunittestsimageintermediate_sizephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/image/intermediate_size.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/image/intermediate_size.php 2015-10-20 22:44:44 UTC (rev 35308)
+++ trunk/tests/phpunit/tests/image/intermediate_size.php 2015-10-21 01:58:52 UTC (rev 35309)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,45 +5,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group upload
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Image_Intermediate_Size extends WP_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected $ids = array();
-
</del><span class="cx" style="display: block; padding: 0 10px"> function tearDown() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->remove_added_uploads();
</span><span class="cx" style="display: block; padding: 0 10px"> parent::tearDown();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Upload files and create attachements for testing
- */
- private function _make_attachment( $file, $parent_post_id = 0 ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function _make_attachment( $file, $parent_post_id = 0 ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $contents = file_get_contents( $file );
</span><span class="cx" style="display: block; padding: 0 10px"> $upload = wp_upload_bits( basename( $file ), null, $contents );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $type = '';
- if ( ! empty( $upload['type'] ) ) {
- $type = $upload['type'];
- } else {
- $mime = wp_check_filetype( $upload['file'] );
- if ( $mime ) {
- $type = $mime['type'];
- }
- }
-
- $attachment = array(
- 'post_title' => basename( $upload['file'] ),
- 'post_content' => '',
- 'post_type' => 'attachment',
- 'post_parent' => $parent_post_id,
- 'post_mime_type' => $type,
- 'guid' => $upload['url'],
- );
-
- // Save the data
- $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $parent_post_id );
- wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );
-
- $this->ids[] = $id;
- return $id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return parent::_make_attachment( $upload, $parent_post_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_make_intermediate_size_no_size() {
</span></span></pre></div>
<a id="trunktestsphpunittestsimagesite_iconphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/image/site_icon.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/image/site_icon.php 2015-10-20 22:44:44 UTC (rev 35308)
+++ trunk/tests/phpunit/tests/image/site_icon.php 2015-10-21 01:58:52 UTC (rev 35309)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -158,28 +158,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $contents = file_get_contents( $filename );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $upload = wp_upload_bits( basename( $filename ), null, $contents );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $type = '';
- if ( ! empty( $upload['type'] ) ) {
- $type = $upload['type'];
- } else {
- $mime = wp_check_filetype( $upload['file'] );
- if ( $mime ) {
- $type = $mime['type'];
- }
- }
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $attachment = array(
- 'post_title' => basename( $upload['file'] ),
- 'post_content' => $upload['url'],
- 'post_type' => 'attachment',
- 'post_mime_type' => $type,
- 'guid' => $upload['url'],
- );
-
- // Save the data
- $this->attachment_id = wp_insert_attachment( $attachment, $upload['file'] );
- wp_update_attachment_metadata( $this->attachment_id, wp_generate_attachment_metadata( $this->attachment_id, $upload['file'] ) );
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->attachment_id = $this->_make_attachment( $upload );
</ins><span class="cx" style="display: block; padding: 0 10px"> return $this->attachment_id;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestspostattachmentsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/post/attachments.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/post/attachments.php 2015-10-20 22:44:44 UTC (rev 35308)
+++ trunk/tests/phpunit/tests/post/attachments.php 2015-10-21 01:58:52 UTC (rev 35309)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,7 +6,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group upload
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Post_Attachments extends WP_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected $ids = array();
</del><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function tearDown() {
</span><span class="cx" style="display: block; padding: 0 10px"> // Remove all uploads.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -14,42 +13,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> parent::tearDown();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function _make_attachment( $upload, $parent_post_id = 0 ) {
-
- $type = '';
- if ( !empty($upload['type']) ) {
- $type = $upload['type'];
- } else {
- $mime = wp_check_filetype( $upload['file'] );
- if ($mime)
- $type = $mime['type'];
- }
-
- $attachment = array(
- 'post_title' => basename( $upload['file'] ),
- 'post_content' => '',
- 'post_type' => 'attachment',
- 'post_parent' => $parent_post_id,
- 'post_mime_type' => $type,
- 'guid' => $upload[ 'url' ],
- );
-
- // Save the data
- $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $parent_post_id );
- wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );
-
- return $this->ids[] = $id;
-
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> function test_insert_bogus_image() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $filename = rand_str().'.jpg';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $filename = rand_str() . '.jpg';
</ins><span class="cx" style="display: block; padding: 0 10px"> $contents = rand_str();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $upload = wp_upload_bits($filename, null, $contents);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $upload = wp_upload_bits( $filename, null, $contents );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( empty($upload['error']) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- $id = $this->_make_attachment($upload);
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_insert_image_no_thumb() {
</span></span></pre></div>
<a id="trunktestsphpunittestsxmlrpcwpgetMediaItemphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php 2015-10-20 22:44:44 UTC (rev 35308)
+++ trunk/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php 2015-10-21 01:58:52 UTC (rev 35309)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -22,19 +22,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $filename = ( DIR_TESTDATA.'/images/waffles.jpg' );
</span><span class="cx" style="display: block; padding: 0 10px"> $contents = file_get_contents( $filename );
</span><span class="cx" style="display: block; padding: 0 10px"> $upload = wp_upload_bits(basename($filename), null, $contents);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $mime = wp_check_filetype( $filename );
- $this->attachment_data = array(
- 'post_title' => basename( $upload['file'] ),
- 'post_content' => '',
- 'post_type' => 'attachment',
- 'post_parent' => $this->post_id,
- 'post_mime_type' => $mime['type'],
- 'guid' => $upload[ 'url' ]
- );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = wp_insert_attachment( $this->attachment_data, $upload[ 'file' ], $this->post_id );
- wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );
- $this->attachment_id = $id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->attachment_id = $this->_make_attachment( $upload, $this->post_id );
+ $this->attachment_data = get_post( $this->attachment_id, ARRAY_A );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> set_post_thumbnail( $this->post_id, $this->attachment_id );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -42,6 +32,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function tearDown() {
</span><span class="cx" style="display: block; padding: 0 10px"> remove_theme_support( 'post-thumbnails' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->remove_added_uploads();
+
</ins><span class="cx" style="display: block; padding: 0 10px"> parent::tearDown();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre>
</div>
</div>
</body>
</html>