<!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>[54428] trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php: Tests: Minimize file copying in `WP_REST_Attachments_Controller` tests.</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 { white-space: pre-line; 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/54428">54428</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/54428","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-10-09 17:45:54 +0000 (Sun, 09 Oct 2022)</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'>Tests: Minimize file copying in `WP_REST_Attachments_Controller` tests.
The tests use two images that were deleted on teardown and recreated on setup for every single test. This appears to be unnecessary, as the files can instead only be recreated if they are missing, and deleted after the test run is complete.
This commit reduces ~200 redundant file copying operations to ~5 when running this test class.
Follow-up to <a href="https://core.trac.wordpress.org/changeset/38832">[38832]</a>, <a href="https://core.trac.wordpress.org/changeset/48291">[48291]</a>, <a href="https://core.trac.wordpress.org/changeset/54424">[54424]</a>.
See <a href="https://core.trac.wordpress.org/ticket/55652">#55652</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsrestapirestattachmentscontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestsrestapirestattachmentscontrollerphp"></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/rest-api/rest-attachments-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php 2022-10-09 17:10:22 UTC (rev 54427)
+++ trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php 2022-10-09 17:45:54 UTC (rev 54428)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -22,12 +22,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @var string The path to a test file.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- private $test_file;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private static $test_file;
</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"> * @var string The path to a second test file.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- private $test_file2;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private static $test_file2;
</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"> * @var array The recorded posts query clauses.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -68,6 +68,13 @@
</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"> public static function wpTearDownAfterClass() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( file_exists( self::$test_file ) ) {
+ unlink( self::$test_file );
+ }
+ if ( file_exists( self::$test_file2 ) ) {
+ unlink( self::$test_file2 );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> self::delete_user( self::$editor_id );
</span><span class="cx" style="display: block; padding: 0 10px"> self::delete_user( self::$author_id );
</span><span class="cx" style="display: block; padding: 0 10px"> self::delete_user( self::$contributor_id );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -85,11 +92,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $role->add_cap( 'level_0' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $orig_file = DIR_TESTDATA . '/images/canola.jpg';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file = get_temp_dir() . 'canola.jpg';
- copy( $orig_file, $this->test_file );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file = get_temp_dir() . 'canola.jpg';
+ if ( ! file_exists( self::$test_file ) ) {
+ copy( $orig_file, self::$test_file );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $orig_file2 = DIR_TESTDATA . '/images/codeispoetry.png';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file2 = get_temp_dir() . 'codeispoetry.png';
- copy( $orig_file2, $this->test_file2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file2 = get_temp_dir() . 'codeispoetry.png';
+ if ( ! file_exists( self::$test_file2 ) ) {
+ copy( $orig_file2, self::$test_file2 );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'rest_pre_dispatch', array( $this, 'wpSetUpBeforeRequest' ), 10, 3 );
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'posts_clauses', array( $this, 'save_posts_clauses' ), 10, 2 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -106,13 +118,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"> public function tear_down() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( file_exists( $this->test_file ) ) {
- unlink( $this->test_file );
- }
- if ( file_exists( $this->test_file2 ) ) {
- unlink( $this->test_file2 );
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> $this->remove_added_uploads();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( class_exists( WP_Image_Editor_Mock::class ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -183,7 +188,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
</span><span class="cx" style="display: block; padding: 0 10px"> // Single.
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -244,7 +249,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_registered_get_item_params() {
</span><span class="cx" style="display: block; padding: 0 10px"> $id1 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -264,7 +269,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_allow_header_sent_on_options_request() {
</span><span class="cx" style="display: block; padding: 0 10px"> $id1 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -292,7 +297,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_items() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> $id1 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -301,7 +306,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $draft_post = self::factory()->post->create( array( 'post_status' => 'draft' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $id2 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> $draft_post,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -310,7 +315,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $published_post = self::factory()->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $id3 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> $published_post,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -332,7 +337,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_items_logged_in_editor() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$editor_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $id1 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -341,7 +346,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $draft_post = self::factory()->post->create( array( 'post_status' => 'draft' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $id2 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> $draft_post,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -350,7 +355,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $published_post = self::factory()->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $id3 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> $published_post,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -370,7 +375,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_items_media_type() {
</span><span class="cx" style="display: block; padding: 0 10px"> $id1 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -393,7 +398,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_items_mime_type() {
</span><span class="cx" style="display: block; padding: 0 10px"> $id1 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -417,7 +422,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_items_parent() {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = self::factory()->post->create( array( 'post_title' => 'Test Post' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> $post_id,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -425,7 +430,7 @@
</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"> $attachment_id2 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -461,7 +466,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_items_invalid_status_param_is_error_response() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$editor_id );
</span><span class="cx" style="display: block; padding: 0 10px"> self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -479,7 +484,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Logged out users can't make the request.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id1 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -503,7 +508,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Logged out users can't make the request.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id1 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -512,7 +517,7 @@
</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"> $attachment_id2 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -548,7 +553,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_items_valid_date() {
</span><span class="cx" style="display: block; padding: 0 10px"> $id1 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_date' => '2016-01-15T00:00:00Z',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -557,7 +562,7 @@
</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"> $id2 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_date' => '2016-01-16T00:00:00Z',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -566,7 +571,7 @@
</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"> $id3 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_date' => '2016-01-17T00:00:00Z',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -599,7 +604,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_items_valid_modified_date() {
</span><span class="cx" style="display: block; padding: 0 10px"> $id1 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_date' => '2016-01-01 00:00:00',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -608,7 +613,7 @@
</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"> $id2 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_date' => '2016-01-02 00:00:00',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -617,7 +622,7 @@
</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"> $id3 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_date' => '2016-01-03 00:00:00',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -659,7 +664,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_items_with_empty_page_runs_count_query_after() {
</span><span class="cx" style="display: block; padding: 0 10px"> self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_date' => '2022-06-12T00:00:00Z',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -681,7 +686,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_item() {
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -701,17 +706,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_item_sizes() {
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_excerpt' => 'A sample caption',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file
</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"> add_image_size( 'rest-api-test', 119, 119, true );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/media/' . $attachment_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -732,17 +737,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_item_sizes_with_no_url() {
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_excerpt' => 'A sample caption',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file
</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"> add_image_size( 'rest-api-test', 119, 119, true );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'wp_get_attachment_image_src', '__return_false' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -760,7 +765,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> $draft_post = self::factory()->post->create( array( 'post_status' => 'draft' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $id1 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> $draft_post,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -774,7 +779,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_item_inherit_status_with_invalid_parent() {
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> REST_TESTS_IMPOSSIBLY_HIGH_NUMBER,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -791,7 +796,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_item_auto_status_with_invalid_parent_not_authenticated_returns_error() {
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> REST_TESTS_IMPOSSIBLY_HIGH_NUMBER,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -819,7 +824,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'description', 'Without a description, my attachment is descriptionless.' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'alt_text', 'Alt text is stored outside post schema.' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_body( file_get_contents( $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_body( file_get_contents( self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $response->get_data();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -843,14 +848,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_file_params(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'file' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'file' => file_get_contents( $this->test_file2 ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'file' => file_get_contents( self::$test_file2 ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'name' => 'codeispoetry.png',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'size' => filesize( $this->test_file2 ),
- 'tmp_name' => $this->test_file2,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'size' => filesize( self::$test_file2 ),
+ 'tmp_name' => self::$test_file2,
</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"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_header( 'Content-MD5', md5_file( $this->test_file2 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_header( 'Content-MD5', md5_file( self::$test_file2 ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 201, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $response->get_data();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -866,14 +871,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_file_params(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'file' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'file' => file_get_contents( $this->test_file ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'file' => file_get_contents( self::$test_file ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'name' => 'canola.jpg',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'size' => filesize( $this->test_file ),
- 'tmp_name' => $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'size' => filesize( self::$test_file ),
+ 'tmp_name' => self::$test_file,
</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"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_header( 'Content-MD5', md5_file( $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_header( 'Content-MD5', md5_file( self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 201, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -887,14 +892,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_file_params(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'file' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'file' => file_get_contents( $this->test_file ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'file' => file_get_contents( self::$test_file ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'name' => 'canola.jpg',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'size' => filesize( $this->test_file ),
- 'tmp_name' => $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'size' => filesize( self::$test_file ),
+ 'tmp_name' => self::$test_file,
</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"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_header( 'Content-MD5', md5_file( $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_header( 'Content-MD5', md5_file( self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 201, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -909,7 +914,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_create_item_missing_content_type() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$author_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/media' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_body( file_get_contents( $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_body( file_get_contents( self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_upload_no_content_type', $response, 400 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -918,7 +923,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$author_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/media' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-Type', 'image/jpeg' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_body( file_get_contents( $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_body( file_get_contents( self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_upload_no_content_disposition', $response, 400 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -929,7 +934,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-Type', 'image/jpeg' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-MD5', 'abc123' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_body( file_get_contents( $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_body( file_get_contents( self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_upload_hash_mismatch', $response, 412 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -940,10 +945,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_file_params(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'file' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'file' => file_get_contents( $this->test_file ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'file' => file_get_contents( self::$test_file ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'name' => 'canola.jpg',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'size' => filesize( $this->test_file ),
- 'tmp_name' => $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'size' => filesize( self::$test_file ),
+ 'tmp_name' => self::$test_file,
</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"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -989,7 +994,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/media' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-Type', 'image/jpeg' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_body( file_get_contents( $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_body( file_get_contents( self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'post', $attachment_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1004,7 +1009,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-Type', 'image/jpeg' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_body( file_get_contents( $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_body( file_get_contents( self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'alt_text', 'test alt text' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment = $response->get_data();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1019,7 +1024,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/media' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-Type', 'image/jpeg' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_body( file_get_contents( $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_body( file_get_contents( self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'alt_text', '<script>alert(document.cookie)</script>' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment = $response->get_data();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1035,7 +1040,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/media' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-Type', 'image/jpeg' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_body( file_get_contents( $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_body( file_get_contents( self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment = $response->get_data();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringNotContainsString( ABSPATH, get_post_meta( $attachment['id'], '_wp_attached_file', true ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1044,7 +1049,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_item() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$editor_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1074,7 +1079,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$editor_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $original_parent = self::factory()->post->create( array() );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> $original_parent,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1098,7 +1103,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_item_invalid_permissions() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$author_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1122,7 +1127,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$editor_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1143,7 +1148,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$editor_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $parent_id = self::factory()->post->create( array() );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> $parent_id,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1166,7 +1171,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_item_with_new_inherit_status() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$editor_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1188,7 +1193,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/media' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-Type', 'image/jpeg' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_body( file_get_contents( $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_body( file_get_contents( self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $input as $name => $value ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( $name, $value );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1446,7 +1451,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_delete_item() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$editor_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1462,7 +1467,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_delete_item_no_trash() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$editor_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1487,7 +1492,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_delete_item_invalid_delete_permissions() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$author_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1502,7 +1507,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_prepare_item() {
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1521,7 +1526,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_prepare_item_limit_fields() {
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1612,7 +1617,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1649,7 +1654,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$editor_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1675,7 +1680,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_search_item_by_filename() {
</span><span class="cx" style="display: block; padding: 0 10px"> $id1 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1682,7 +1687,7 @@
</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"> $id2 = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file2,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file2,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/png',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1689,7 +1694,7 @@
</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">- $filename = wp_basename( $this->test_file2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $filename = wp_basename( self::$test_file2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/media' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'search', $filename );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1801,16 +1806,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'file' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'error' => '0',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'file' => file_get_contents( $this->test_file ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'file' => file_get_contents( self::$test_file ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'name' => 'canola.jpg',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'size' => filesize( $this->test_file ),
- 'tmp_name' => $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'size' => filesize( self::$test_file ),
+ 'tmp_name' => self::$test_file,
</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"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'title', 'My title is very cool' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'caption', 'This is a better caption.' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_header( 'Content-MD5', md5_file( $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_header( 'Content-MD5', md5_file( self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_upload_file_too_big', $response, 400 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1829,7 +1834,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/media' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-Type', 'image/jpeg' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_body( file_get_contents( $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_body( file_get_contents( self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'title', 'My title is very cool' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'caption', 'This is a better caption.' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1852,16 +1857,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'file' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'error' => '0',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'file' => file_get_contents( $this->test_file ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'file' => file_get_contents( self::$test_file ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'name' => 'canola.jpg',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'size' => filesize( $this->test_file ),
- 'tmp_name' => $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'size' => filesize( self::$test_file ),
+ 'tmp_name' => self::$test_file,
</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"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'title', 'My title is very cool' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'caption', 'This is a better caption.' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_header( 'Content-MD5', md5_file( $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_header( 'Content-MD5', md5_file( self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_upload_limited_space', $response, 400 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1880,7 +1885,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/media' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-Type', 'image/jpeg' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_body( file_get_contents( $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_body( file_get_contents( self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'title', 'My title is very cool' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'caption', 'This is a better caption.' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1910,7 +1915,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'description', 'Without a description, my attachment is descriptionless.' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'alt_text', 'Alt text is stored outside post schema.' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_body( file_get_contents( $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_body( file_get_contents( self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $response->get_data();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 201, $response->get_status() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1933,7 +1938,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$editor_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_object(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->test_file,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$test_file,
</ins><span class="cx" style="display: block; padding: 0 10px"> 0,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_mime_type' => 'image/jpeg',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1971,7 +1976,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_header( 'Content-Disposition', 'attachment; filename=cannoli.jpg' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'meta', array( 'best_cannoli' => 'Chocolate-dipped, no filling' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_body( file_get_contents( $this->test_file ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_body( file_get_contents( self::$test_file ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $response->get_data();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1992,7 +1997,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @requires function imagejpeg
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_edit_image_returns_error_if_logged_out() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $attachment = self::factory()->attachment->create_upload_object( $this->test_file );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $attachment = self::factory()->attachment->create_upload_object( self::$test_file );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', "/wp/v2/media/{$attachment}/edit" );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( array( 'src' => wp_get_attachment_image_url( $attachment, 'full' ) ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2009,7 +2014,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $user->add_cap( 'upload_files', false );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( $user->ID );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $attachment = self::factory()->attachment->create_upload_object( $this->test_file );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $attachment = self::factory()->attachment->create_upload_object( self::$test_file );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', "/wp/v2/media/{$attachment}/edit" );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( array( 'src' => wp_get_attachment_image_url( $attachment, 'full' ) ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2023,7 +2028,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_edit_image_returns_error_if_cannot_edit() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$uploader_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $attachment = self::factory()->attachment->create_upload_object( $this->test_file );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $attachment = self::factory()->attachment->create_upload_object( self::$test_file );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', "/wp/v2/media/{$attachment}/edit" );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( array( 'src' => wp_get_attachment_image_url( $attachment, 'full' ) ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2050,7 +2055,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_edit_image_returns_error_if_unsupported_mime_type() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$superadmin_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $attachment = self::factory()->attachment->create_upload_object( $this->test_file );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $attachment = self::factory()->attachment->create_upload_object( self::$test_file );
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_update_post(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'ID' => $attachment,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2070,7 +2075,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_edit_image_returns_error_if_no_edits() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$superadmin_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $attachment = self::factory()->attachment->create_upload_object( $this->test_file );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $attachment = self::factory()->attachment->create_upload_object( self::$test_file );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', "/wp/v2/media/{$attachment}/edit" );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( array( 'src' => wp_get_attachment_image_url( $attachment, 'full' ) ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2084,7 +2089,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_edit_image_rotate() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$superadmin_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $attachment = self::factory()->attachment->create_upload_object( $this->test_file );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $attachment = self::factory()->attachment->create_upload_object( self::$test_file );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->setup_mock_editor();
</span><span class="cx" style="display: block; padding: 0 10px"> WP_Image_Editor_Mock::$edit_return['rotate'] = new WP_Error();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2109,7 +2114,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_edit_image_crop() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$superadmin_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $attachment = self::factory()->attachment->create_upload_object( $this->test_file );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $attachment = self::factory()->attachment->create_upload_object( self::$test_file );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->setup_mock_editor();
</span><span class="cx" style="display: block; padding: 0 10px"> WP_Image_Editor_Mock::$size_return = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2146,7 +2151,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_edit_image() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$superadmin_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $attachment = self::factory()->attachment->create_upload_object( $this->test_file );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $attachment = self::factory()->attachment->create_upload_object( self::$test_file );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'rotation' => 60,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2173,7 +2178,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_batch_edit_image() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$superadmin_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $attachment = self::factory()->attachment->create_upload_object( $this->test_file );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $attachment = self::factory()->attachment->create_upload_object( self::$test_file );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'modifiers' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2216,8 +2221,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_edit_image_returns_error_if_mismatched_src() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$superadmin_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $attachment_id_image1 = self::factory()->attachment->create_upload_object( $this->test_file );
- $attachment_id_image2 = self::factory()->attachment->create_upload_object( $this->test_file2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $attachment_id_image1 = self::factory()->attachment->create_upload_object( self::$test_file );
+ $attachment_id_image2 = self::factory()->attachment->create_upload_object( self::$test_file2 );
</ins><span class="cx" style="display: block; padding: 0 10px"> $attachment_id_file = self::factory()->attachment->create();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // URL to the first uploaded image.
</span></span></pre>
</div>
</div>
</body>
</html>