<!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>[38975] trunk/tests/phpunit/tests/rest-api: Share fixtures in REST API endpoint 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 { 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/38975">38975</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/38975","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>boonebgorges</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-10-27 02:56:28 +0000 (Thu, 27 Oct 2016)</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'>Share fixtures in REST API endpoint tests.
As sparrows' tears shed steadily
Make widest rivers filled,
`setUp()` routines run prodig'ly
Add minutes to a build.
So cull ye fixtures profligate!
Direct thine frugal gaze!
Our savings here - a half-minute -
When multiplied: Amaze!
See <a href="https://core.trac.wordpress.org/ticket/30017">#30017</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsrestapirestattachmentscontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestcategoriescontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-categories-controller.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestcommentscontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestpagescontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-pages-controller.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestpostmetafieldsphp">trunk/tests/phpunit/tests/rest-api/rest-post-meta-fields.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestpostscontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestrevisionscontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-revisions-controller.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestsettingscontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-settings-controller.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestuserscontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-users-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 2016-10-27 01:41:08 UTC (rev 38974)
+++ trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php 2016-10-27 02:56:28 UTC (rev 38975)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10,29 +10,42 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group restapi
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Controller_Testcase {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $editor_id;
+ protected static $author_id;
+ protected static $contributor_id;
+ protected static $uploader_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function setUp() {
- parent::setUp();
-
- $this->editor_id = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( $factory ) {
+ self::$editor_id = $factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'editor',
</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->author_id = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$author_id = $factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'author',
</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->contributor_id = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$contributor_id = $factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'contributor',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$uploader_id = $factory->user->create( array(
+ 'role' => 'uploader',
+ ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ self::delete_user( self::$editor_id );
+ self::delete_user( self::$author_id );
+ self::delete_user( self::$contributor_id );
+ self::delete_user( self::$uploader_id );
+ }
+
+ public function setUp() {
+ parent::setUp();
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Add an uploader role to test upload capabilities.
</span><span class="cx" style="display: block; padding: 0 10px"> add_role( 'uploader', 'File upload role' );
</span><span class="cx" style="display: block; padding: 0 10px"> $role = get_role( 'uploader' );
</span><span class="cx" style="display: block; padding: 0 10px"> $role->add_cap( 'upload_files' );
</span><span class="cx" style="display: block; padding: 0 10px"> $role->add_cap( 'read' );
</span><span class="cx" style="display: block; padding: 0 10px"> $role->add_cap( 'level_0' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->uploader_id = $this->factory->user->create( array(
- 'role' => 'uploader',
- ) );
</del><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><span class="cx" style="display: block; padding: 0 10px"> $this->test_file = '/tmp/canola.jpg';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -179,7 +192,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"> public function test_get_items_logged_in_editor() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $id1 = $this->factory->attachment->create_object( $this->test_file, 0, 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="lines" style="display: block; padding: 0 10px; color: #888">@@ -280,7 +293,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"> public function test_get_items_invalid_status_param_is_error_response() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->factory->attachment->create_object( $this->test_file, 0, 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="lines" style="display: block; padding: 0 10px; color: #888">@@ -307,7 +320,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
</span><span class="cx" style="display: block; padding: 0 10px"> // Properly authorized users can make the request
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $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">@@ -415,7 +428,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"> public function test_create_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</ins><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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -427,7 +440,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"> public function test_create_item_default_filename_title() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</ins><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_file_params( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'file' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -445,7 +458,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"> public function test_create_item_with_files() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</ins><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_file_params( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'file' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -461,7 +474,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"> public function test_create_item_with_upload_files_role() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->uploader_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$uploader_id );
</ins><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_file_params( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'file' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -477,14 +490,14 @@
</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 test_create_item_empty_body() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</ins><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"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_upload_no_data', $response, 400 );
</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 test_create_item_missing_content_type() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</ins><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_body( file_get_contents( $this->test_file ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -492,7 +505,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"> public function test_create_item_missing_content_disposition() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</ins><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_body( file_get_contents( $this->test_file ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -501,7 +514,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"> public function test_create_item_bad_md5_header() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</ins><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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -512,7 +525,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"> public function test_create_item_with_files_bad_md5_header() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</ins><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_file_params( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'file' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -528,15 +541,15 @@
</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 test_create_item_invalid_upload_files_capability() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->contributor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$contributor_id );
</ins><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"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_cannot_create', $response, 403 );
</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 test_create_item_invalid_edit_permissions() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_id = $this->factory->post->create( array( 'post_author' => $this->editor_id ) );
- wp_set_current_user( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = $this->factory->post->create( array( 'post_author' => self::$editor_id ) );
+ wp_set_current_user( self::$author_id );
</ins><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_param( 'post', $post_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -544,8 +557,8 @@
</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 test_create_item_invalid_upload_permissions() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_id = $this->factory->post->create( array( 'post_author' => $this->editor_id ) );
- wp_set_current_user( $this->uploader_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = $this->factory->post->create( array( 'post_author' => self::$editor_id ) );
+ wp_set_current_user( self::$uploader_id );
</ins><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_param( 'post', $post_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -554,7 +567,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_create_item_invalid_post_type() {
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = $this->factory->post->create( array( 'post_type' => 'attachment', 'post_status' => 'inherit', 'post_parent' => 0 ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -565,7 +578,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"> public function test_create_item_alt_text() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</ins><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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -578,7 +591,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"> public function test_create_item_unsafe_alt_text() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</ins><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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -590,11 +603,11 @@
</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 test_update_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = $this->factory->attachment->create_object( $this->test_file, 0, 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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->editor_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_author' => self::$editor_id,
</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_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'title', 'My title is very cool' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -615,7 +628,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"> public function test_update_item_parent() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $original_parent = $this->factory->post->create( array() );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = $this->factory->attachment->create_object( $this->test_file, $original_parent, 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">@@ -636,11 +649,11 @@
</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 test_update_item_invalid_permissions() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = $this->factory->attachment->create_object( $this->test_file, 0, 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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->editor_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_author' => self::$editor_id,
</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_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'caption', 'This is a better caption.' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -650,11 +663,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_item_invalid_post_type() {
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = $this->factory->post->create( array( 'post_type' => 'attachment', 'post_status' => 'inherit', 'post_parent' => 0 ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = $this->factory->attachment->create_object( $this->test_file, 0, 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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->editor_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_author' => self::$editor_id,
</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_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'post', $attachment_id );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -663,7 +676,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"> public function test_delete_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = $this->factory->attachment->create_object( $this->test_file, 0, 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="lines" style="display: block; padding: 0 10px; color: #888">@@ -675,7 +688,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"> public function test_delete_item_no_trash() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = $this->factory->attachment->create_object( $this->test_file, 0, 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="lines" style="display: block; padding: 0 10px; color: #888">@@ -692,11 +705,11 @@
</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 test_delete_item_invalid_delete_permissions() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = $this->factory->attachment->create_object( $this->test_file, 0, 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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->editor_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_author' => self::$editor_id,
</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( 'DELETE', '/wp/v2/media/' . $attachment_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -707,7 +720,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = $this->factory->attachment->create_object( $this->test_file, 0, 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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->editor_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_author' => self::$editor_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment = get_post( $attachment_id );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -798,11 +811,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'update_callback' => array( $this, 'additional_field_update_callback' ),
</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">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = $this->factory->attachment->create_object( $this->test_file, 0, 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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->editor_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_author' => self::$editor_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px"> // Check for error on update.
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/media/%d', $attachment_id ) );
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestcategoriescontrollerphp"></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-categories-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-categories-controller.php 2016-10-27 01:41:08 UTC (rev 38974)
+++ trunk/tests/phpunit/tests/rest-api/rest-categories-controller.php 2016-10-27 02:56:28 UTC (rev 38975)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,17 +11,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group restapi
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcase {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $administrator;
+ protected static $subscriber;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function setUp() {
- parent::setUp();
- $this->administrator = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( $factory ) {
+ self::$administrator = $factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'administrator',
</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->subscriber = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$subscriber = $factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'subscriber',
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ self::delete_user( self::$administrator );
+ self::delete_user( self::$subscriber );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> public function test_register_routes() {
</span><span class="cx" style="display: block; padding: 0 10px"> $routes = $this->server->get_routes();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( '/wp/v2/categories', $routes );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -572,7 +578,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"> public function test_create_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/categories' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'name', 'My Awesome Term' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'description', 'This term is so awesome.' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -588,7 +594,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"> public function test_create_item_invalid_taxonomy() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/invalid-taxonomy' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'name', 'Invalid Taxonomy' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -596,7 +602,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"> public function test_create_item_incorrect_permissions() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->subscriber );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$subscriber );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/categories' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'name', 'Incorrect permissions' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -604,14 +610,14 @@
</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 test_create_item_missing_arguments() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/categories' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_missing_callback_param', $response, 400 );
</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 test_create_item_with_parent() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $parent = wp_insert_term( 'test-category', 'category' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/categories' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'name', 'My Awesome Term' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -623,7 +629,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"> public function test_create_item_invalid_parent() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $term = get_term_by( 'id', $this->factory->category->create(), 'category' );
</span><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/categories/' . $term->term_id );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -634,7 +640,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"> public function test_update_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $orig_args = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'name' => 'Original Name',
</span><span class="cx" style="display: block; padding: 0 10px"> 'description' => 'Original Description',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -654,7 +660,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"> public function test_update_item_invalid_taxonomy() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/invalid-taxonomy/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'name', 'Invalid Taxonomy' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -662,7 +668,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"> public function test_update_item_invalid_term() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'name', 'Invalid Term' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -670,7 +676,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"> public function test_update_item_incorrect_permissions() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->subscriber );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$subscriber );
</ins><span class="cx" style="display: block; padding: 0 10px"> $term = get_term_by( 'id', $this->factory->category->create(), 'category' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'name', 'Incorrect permissions' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -679,7 +685,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"> public function test_update_item_parent() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $parent = get_term_by( 'id', $this->factory->category->create(), 'category' );
</span><span class="cx" style="display: block; padding: 0 10px"> $term = get_term_by( 'id', $this->factory->category->create(), 'category' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -693,7 +699,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"> public function test_update_item_invalid_parent() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $term = get_term_by( 'id', $this->factory->category->create(), 'category' );
</span><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/categories/' . $term->term_id );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -703,7 +709,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"> public function test_delete_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $term = get_term_by( 'id', $this->factory->category->create( array( 'name' => 'Deleted Category' ) ), 'category' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'DELETE', '/wp/v2/categories/' . $term->term_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'force', true );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -714,7 +720,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"> public function test_delete_item_force_false() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $term = get_term_by( 'id', $this->factory->category->create( array( 'name' => 'Deleted Category' ) ), 'category' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'DELETE', '/wp/v2/categories/' . $term->term_id );
</span><span class="cx" style="display: block; padding: 0 10px"> // force defaults to false
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -723,21 +729,21 @@
</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 test_delete_item_invalid_taxonomy() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'DELETE', '/wp/v2/invalid-taxonomy/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_no_route', $response, 404 );
</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 test_delete_item_invalid_term() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'DELETE', '/wp/v2/categories/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_term_invalid', $response, 404 );
</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 test_delete_item_incorrect_permissions() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->subscriber );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$subscriber );
</ins><span class="cx" style="display: block; padding: 0 10px"> $term = get_term_by( 'id', $this->factory->category->create(), 'category' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'DELETE', '/wp/v2/categories/' . $term->term_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestcommentscontrollerphp"></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-comments-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-comments-controller.php 2016-10-27 01:41:08 UTC (rev 38974)
+++ trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php 2016-10-27 02:56:28 UTC (rev 38975)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,59 +11,73 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected $admin_id;
- protected $subscriber_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $admin_id;
+ protected static $subscriber_id;
+ protected static $author_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected $post_id;
- protected $private_id;
- protected $draft_id;
- protected $trash_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $post_id;
+ protected static $private_id;
+ protected static $draft_id;
+ protected static $trash_id;
+ protected static $approved_id;
+ protected static $hold_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected $approved_id;
- protected $hold_id;
-
</del><span class="cx" style="display: block; padding: 0 10px"> protected $endpoint;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function setUp() {
- parent::setUp();
-
- $this->admin_id = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( $factory ) {
+ self::$admin_id = $factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'administrator',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ));
- $this->subscriber_id = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ) );
+ self::$subscriber_id = $factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'subscriber',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ));
- $this->author_id = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ) );
+ self::$author_id = $factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'author',
</span><span class="cx" style="display: block; padding: 0 10px"> 'display_name' => 'Sea Captain',
</span><span class="cx" style="display: block; padding: 0 10px"> 'first_name' => 'Horatio',
</span><span class="cx" style="display: block; padding: 0 10px"> 'last_name' => 'McCallister',
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_email' => 'captain@thefryingdutchman.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_url' => 'http://thefryingdutchman.com',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->post_id = $this->factory->post->create();
- $this->private_id = $this->factory->post->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$post_id = $factory->post->create();
+ self::$private_id = $factory->post->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'private',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ));
- $this->draft_id = $this->factory->post->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ) );
+ self::$draft_id = $factory->post->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'draft',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ));
- $this->trash_id = $this->factory->post->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ) );
+ self::$trash_id = $factory->post->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'trash',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->approved_id = $this->factory->comment->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$approved_id = $factory->comment->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'user_id' => 0,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ));
- $this->hold_id = $this->factory->comment->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ) );
+ self::$hold_id = $factory->comment->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 0,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
- 'user_id' => $this->subscriber_id,
- ));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
+ 'user_id' => self::$subscriber_id,
+ ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ self::delete_user( self::$admin_id );
+ self::delete_user( self::$subscriber_id );
+ self::delete_user( self::$author_id );
+
+ wp_delete_post( self::$post_id, true );
+ wp_delete_post( self::$private_id, true );
+ wp_delete_post( self::$draft_id, true );
+ wp_delete_post( self::$trash_id, true );
+ wp_delete_post( self::$approved_id, true );
+ wp_delete_post( self::$hold_id, true );
+ }
+
+ public function setUp() {
+ parent::setUp();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->endpoint = new WP_REST_Comments_Controller;
</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">@@ -88,7 +102,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
</span><span class="cx" style="display: block; padding: 0 10px"> // Single
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments/' . $this->approved_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments/' . self::$approved_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->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->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -126,7 +140,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"> public function test_get_items() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->factory->comment->create_post_comments( $this->post_id, 6 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->factory->comment->create_post_comments( self::$post_id, 6 );
</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/comments' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -134,7 +148,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comments = $response->get_data();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // We created 6 comments in this method, plus $this->approved_id.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // We created 6 comments in this method, plus self::$approved_id.
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 7, $comments );
</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">@@ -143,7 +157,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $args = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->private_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$private_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $private_comment = $this->factory->comment->create( $args );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -157,11 +171,11 @@
</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 test_get_items_with_private_post_permission() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $args = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->private_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$private_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $private_comment = $this->factory->comment->create( $args );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -194,7 +208,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"> public function test_get_items_with_invalid_post_permission() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_id = $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -222,7 +236,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_no_post() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->comment->create_post_comments( 0, 2 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'post', 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -240,7 +254,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"> public function test_get_items_edit_context() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'context', 'edit' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -264,10 +278,10 @@
</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 test_get_items_include_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $args = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $id1 = $this->factory->comment->create( $args );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->comment->create( $args );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -289,10 +303,10 @@
</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 test_get_items_exclude_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $args = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $id1 = $this->factory->comment->create( $args );
</span><span class="cx" style="display: block; padding: 0 10px"> $id2 = $this->factory->comment->create( $args );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -309,10 +323,10 @@
</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 test_get_items_offset_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $args = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->comment->create( $args );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->comment->create( $args );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -332,10 +346,10 @@
</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 test_get_items_order_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $args = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->comment->create( $args );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->comment->create( $args );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -349,7 +363,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'order', 'asc' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $response->get_data();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $this->approved_id, $data[0]['id'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$approved_id, $data[0]['id'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_items_private_post_no_permissions() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -363,27 +377,27 @@
</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_author_arg() {
</span><span class="cx" style="display: block; padding: 0 10px"> // Authorized
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $args = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
- 'user_id' => $this->author_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
+ 'user_id' => self::$author_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->comment->create( $args );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $args['user_id'] = $this->subscriber_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $args['user_id'] = self::$subscriber_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->factory->comment->create( $args );
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $args['user_id'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->comment->create( $args );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // 'author' limits result to 1 of 3
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_param( 'author', $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_param( 'author', self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px"> $comments = $response->get_data();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $comments );
</span><span class="cx" style="display: block; padding: 0 10px"> // Multiple authors are supported
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_param( 'author', array( $this->author_id, $this->subscriber_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_param( 'author', array( self::$author_id, self::$subscriber_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px"> $comments = $response->get_data();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -396,14 +410,14 @@
</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_author_exclude_arg() {
</span><span class="cx" style="display: block; padding: 0 10px"> // Authorized
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $args = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
- 'user_id' => $this->author_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
+ 'user_id' => self::$author_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->comment->create( $args );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $args['user_id'] = $this->subscriber_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $args['user_id'] = self::$subscriber_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->factory->comment->create( $args );
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $args['user_id'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->comment->create( $args );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -415,14 +429,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // 'author_exclude' limits result to 3 of 4
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_param( 'author_exclude', $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_param( 'author_exclude', self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px"> $comments = $response->get_data();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 3, $comments );
</span><span class="cx" style="display: block; padding: 0 10px"> // 'author_exclude' for both comment authors (2 of 4)
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_param( 'author_exclude', array( $this->author_id, $this->subscriber_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_param( 'author_exclude', array( self::$author_id, self::$subscriber_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px"> $comments = $response->get_data();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -436,7 +450,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_items_parent_arg() {
</span><span class="cx" style="display: block; padding: 0 10px"> $args = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $parent_id = $this->factory->comment->create( $args );
</span><span class="cx" style="display: block; padding: 0 10px"> $parent_id2 = $this->factory->comment->create( $args );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -461,7 +475,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_items_parent_exclude_arg() {
</span><span class="cx" style="display: block; padding: 0 10px"> $args = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $parent_id = $this->factory->comment->create( $args );
</span><span class="cx" style="display: block; padding: 0 10px"> $parent_id2 = $this->factory->comment->create( $args );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -484,10 +498,10 @@
</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 test_get_items_search_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $args = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment_content' => 'foo',
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_author' => 'Homer J Simpson',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -509,12 +523,12 @@
</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 test_get_comments_pagination_headers() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> // Start of the index
</span><span class="cx" style="display: block; padding: 0 10px"> for ( $i = 0; $i < 49; $i++ ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_content' => "Comment {$i}",
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -530,7 +544,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // 3rd page
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_content' => 'Comment 51',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
</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/comments' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'page', 3 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -583,15 +597,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_comments_valid_date() {
</span><span class="cx" style="display: block; padding: 0 10px"> $comment1 = $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_date' => '2016-01-15T00:00:00Z',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment2 = $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_date' => '2016-01-16T00:00:00Z',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment3 = $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_date' => '2016-01-17T00:00:00Z',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -604,7 +618,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"> public function test_get_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', $this->approved_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -614,8 +628,8 @@
</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 test_prepare_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', $this->approved_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_query_params( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => 'edit',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -628,7 +642,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"> public function test_get_comment_author_avatar_urls() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', $this->approved_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -637,7 +651,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 48, $data['author_avatar_urls'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 96, $data['author_avatar_urls'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $comment = get_comment( $this->approved_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $comment = get_comment( self::$approved_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Ignore the subdomain, since 'get_avatar_url randomly sets the Gravatar
</span><span class="cx" style="display: block; padding: 0 10px"> * server when building the url string.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -654,7 +668,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_comment_invalid_context() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( 0 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $this->approved_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', self::$approved_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'context', 'edit' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_forbidden_context', $response, 401 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -673,7 +687,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"> public function test_get_comment_invalid_post_id_as_admin() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $comment_id = $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_post_ID' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -687,16 +701,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_comment_not_approved() {
</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">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', $this->hold_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', self::$hold_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_cannot_read', $response, 401 );
</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 test_get_comment_not_approved_same_user() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->subscriber_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$subscriber_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', $this->hold_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', self::$hold_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -705,15 +719,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_comment_with_children_link() {
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_id_1 = $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
- 'user_id' => $this->subscriber_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
+ 'user_id' => self::$subscriber_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $child_comment = $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_parent' => $comment_id_1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
- 'user_id' => $this->subscriber_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
+ 'user_id' => self::$subscriber_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -725,8 +739,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_comment_without_children_link() {
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_id_1 = $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
- 'user_id' => $this->subscriber_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
+ 'user_id' => self::$subscriber_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -739,7 +753,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">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => 'Comic Book Guy',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'cbg@androidsdungeon.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_url' => 'http://androidsdungeon.com',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -758,14 +772,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->check_comment_data( $data, 'view', $response->get_links() );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'hold', $data['status'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( '2014-11-07T10:14:25', $data['date'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $this->post_id, $data['post'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$post_id, $data['post'] );
</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"> public function test_create_item_using_accepted_content_raw_value() {
</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">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => 'Reverend Lovejoy',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'lovejoy@example.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_url' => 'http://timothylovejoy.jr',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -790,7 +804,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'require_name_email', 1 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'Now, I don\'t want you to worry class. These tests will have no affect on your grades. They merely determine your future social status and financial success. If any.',
</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">@@ -808,7 +822,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'require_name_email', 1 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'ekrabappel@springfield-elementary.edu',
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'Now, I don\'t want you to worry class. These tests will have no affect on your grades. They merely determine your future social status and financial success. If any.',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -827,7 +841,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'require_name_email', 1 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => 'Edna Krabappel',
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'Now, I don\'t want you to worry class. These tests will have no affect on your grades. They merely determine your future social status and financial success. If any.',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -846,7 +860,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">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => 'Reverend Lovejoy',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'lovejoy@example.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_url' => 'http://timothylovejoy.jr',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -865,7 +879,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">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => 'Reverend Lovejoy',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'lovejoy@example.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_url' => 'http://timothylovejoy.jr',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -888,9 +902,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_email' => 'cbg@androidsdungeon.com',
</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">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => 'Comic Book Guy',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'cbg@androidsdungeon.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_url' => 'http://androidsdungeon.com',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -911,11 +925,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_create_comment_without_type() {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = $this->factory->post->create();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</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"> 'post' => $post_id,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'author' => $this->admin_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'author' => self::$admin_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => 'Comic Book Guy',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'cbg@androidsdungeon.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_url' => 'http://androidsdungeon.com',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -956,7 +970,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( $user_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'content' => "Well sir, there's nothing on earth like a genuine, bona fide, electrified, six-car Monorail!",
</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">@@ -978,15 +992,15 @@
</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 test_create_comment_other_user() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => 'Homer Jay Simpson',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'chunkylover53@aol.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_url' => 'http://compuglobalhypermeganet.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'author' => $this->subscriber_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'author' => self::$subscriber_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -996,22 +1010,22 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 201, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $response->get_data();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $this->subscriber_id, $data['author'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$subscriber_id, $data['author'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'Homer Jay Simpson', $data['author_name'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'chunkylover53@aol.com', $data['author_email'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'http://compuglobalhypermeganet.com', $data['author_url'] );
</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 test_create_comment_other_user_without_permission() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->subscriber_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$subscriber_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => 'Homer Jay Simpson',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'chunkylover53@aol.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_url' => 'http://compuglobalhypermeganet.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'author' => $this->admin_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'author' => self::$admin_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1023,15 +1037,15 @@
</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 test_create_comment_karma_without_permission() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->subscriber_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$subscriber_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => 'Homer Jay Simpson',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'chunkylover53@aol.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_url' => 'http://compuglobalhypermeganet.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'author' => $this->subscriber_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'author' => self::$subscriber_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'karma' => 100,
</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">@@ -1044,15 +1058,15 @@
</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 test_create_comment_status_without_permission() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->subscriber_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$subscriber_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => 'Homer Jay Simpson',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'chunkylover53@aol.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_url' => 'http://compuglobalhypermeganet.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'author' => $this->subscriber_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'author' => self::$subscriber_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'status' => 'approved',
</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">@@ -1066,7 +1080,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_create_comment_with_status_IP_and_user_agent() {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = $this->factory->post->create();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</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"> 'post' => $post_id,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1093,7 +1107,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"> public function test_create_comment_invalid_author_IP() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</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"> 'author_name' => 'Comic Book Guy',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1113,7 +1127,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"> public function test_create_comment_no_post_id() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</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"> 'author_name' => 'Comic Book Guy',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1131,14 +1145,14 @@
</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 test_create_comment_no_post_id_no_permission() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->subscriber_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$subscriber_id );
</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"> 'author_name' => 'Homer Jay Simpson',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'chunkylover53@aol.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_url' => 'http://compuglobalhypermeganet.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'Here\’s to alcohol: the cause of, and solution to, all of life\’s problems.',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'author' => $this->subscriber_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'author' => self::$subscriber_id,
</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/comments' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->add_header( 'content-type', 'application/json' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1150,15 +1164,15 @@
</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 test_create_comment_draft_post() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->subscriber_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$subscriber_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->draft_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$draft_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => 'Ishmael',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'herman-melville@earthlink.net',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_url' => 'https://en.wikipedia.org/wiki/Herman_Melville',
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'Call me Ishmael.',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'author' => $this->subscriber_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'author' => self::$subscriber_id,
</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/comments' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->add_header( 'content-type', 'application/json' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1170,15 +1184,15 @@
</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 test_create_comment_trash_post() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->subscriber_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$subscriber_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->trash_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$trash_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => 'Ishmael',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'herman-melville@earthlink.net',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_url' => 'https://en.wikipedia.org/wiki/Herman_Melville',
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'Call me Ishmael.',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'author' => $this->subscriber_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'author' => self::$subscriber_id,
</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/comments' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->add_header( 'content-type', 'application/json' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1190,15 +1204,15 @@
</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 test_create_comment_private_post_invalid_permission() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->subscriber_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$subscriber_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->private_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$private_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => 'Homer Jay Simpson',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'chunkylover53@aol.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_url' => 'http://compuglobalhypermeganet.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'I\’d be a vegetarian if bacon grew on trees.',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'author' => $this->subscriber_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'author' => self::$subscriber_id,
</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/comments' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->add_header( 'content-type', 'application/json' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1212,7 +1226,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_create_item_duplicate() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->comment->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment_author' => 'Guy N. Cognito',
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_author_email' => 'chunkylover53@aol.co.uk',
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_content' => 'Homer? Who is Homer? My name is Guy N. Cognito.',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1221,7 +1235,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">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => 'Guy N. Cognito',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'chunkylover53@aol.co.uk',
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'Homer? Who is Homer? My name is Guy N. Cognito.',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1257,7 +1271,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"> update_option( 'comment_registration', 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_param( 'post', $this->post_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_param( 'post', self::$post_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 401, $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">@@ -1265,10 +1279,10 @@
</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 test_create_item_invalid_author() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author' => REST_TESTS_IMPOSSIBLY_HIGH_NUMBER,
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'It\'s all over\, people! We don\'t have a prayer!',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1282,12 +1296,12 @@
</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 test_create_item_pull_author_info() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $author = new WP_User( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $author = new WP_User( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
- 'author' => $this->author_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
+ 'author' => self::$author_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'It\'s all over\, people! We don\'t have a prayer!',
</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">@@ -1298,7 +1312,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $result = $response->get_data();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->author_id, $result['author'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::$author_id, $result['author'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'Sea Captain', $result['author_name'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'captain@thefryingdutchman.com', $result['author_email'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'http://thefryingdutchman.com', $result['author_url'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1308,7 +1322,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">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => 'Comic Book Guy',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'cbg@androidsdungeon.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_url' => 'http://androidsdungeon.com',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1323,7 +1337,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 201, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => 'Comic Book Guy',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'cbg@androidsdungeon.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_url' => 'http://androidsdungeon.com',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1341,10 +1355,10 @@
</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"> $post_id = $this->factory->post->create();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'author' => $this->subscriber_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'author' => self::$subscriber_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'author_name' => 'Disco Stu',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_url' => 'http://stusdisco.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => 'stu@stusdisco.com',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1354,7 +1368,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'karma' => 100,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post' => $post_id,
</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 = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $this->approved_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->add_header( 'content-type', 'application/json' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body( wp_json_encode( $params ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1362,7 +1376,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = $response->get_data();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $updated = get_comment( $this->approved_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $updated = get_comment( self::$approved_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['content'], $comment['content']['raw'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['author'], $comment['author'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['author_name'], $comment['author_name'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1377,11 +1391,11 @@
</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 test_update_comment_status() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_id = $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 0,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ));
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1401,11 +1415,11 @@
</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 test_update_comment_field_does_not_use_default_values() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_id = $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 0,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment_content' => 'some content',
</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">@@ -1427,13 +1441,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 function test_update_comment_date_gmt() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</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"> 'date_gmt' => '2015-05-07T10:14:25',
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'I\'ll be deep in the cold, cold ground before I recognize Missouri.',
</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 = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $this->approved_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->add_header( 'content-type', 'application/json' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body( wp_json_encode( $params ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1441,18 +1455,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = $response->get_data();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $updated = get_comment( $this->approved_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $updated = get_comment( self::$approved_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['date_gmt'], $comment['date_gmt'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['date_gmt'], mysql_to_rfc3339( $updated->comment_date_gmt ) );
</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 test_update_comment_invalid_type() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</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"> 'type' => 'trackback',
</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 = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $this->approved_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->add_header( 'content-type', 'application/json' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body( wp_json_encode( $params ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1461,14 +1475,14 @@
</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 test_update_comment_with_raw_property() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</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"> 'content' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'raw' => 'What the heck kind of name is Persephone?',
</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 = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $this->approved_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->add_header( 'content-type', 'application/json' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body( wp_json_encode( $params ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1477,19 +1491,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = $response->get_data();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $updated = get_comment( $this->approved_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $updated = get_comment( self::$approved_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['content']['raw'], $updated->comment_content );
</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 test_update_item_invalid_date() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</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"> 'content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'date' => rand_str(),
</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 = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $this->approved_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->add_header( 'content-type', 'application/json' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body( wp_json_encode( $params ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1498,14 +1512,14 @@
</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 test_update_item_invalid_date_gmt() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</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"> 'content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'date_gmt' => rand_str(),
</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 = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $this->approved_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->add_header( 'content-type', 'application/json' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body( wp_json_encode( $params ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1533,7 +1547,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'Disco Stu likes disco music.',
</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 = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $this->hold_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$hold_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->add_header( 'content-type', 'application/json' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body( wp_json_encode( $params ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1544,11 +1558,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_comment_private_post_invalid_permission() {
</span><span class="cx" style="display: block; padding: 0 10px"> $private_comment_id = $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->private_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$private_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'user_id' => 0,
</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">- wp_set_current_user( $this->subscriber_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$subscriber_id );
</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"> 'content' => 'Disco Stu likes disco music.',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1562,17 +1576,17 @@
</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 test_update_comment_with_children_link() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $comment_id_1 = $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
- 'user_id' => $this->subscriber_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
+ 'user_id' => self::$subscriber_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $child_comment = $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
- 'user_id' => $this->subscriber_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
+ 'user_id' => self::$subscriber_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check if comment 1 does not have the child link.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1596,28 +1610,28 @@
</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 test_delete_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_id = $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
- 'user_id' => $this->subscriber_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
+ 'user_id' => self::$subscriber_id,
</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( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $response->get_data();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $this->post_id, $data['post'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$post_id, $data['post'] );
</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"> public function test_delete_item_skip_trash() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_id = $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
- 'user_id' => $this->subscriber_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
+ 'user_id' => self::$subscriber_id,
</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( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $request['force'] = true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1625,16 +1639,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $response->get_data();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $this->post_id, $data['post'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$post_id, $data['post'] );
</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"> public function test_delete_item_already_trashed() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_id = $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
- 'user_id' => $this->subscriber_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
+ 'user_id' => self::$subscriber_id,
</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( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1645,7 +1659,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"> public function test_delete_comment_invalid_id() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</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( 'DELETE', sprintf( '/wp/v2/comments/%d', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1654,27 +1668,27 @@
</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 test_delete_comment_without_permission() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->subscriber_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$subscriber_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', $this->approved_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_cannot_delete', $response, 403 );
</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 test_delete_child_comment_link() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $comment_id_1 = $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
- 'user_id' => $this->subscriber_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
+ 'user_id' => self::$subscriber_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $child_comment = $this->factory->comment->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved' => 1,
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_parent' => $comment_id_1,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $this->post_id,
- 'user_id' => $this->subscriber_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post_id,
+ 'user_id' => self::$subscriber_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%s', $child_comment ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1747,12 +1761,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $schema, $data['schema']['properties']['my_custom_int'] );
</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 = new WP_REST_Request( 'GET', '/wp/v2/comments/' . $this->approved_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'GET', '/wp/v2/comments/' . self::$approved_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'my_custom_int', $response->data );
</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 = new WP_REST_Request( 'POST', '/wp/v2/comments/' . $this->approved_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', '/wp/v2/comments/' . self::$approved_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params(array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'my_custom_int' => 123,
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'abc',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1760,14 +1774,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( 1 );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->server->dispatch( $request );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( 123, get_comment_meta( $this->approved_id, 'my_custom_int', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( 123, get_comment_meta( self::$approved_id, 'my_custom_int', true ) );
</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/comments' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params(array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'my_custom_int' => 123,
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => 'hello',
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'goodbye',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ));
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1792,10 +1806,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'update_callback' => array( $this, 'additional_field_update_callback' ),
</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">- wp_set_current_user( $this->admin_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$admin_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check for error on update.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/comments/%d', $this->approved_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/comments/%d', self::$approved_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params(array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'my_custom_int' => 'returnError',
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'abc',
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestpagescontrollerphp"></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-pages-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-pages-controller.php 2016-10-27 01:41:08 UTC (rev 38974)
+++ trunk/tests/phpunit/tests/rest-api/rest-pages-controller.php 2016-10-27 02:56:28 UTC (rev 38975)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,17 +11,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group restapi
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Testcase {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $editor_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function setUp() {
- parent::setUp();
-
- $this->editor_id = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( $factory ) {
+ self::$editor_id = $factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'editor',
</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->author_id = $this->factory->user->create( array(
- 'role' => 'author',
- ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ self::delete_user( self::$editor_id );
+ }
+
+ public function setUp() {
+ parent::setUp();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->has_setup_template = false;
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'theme_page_templates', array( $this, 'filter_theme_page_templates' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -183,7 +186,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // But they are accessible to authorized users
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->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->assertCount( 1, $data );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -227,7 +230,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"> public function test_create_item_with_template() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/pages' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -246,7 +249,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $page_id = $this->factory->post->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'page',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/pages' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -267,7 +270,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"> public function test_create_page_with_invalid_parent() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/pages' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -322,7 +325,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => 'page',
</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">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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( 'PUT', sprintf( '/wp/v2/pages/%d', $page_id ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -342,7 +345,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'menu_order' => 1,
</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">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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( 'PUT', sprintf( '/wp/v2/pages/%d', $page_id ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestpostmetafieldsphp"></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-post-meta-fields.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/rest-api/rest-post-meta-fields.php 2016-10-27 01:41:08 UTC (rev 38974)
+++ trunk/tests/phpunit/tests/rest-api/rest-post-meta-fields.php 2016-10-27 02:56:28 UTC (rev 38975)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10,6 +10,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group restapi
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $post_id;
+
+ public static function wpSetUpBeforeClass( $factory ) {
+ self::$post_id = $factory->post->create();
+ }
+
+ public static function wpTearDownAfterClass() {
+ wp_delete_post( self::$post_id, true );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> public function setUp() {
</span><span class="cx" style="display: block; padding: 0 10px"> parent::setUp();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -54,8 +64,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> global $wp_rest_server;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->server = $wp_rest_server = new Spy_REST_Server;
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( 'rest_api_init' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- $this->post_id = $this->factory->post->create();
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> protected function grant_write_permission() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -67,9 +75,9 @@
</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 test_get_value() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_post_meta( $this->post_id, 'test_single', 'testvalue' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_post_meta( self::$post_id, 'test_single', 'testvalue' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -86,8 +94,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @depends test_get_value
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_multi_value() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_post_meta( $this->post_id, 'test_multi', 'value1' );
- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_post_meta( self::$post_id, 'test_multi', 'value1' );
+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -99,7 +107,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertContains( 'value1', $meta['test_multi'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check after an update.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_post_meta( $this->post_id, 'test_multi', 'value2' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_post_meta( self::$post_id, 'test_multi', 'value2' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -113,8 +121,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @depends test_get_value
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_unregistered() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_post_meta( $this->post_id, 'test_unregistered', 'value1' );
- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_post_meta( self::$post_id, 'test_unregistered', 'value1' );
+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -128,8 +136,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @depends test_get_value
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_registered_no_api_access() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_post_meta( $this->post_id, 'test_no_rest', 'for_the_wicked' );
- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_post_meta( self::$post_id, 'test_no_rest', 'for_the_wicked' );
+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -143,8 +151,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @depends test_get_value
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_registered_api_disabled() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_post_meta( $this->post_id, 'test_rest_disabled', 'sleepless_nights' );
- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_post_meta( self::$post_id, 'test_rest_disabled', 'sleepless_nights' );
+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -176,11 +184,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->server = $wp_rest_server = new Spy_REST_Server;
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( 'rest_api_init' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_post_meta( $this->post_id, 'test_string', 42 );
- add_post_meta( $this->post_id, 'test_number', '42' );
- add_post_meta( $this->post_id, 'test_bool', 1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_post_meta( self::$post_id, 'test_string', 42 );
+ add_post_meta( self::$post_id, 'test_number', '42' );
+ add_post_meta( self::$post_id, 'test_bool', 1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $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">@@ -205,7 +213,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_set_value() {
</span><span class="cx" style="display: block; padding: 0 10px"> // Ensure no data exists currently.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $values = get_post_meta( $this->post_id, 'test_single', false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $values = get_post_meta( self::$post_id, 'test_single', false );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEmpty( $values );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->grant_write_permission();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -215,13 +223,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'test_single' => 'test_value',
</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 = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $meta = get_post_meta( $this->post_id, 'test_single', false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $meta = get_post_meta( self::$post_id, 'test_single', false );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( $meta );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $meta );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'test_value', $meta[0] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -237,8 +245,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_set_duplicate_single_value() {
</span><span class="cx" style="display: block; padding: 0 10px"> // Start with an existing metakey and value.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $values = update_post_meta( $this->post_id, 'test_single', 'test_value' );
- $this->assertEquals( 'test_value', get_post_meta( $this->post_id, 'test_single', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $values = update_post_meta( self::$post_id, 'test_single', 'test_value' );
+ $this->assertEquals( 'test_value', get_post_meta( self::$post_id, 'test_single', true ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->grant_write_permission();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -247,13 +255,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'test_single' => 'test_value',
</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 = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $meta = get_post_meta( $this->post_id, 'test_single', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $meta = get_post_meta( self::$post_id, 'test_single', true );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( $meta );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'test_value', $meta );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -275,14 +283,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</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">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_cannot_edit', $response, 401 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check that the value wasn't actually updated.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEmpty( get_post_meta( $this->post_id, 'test_single', false ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEmpty( get_post_meta( self::$post_id, 'test_single', false ) );
</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">@@ -297,12 +305,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->grant_write_permission();
</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 = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_cannot_update', $response, 403 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEmpty( get_post_meta( $this->post_id, 'test_bad_auth', false ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEmpty( get_post_meta( self::$post_id, 'test_bad_auth', false ) );
</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">@@ -317,7 +325,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->grant_write_permission();
</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 = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $data );
</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">@@ -335,7 +343,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_set_value_multiple() {
</span><span class="cx" style="display: block; padding: 0 10px"> // Ensure no data exists currently.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $values = get_post_meta( $this->post_id, 'test_multi', false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $values = get_post_meta( self::$post_id, 'test_multi', false );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEmpty( $values );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->grant_write_permission();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -345,13 +353,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'test_multi' => array( 'val1' ),
</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 = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $meta = get_post_meta( $this->post_id, 'test_multi', false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $meta = get_post_meta( self::$post_id, 'test_multi', false );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( $meta );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $meta );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'val1', $meta[0] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -367,7 +375,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $meta = get_post_meta( $this->post_id, 'test_multi', false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $meta = get_post_meta( self::$post_id, 'test_multi', false );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( $meta );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 2, $meta );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertContains( 'val1', $meta );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -378,9 +386,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Test removing only one item with duplicate items.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_set_value_remove_one() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_post_meta( $this->post_id, 'test_multi', 'c' );
- add_post_meta( $this->post_id, 'test_multi', 'n' );
- add_post_meta( $this->post_id, 'test_multi', 'n' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_post_meta( self::$post_id, 'test_multi', 'c' );
+ add_post_meta( self::$post_id, 'test_multi', 'n' );
+ add_post_meta( self::$post_id, 'test_multi', 'n' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->grant_write_permission();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -389,13 +397,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'test_multi' => array( 'c', 'n' ),
</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 = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $meta = get_post_meta( $this->post_id, 'test_multi', false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $meta = get_post_meta( self::$post_id, 'test_multi', false );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( $meta );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 2, $meta );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertContains( 'c', $meta );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -407,7 +415,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_set_value_multiple_unauthenticated() {
</span><span class="cx" style="display: block; padding: 0 10px"> // Ensure no data exists currently.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $values = get_post_meta( $this->post_id, 'test_multi', false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $values = get_post_meta( self::$post_id, 'test_multi', false );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEmpty( $values );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( 0 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -417,13 +425,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'test_multi' => array( 'val1' ),
</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 = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_cannot_edit', $response, 401 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $meta = get_post_meta( $this->post_id, 'test_multi', false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $meta = get_post_meta( self::$post_id, 'test_multi', false );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEmpty( $meta );
</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">@@ -439,17 +447,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->grant_write_permission();
</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 = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_cannot_update', $response, 403 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEmpty( get_post_meta( $this->post_id, 'test_bad_auth_multi', false ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEmpty( get_post_meta( self::$post_id, 'test_bad_auth_multi', false ) );
</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"> public function test_add_multi_value_db_error() {
</span><span class="cx" style="display: block; padding: 0 10px"> // Ensure no data exists currently.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $values = get_post_meta( $this->post_id, 'test_multi', false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $values = get_post_meta( self::$post_id, 'test_multi', false );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEmpty( $values );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->grant_write_permission();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -459,7 +467,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'test_multi' => array( 'val1' ),
</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 = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $data );
</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">@@ -478,8 +486,8 @@
</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 test_remove_multi_value_db_error() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_post_meta( $this->post_id, 'test_multi', 'val1' );
- $values = get_post_meta( $this->post_id, 'test_multi', false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_post_meta( self::$post_id, 'test_multi', 'val1' );
+ $values = get_post_meta( self::$post_id, 'test_multi', false );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'val1' ), $values );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->grant_write_permission();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -489,7 +497,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'test_multi' => array(),
</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 = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $data );
</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">@@ -508,8 +516,8 @@
</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 test_delete_value() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_post_meta( $this->post_id, 'test_single', 'val1' );
- $current = get_post_meta( $this->post_id, 'test_single', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_post_meta( self::$post_id, 'test_single', 'val1' );
+ $current = get_post_meta( self::$post_id, 'test_single', true );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'val1', $current );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->grant_write_permission();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -519,13 +527,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'test_single' => null,
</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 = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $meta = get_post_meta( $this->post_id, 'test_single', false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $meta = get_post_meta( self::$post_id, 'test_single', false );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEmpty( $meta );
</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">@@ -533,8 +541,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @depends test_delete_value
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_delete_value_blocked() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_post_meta( $this->post_id, 'test_bad_auth', 'val1' );
- $current = get_post_meta( $this->post_id, 'test_bad_auth', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_post_meta( self::$post_id, 'test_bad_auth', 'val1' );
+ $current = get_post_meta( self::$post_id, 'test_bad_auth', true );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'val1', $current );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->grant_write_permission();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -544,13 +552,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'test_bad_auth' => null,
</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 = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_cannot_delete', $response, 403 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $meta = get_post_meta( $this->post_id, 'test_bad_auth', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $meta = get_post_meta( self::$post_id, 'test_bad_auth', true );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'val1', $meta );
</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">@@ -558,8 +566,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @depends test_delete_value
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_delete_value_db_error() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_post_meta( $this->post_id, 'test_single', 'val1' );
- $current = get_post_meta( $this->post_id, 'test_single', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_post_meta( self::$post_id, 'test_single', 'val1' );
+ $current = get_post_meta( self::$post_id, 'test_single', true );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'val1', $current );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->grant_write_permission();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -569,7 +577,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'test_single' => null,
</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 = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $data );
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Disable showing error as the below is going to intentionally
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -587,7 +595,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"> public function test_get_schema() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'OPTIONS', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'OPTIONS', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $response->get_data();
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestpostscontrollerphp"></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-posts-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-posts-controller.php 2016-10-27 01:41:08 UTC (rev 38974)
+++ trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php 2016-10-27 02:56:28 UTC (rev 38975)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10,22 +10,36 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group restapi
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Testcase {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $post_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function setUp() {
- parent::setUp();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $editor_id;
+ protected static $author_id;
+ protected static $contributor_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->post_id = $this->factory->post->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( $factory ) {
+ self::$post_id = $factory->post->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->editor_id = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$editor_id = $factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'editor',
</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->author_id = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$author_id = $factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'author',
</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->contributor_id = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$contributor_id = $factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'contributor',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ wp_delete_post( self::$post_id, true );
+
+ self::delete_user( self::$editor_id );
+ self::delete_user( self::$author_id );
+ self::delete_user( self::$contributor_id );
+ }
+
+ public function setUp() {
+ parent::setUp();
</ins><span class="cx" style="display: block; padding: 0 10px"> register_post_type( 'youseeme', array( 'supports' => array(), 'show_in_rest' => true ) );
</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">@@ -46,7 +60,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
</span><span class="cx" style="display: block; padding: 0 10px"> // Single
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . $this->post_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . self::$post_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->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->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -105,8 +119,8 @@
</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 test_get_items_author_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->factory->post->create( array( 'post_author' => $this->editor_id ) );
- $this->factory->post->create( array( 'post_author' => $this->author_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->factory->post->create( array( 'post_author' => self::$editor_id ) );
+ $this->factory->post->create( array( 'post_author' => self::$author_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> // All 3 posts
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -114,25 +128,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 3, count( $response->get_data() ) );
</span><span class="cx" style="display: block; padding: 0 10px"> // 2 of 3 posts
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_param( 'author', array( $this->editor_id, $this->author_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_param( 'author', array( self::$editor_id, self::$author_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</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->assertEquals( 2, count( $data ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEqualSets( array( $this->editor_id, $this->author_id ), wp_list_pluck( $data, 'author' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualSets( array( self::$editor_id, self::$author_id ), wp_list_pluck( $data, 'author' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> // 1 of 3 posts
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_param( 'author', $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_param( 'author', self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</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->assertEquals( 1, count( $data ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $this->editor_id, $data[0]['author'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$editor_id, $data[0]['author'] );
</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"> public function test_get_items_author_exclude_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->factory->post->create( array( 'post_author' => $this->editor_id ) );
- $this->factory->post->create( array( 'post_author' => $this->author_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->factory->post->create( array( 'post_author' => self::$editor_id ) );
+ $this->factory->post->create( array( 'post_author' => self::$author_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> // All 3 posts
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -140,22 +154,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 3, count( $response->get_data() ) );
</span><span class="cx" style="display: block; padding: 0 10px"> // 1 of 3 posts
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_param( 'author_exclude', array( $this->editor_id, $this->author_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_param( 'author_exclude', array( self::$editor_id, self::$author_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</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->assertEquals( 1, count( $data ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotEquals( $this->editor_id, $data[0]['author'] );
- $this->assertNotEquals( $this->author_id, $data[0]['author'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotEquals( self::$editor_id, $data[0]['author'] );
+ $this->assertNotEquals( self::$author_id, $data[0]['author'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> // 2 of 3 posts
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request->set_param( 'author_exclude', $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request->set_param( 'author_exclude', self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</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->assertEquals( 2, count( $data ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNotEquals( $this->editor_id, $data[0]['author'] );
- $this->assertNotEquals( $this->editor_id, $data[1]['author'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertNotEquals( self::$editor_id, $data[0]['author'] );
+ $this->assertNotEquals( self::$editor_id, $data[1]['author'] );
</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"> public function test_get_items_include_query() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -232,7 +246,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'status', 'draft' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'status', 'draft' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -305,18 +319,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $response->get_data();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( array( $this->post_id, $post_id3, $post_id2, $post_id1 ), wp_list_pluck( $data, 'id' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( array( self::$post_id, $post_id3, $post_id2, $post_id1 ), wp_list_pluck( $data, 'id' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Permit stickies
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'ignore_sticky_posts', false );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $response->get_data();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( array( $post_id2, $this->post_id, $post_id3, $post_id1 ), wp_list_pluck( $data, 'id' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( array( $post_id2, self::$post_id, $post_id3, $post_id1 ), wp_list_pluck( $data, 'id' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_items_offset_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id1 = $this->post_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $id1 = self::$post_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $id4 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -335,7 +349,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"> public function test_get_items_tags_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id1 = $this->post_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $id1 = self::$post_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $id4 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -352,7 +366,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"> public function test_get_items_tags_exclude_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id1 = $this->post_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $id1 = self::$post_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $id4 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -371,7 +385,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"> public function test_get_items_tags_and_categories_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id1 = $this->post_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $id1 = self::$post_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $id4 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -391,7 +405,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"> public function test_get_items_tags_and_categories_exclude_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id1 = $this->post_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $id1 = self::$post_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $id4 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -413,7 +427,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"> public function test_get_items_sticky_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id1 = $this->post_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $id1 = self::$post_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'sticky_posts', array( $id2 ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -430,7 +444,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"> public function test_get_items_sticky_with_post__in_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id1 = $this->post_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $id1 = self::$post_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -459,7 +473,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"> public function test_get_items_not_sticky_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id1 = $this->post_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $id1 = self::$post_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'sticky_posts', array( $id2 ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -476,7 +490,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"> public function test_get_items_sticky_with_post__not_in_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id1 = $this->post_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $id1 = self::$post_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $id3 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -586,7 +600,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // But they are accessible to authorized users
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->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->assertCount( 1, $data );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -630,31 +644,31 @@
</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 test_get_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->check_get_post_response( $response, 'view' );
</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 test_get_item_links() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $links = $response->get_links();
</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->assertEquals( rest_url( '/wp/v2/posts/' . $this->post_id ), $links['self'][0]['href'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( rest_url( '/wp/v2/posts/' . self::$post_id ), $links['self'][0]['href'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( rest_url( '/wp/v2/posts' ), $links['collection'][0]['href'] );
</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->assertEquals( rest_url( '/wp/v2/types/' . get_post_type( $this->post_id ) ), $links['about'][0]['href'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( rest_url( '/wp/v2/types/' . get_post_type( self::$post_id ) ), $links['about'][0]['href'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $replies_url = rest_url( '/wp/v2/comments' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $replies_url = add_query_arg( 'post', $this->post_id, $replies_url );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $replies_url = add_query_arg( 'post', self::$post_id, $replies_url );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $replies_url, $links['replies'][0]['href'] );
</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->assertEquals( rest_url( '/wp/v2/posts/' . $this->post_id . '/revisions' ), $links['version-history'][0]['href'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions' ), $links['version-history'][0]['href'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $attachments_url = rest_url( '/wp/v2/media' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $attachments_url = add_query_arg( 'parent', $this->post_id, $attachments_url );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $attachments_url = add_query_arg( 'parent', self::$post_id, $attachments_url );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $attachments_url, $links['https://api.w.org/attachment'][0]['href'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $term_links = $links['https://api.w.org/term'];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -672,23 +686,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( $cat_link );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( $format_link );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tags_url = add_query_arg( 'post', $this->post_id, rest_url( '/wp/v2/tags' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $tags_url = add_query_arg( 'post', self::$post_id, rest_url( '/wp/v2/tags' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $tags_url, $tag_link['href'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $category_url = add_query_arg( 'post', $this->post_id, rest_url( '/wp/v2/categories' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $category_url = add_query_arg( 'post', self::$post_id, rest_url( '/wp/v2/categories' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $category_url, $cat_link['href'] );
</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 test_get_item_links_no_author() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $links = $response->get_links();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( isset( $links['author'] ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_post( array( 'ID' => $this->post_id, 'post_author' => $this->author_id ) );
- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_post( array( 'ID' => self::$post_id, 'post_author' => self::$author_id ) );
+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $links = $response->get_links();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( rest_url( '/wp/v2/users/' . $this->author_id ), $links['author'][0]['href'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( rest_url( '/wp/v2/users/' . self::$author_id ), $links['author'][0]['href'] );
</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"> public function test_get_post_without_permission() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -716,7 +730,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => 'edit',
</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">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -736,7 +750,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_post_context_without_permission() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( 0 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_query_params( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => 'edit',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -811,21 +825,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> register_post_status( 'testpubstatus', array( 'public' => true ) );
</span><span class="cx" style="display: block; padding: 0 10px"> register_post_status( 'testprivtatus', array( 'public' => false ) );
</span><span class="cx" style="display: block; padding: 0 10px"> // Public status
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_post( array( 'ID' => $this->post_id, 'post_status' => 'testpubstatus' ) );
- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_post( array( 'ID' => self::$post_id, 'post_status' => 'testpubstatus' ) );
+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px"> // Private status
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_post( array( 'ID' => $this->post_id, 'post_status' => 'testprivtatus' ) );
- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_post( array( 'ID' => self::$post_id, 'post_status' => 'testprivtatus' ) );
+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 403, $response->get_status() );
</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 test_prepare_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_query_params( array( 'context' => 'edit' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -833,7 +847,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"> public function test_create_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -845,7 +859,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"> public function test_rest_create_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->add_header( 'content-type', 'application/json' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -857,7 +871,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"> public function test_create_post_invalid_id() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -870,7 +884,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"> public function test_create_post_as_contributor() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->contributor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$contributor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data(array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -883,7 +897,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"> public function test_create_post_sticky() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -899,7 +913,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"> public function test_create_post_sticky_as_contributor() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->contributor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$contributor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -913,11 +927,11 @@
</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 test_create_post_other_author_without_permission() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data(array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'author' => $this->editor_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'author' => self::$editor_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ));
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $params );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -939,7 +953,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"> public function test_create_post_draft() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -958,7 +972,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"> public function test_create_post_private() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -974,7 +988,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"> public function test_create_post_private_without_permission() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $user = wp_get_current_user();
</span><span class="cx" style="display: block; padding: 0 10px"> $user->add_cap( 'publish_posts', false );
</span><span class="cx" style="display: block; padding: 0 10px"> // Flush capabilities, https://core.trac.wordpress.org/ticket/28374
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -984,7 +998,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'status' => 'private',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'author' => $this->author_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'author' => self::$author_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $params );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -993,7 +1007,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"> public function test_create_post_publish_without_permission() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $user = wp_get_current_user();
</span><span class="cx" style="display: block; padding: 0 10px"> $user->add_cap( 'publish_posts', false );
</span><span class="cx" style="display: block; padding: 0 10px"> // Flush capabilities, https://core.trac.wordpress.org/ticket/28374
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1011,7 +1025,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"> public function test_create_post_invalid_status() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1024,7 +1038,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"> public function test_create_post_with_format() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1040,7 +1054,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"> public function test_create_post_with_invalid_format() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1060,7 +1074,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'menu_order' => rand( 1, 100 ),
</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">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1085,7 +1099,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"> public function test_create_post_invalid_author() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1098,11 +1112,11 @@
</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 test_create_post_invalid_author_without_permission() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'author' => $this->editor_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'author' => self::$editor_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $params );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1111,7 +1125,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"> public function test_create_post_with_password() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1125,7 +1139,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"> public function test_create_post_with_falsy_password() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1140,7 +1154,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"> public function test_create_post_with_empty_string_password_and_sticky() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1156,7 +1170,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"> public function test_create_post_with_password_and_sticky_fails() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1170,7 +1184,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"> public function test_create_post_custom_date() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1187,7 +1201,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"> public function test_create_post_custom_date_with_timezone() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1208,7 +1222,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"> public function test_create_post_with_db_error() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1230,7 +1244,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"> public function test_create_post_with_invalid_date() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1243,7 +1257,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"> public function test_create_post_with_invalid_date_gmt() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1256,7 +1270,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"> public function test_create_post_with_quotes_in_title() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1269,7 +1283,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"> public function test_create_post_with_categories() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $category = wp_insert_term( 'Test Category', 'category' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1286,7 +1300,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"> public function test_create_post_with_invalid_categories() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'POST', '/wp/v2/posts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'password' => 'testing',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1302,9 +1316,9 @@
</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 test_update_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data();
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $params );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1312,20 +1326,20 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->check_update_post_response( $response );
</span><span class="cx" style="display: block; padding: 0 10px"> $new_data = $response->get_data();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $this->post_id, $new_data['id'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$post_id, $new_data['id'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['title'], $new_data['title']['raw'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['content'], $new_data['content']['raw'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['excerpt'], $new_data['excerpt']['raw'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = get_post( $this->post_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( self::$post_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['title'], $post->post_title );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['content'], $post->post_content );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['excerpt'], $post->post_excerpt );
</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 test_rest_update_post() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->add_header( 'content-type', 'application/json' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data();
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body( wp_json_encode( $params ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1333,20 +1347,20 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->check_update_post_response( $response );
</span><span class="cx" style="display: block; padding: 0 10px"> $new_data = $response->get_data();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $this->post_id, $new_data['id'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$post_id, $new_data['id'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['title'], $new_data['title']['raw'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['content'], $new_data['content']['raw'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['excerpt'], $new_data['excerpt']['raw'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = get_post( $this->post_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( self::$post_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['title'], $post->post_title );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['content'], $post->post_content );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['excerpt'], $post->post_excerpt );
</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 test_rest_update_post_raw() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->add_header( 'content-type', 'application/json' );
</span><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_raw_post_data();
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body( wp_json_encode( $params ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1354,20 +1368,20 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->check_update_post_response( $response );
</span><span class="cx" style="display: block; padding: 0 10px"> $new_data = $response->get_data();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $this->post_id, $new_data['id'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$post_id, $new_data['id'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['title']['raw'], $new_data['title']['raw'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['content']['raw'], $new_data['content']['raw'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['excerpt']['raw'], $new_data['excerpt']['raw'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = get_post( $this->post_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( self::$post_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['title']['raw'], $post->post_title );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['content']['raw'], $post->post_content );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $params['excerpt']['raw'], $post->post_excerpt );
</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 test_update_post_without_extra_params() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data();
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $params['type'] );
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $params['name'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1380,14 +1394,14 @@
</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 test_update_post_without_permission() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $user = wp_get_current_user();
</span><span class="cx" style="display: block; padding: 0 10px"> $user->add_cap( 'edit_published_posts', false );
</span><span class="cx" style="display: block; padding: 0 10px"> // Flush capabilities, https://core.trac.wordpress.org/ticket/28374
</span><span class="cx" style="display: block; padding: 0 10px"> $user->get_role_caps();
</span><span class="cx" style="display: block; padding: 0 10px"> $user->update_user_level_from_caps();
</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 = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data();
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $params );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1396,9 +1410,9 @@
</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 test_update_post_sticky_as_contributor() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->contributor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$contributor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'sticky' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> 'status' => 'pending',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1410,7 +1424,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"> public function test_update_post_invalid_id() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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( 'PUT', sprintf( '/wp/v2/posts/%d', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1419,18 +1433,18 @@
</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 test_update_post_invalid_route() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/pages/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/pages/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_post_invalid_id', $response, 404 );
</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 test_update_post_with_format() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'format' => 'gallery',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1444,9 +1458,9 @@
</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 test_update_post_with_invalid_format() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'format' => 'testformat',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1457,12 +1471,12 @@
</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 test_update_post_ignore_readonly() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $new_content = rand_str();
</span><span class="cx" style="display: block; padding: 0 10px"> $expected_modified = current_time( 'mysql' );
</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 = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'modified' => '2010-06-01T02:00:00Z',
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => $new_content,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1483,9 +1497,9 @@
</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 test_update_post_with_invalid_date() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'date' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1496,9 +1510,9 @@
</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 test_update_post_with_invalid_date_gmt() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'date_gmt' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1509,9 +1523,9 @@
</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 test_update_post_slug() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'slug' => 'sample-slug',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1525,9 +1539,9 @@
</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 test_update_post_slug_accented_chars() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'slug' => 'tęst-acceńted-chäræcters',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1541,9 +1555,9 @@
</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 test_update_post_sticky() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'sticky' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1556,7 +1570,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( true, is_sticky( $post->ID ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Updating another field shouldn't change sticky status
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => 'This should not reset sticky',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1570,9 +1584,9 @@
</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 test_update_post_excerpt() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'excerpt' => 'An Excerpt',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1583,9 +1597,9 @@
</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 test_update_post_empty_excerpt() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'excerpt' => '',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1596,9 +1610,9 @@
</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 test_update_post_content() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => 'Some Content',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1609,9 +1623,9 @@
</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 test_update_post_empty_content() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'content' => '',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1622,9 +1636,9 @@
</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 test_update_post_with_password_and_sticky_fails() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'password' => '123',
</span><span class="cx" style="display: block; padding: 0 10px"> 'sticky' => true,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1636,11 +1650,11 @@
</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 test_update_stick_post_with_password_fails() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- stick_post( $this->post_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ stick_post( self::$post_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'password' => '123',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1651,11 +1665,11 @@
</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 test_update_password_protected_post_with_sticky_fails() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_update_post( array( 'ID' => $this->post_id, 'post_password' => '123' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_post( array( 'ID' => self::$post_id, 'post_password' => '123' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'sticky' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1666,9 +1680,9 @@
</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 test_update_post_with_quotes_in_title() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => "Rob O'Rourke's Diary",
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1680,10 +1694,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_post_with_categories() {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $category = wp_insert_term( 'Test Category', 'category' );
</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 = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => 'Tester',
</span><span class="cx" style="display: block; padding: 0 10px"> 'categories' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1714,11 +1728,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_post_with_empty_categories() {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $category = wp_insert_term( 'Test Category', 'category' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_object_terms( $this->post_id, $category['term_id'], 'category' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_object_terms( self::$post_id, $category['term_id'], 'category' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $params = $this->set_post_data( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => 'Tester',
</span><span class="cx" style="display: block; padding: 0 10px"> 'categories' => array(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1731,7 +1745,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</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"> $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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( 'DELETE', sprintf( '/wp/v2/posts/%d', $post_id ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1744,7 +1758,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_delete_item_skip_trash() {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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( 'DELETE', sprintf( '/wp/v2/posts/%d', $post_id ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $request['force'] = true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1758,7 +1772,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_delete_item_already_trashed() {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = $this->factory->post->create( array( 'post_title' => 'Deleted post' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d', $post_id ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1767,7 +1781,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"> public function test_delete_post_invalid_id() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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( 'DELETE', '/wp/v2/posts/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1777,7 +1791,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_delete_post_invalid_post_type() {
</span><span class="cx" style="display: block; padding: 0 10px"> $page_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</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( 'DELETE', '/wp/v2/posts/' . $page_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1786,9 +1800,9 @@
</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 test_delete_post_without_permission() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_cannot_delete', $response, 403 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1905,9 +1919,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'update_callback' => array( $this, 'additional_field_update_callback' ),
</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">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> // Check for error on update.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'my_custom_int' => 'returnError',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestrevisionscontrollerphp"></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-revisions-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-revisions-controller.php 2016-10-27 01:41:08 UTC (rev 38974)
+++ trunk/tests/phpunit/tests/rest-api/rest-revisions-controller.php 2016-10-27 02:56:28 UTC (rev 38975)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10,22 +10,40 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group restapi
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_Test_REST_Revisions_Controller extends WP_Test_REST_Controller_Testcase {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $post_id;
+ protected static $page_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function setUp() {
- parent::setUp();
- $this->post_id = $this->factory->post->create();
- $this->page_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $editor_id;
+ protected static $contributor_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->editor_id = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( $factory ) {
+ self::$post_id = $factory->post->create();
+ self::$page_id = $factory->post->create( array( 'post_type' => 'page' ) );
+
+ self::$editor_id = $factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'editor',
</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->contributor_id = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$contributor_id = $factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'contributor',
</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">- wp_update_post( array( 'post_content' => 'This content is better.', 'ID' => $this->post_id ) );
- wp_update_post( array( 'post_content' => 'This content is marvelous.', 'ID' => $this->post_id ) );
- $revisions = wp_get_post_revisions( $this->post_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_update_post( array( 'post_content' => 'This content is better.', 'ID' => self::$post_id ) );
+ wp_update_post( array( 'post_content' => 'This content is marvelous.', 'ID' => self::$post_id ) );
+ }
+
+ public static function wpTearDownAfterClass() {
+ // Also deletes revisions.
+ wp_delete_post( self::$post_id, true );
+ wp_delete_post( self::$page_id, true );
+
+ self::delete_user( self::$editor_id );
+ self::delete_user( self::$contributor_id );
+ }
+
+ public function setUp() {
+ parent::setUp();
+
+ $revisions = wp_get_post_revisions( self::$post_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->revision_1 = array_pop( $revisions );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->revision_id1 = $this->revision_1->ID;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->revision_2 = array_pop( $revisions );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -42,13 +60,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_context_param() {
</span><span class="cx" style="display: block; padding: 0 10px"> // Collection
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . $this->post_id . '/revisions' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . self::$post_id . '/revisions' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->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->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] );
</span><span class="cx" style="display: block; padding: 0 10px"> // Single
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . $this->post_id . '/revisions/' . $this->revision_1->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . self::$post_id . '/revisions/' . $this->revision_1->ID );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->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->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -56,8 +74,8 @@
</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 test_get_items() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
- $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $this->post_id . '/revisions' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
+ $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->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->assertEquals( 200, $response->get_status() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -73,32 +91,32 @@
</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_no_permission() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( 0 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $this->post_id . '/revisions' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_cannot_read', $response, 401 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->contributor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$contributor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_cannot_read', $response, 403 );
</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 test_get_items_missing_parent() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER . '/revisions' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_post_invalid_parent', $response, 404 );
</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 test_get_items_invalid_parent_post_type() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
- $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $this->page_id . '/revisions' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
+ $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$page_id . '/revisions' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_post_invalid_parent', $response, 404 );
</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 test_get_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
- $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $this->post_id . '/revisions/' . $this->revision_id1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
+ $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions/' . $this->revision_id1 );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->check_get_revision_response( $response, $this->revision_1 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -121,8 +139,8 @@
</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 test_get_item_embed_context() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
- $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $this->post_id . '/revisions/' . $this->revision_id1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
+ $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions/' . $this->revision_id1 );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'context', 'embed' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $fields = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -140,54 +158,54 @@
</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_no_permission() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( 0 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $this->post_id . '/revisions/' . $this->revision_id1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions/' . $this->revision_id1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_cannot_read', $response, 401 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->contributor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$contributor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_cannot_read', $response, 403 );
</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 test_get_item_missing_parent() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER . '/revisions/' . $this->revision_id1 );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_post_invalid_parent', $response, 404 );
</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 test_get_item_invalid_parent_post_type() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
- $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $this->page_id . '/revisions/' . $this->revision_id1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
+ $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$page_id . '/revisions/' . $this->revision_id1 );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_post_invalid_parent', $response, 404 );
</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 test_delete_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
- $request = new WP_REST_Request( 'DELETE', '/wp/v2/posts/' . $this->post_id . '/revisions/' . $this->revision_id1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
+ $request = new WP_REST_Request( 'DELETE', '/wp/v2/posts/' . self::$post_id . '/revisions/' . $this->revision_id1 );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( get_post( $this->revision_id1 ) );
</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 test_delete_item_no_permission() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->contributor_id );
- $request = new WP_REST_Request( 'DELETE', '/wp/v2/posts/' . $this->post_id . '/revisions/' . $this->revision_id1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$contributor_id );
+ $request = new WP_REST_Request( 'DELETE', '/wp/v2/posts/' . self::$post_id . '/revisions/' . $this->revision_id1 );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_cannot_read', $response, 403 );
</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 test_prepare_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor_id );
- $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $this->post_id . '/revisions/' . $this->revision_id1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
+ $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions/' . $this->revision_id1 );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 200, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->check_get_revision_response( $response, $this->revision_1 );
</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 test_get_item_schema() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . $this->post_id . '/revisions' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . self::$post_id . '/revisions' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->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"> $properties = $data['schema']['properties'];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -207,13 +225,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 function test_create_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'POST', '/wp/v2/posts/' . $this->post_id . '/revisions' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', '/wp/v2/posts/' . self::$post_id . '/revisions' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_no_route', $response, 404 );
</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 test_update_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'POST', '/wp/v2/posts/' . $this->post_id . '/revisions/' . $this->revision_id1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', '/wp/v2/posts/' . self::$post_id . '/revisions/' . $this->revision_id1 );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_no_route', $response, 404 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -233,7 +251,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'update_callback' => array( $this, 'additional_field_update_callback' ),
</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 = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . $this->post_id . '/revisions' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . self::$post_id . '/revisions' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</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">@@ -243,7 +261,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( 1 );
</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 = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $this->post_id . '/revisions/' . $this->revision_id1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions/' . $this->revision_id1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'my_custom_int', $response->data );
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestsettingscontrollerphp"></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-settings-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-settings-controller.php 2016-10-27 01:41:08 UTC (rev 38974)
+++ trunk/tests/phpunit/tests/rest-api/rest-settings-controller.php 2016-10-27 02:56:28 UTC (rev 38975)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10,12 +10,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group restapi
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $administrator;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( $factory ) {
+ self::$administrator = $factory->user->create( array(
+ 'role' => 'administrator',
+ ) );
+ }
+
+ public static function wpTearDownAfterClass() {
+ self::delete_user( self::$administrator );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> public function setUp() {
</span><span class="cx" style="display: block; padding: 0 10px"> parent::setUp();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->administrator = $this->factory->user->create( array(
- 'role' => 'administrator',
- ) );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->endpoint = new WP_REST_Settings_Controller();
</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">@@ -37,7 +45,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"> public function test_get_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/settings' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</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">@@ -63,7 +71,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"> public function test_get_item_value_is_cast_to_type() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> update_option( 'posts_per_page', 'invalid_number' ); // this is cast to (int) 1
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/settings' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -74,7 +82,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"> public function test_get_item_with_custom_setting() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> register_setting( 'somegroup', 'mycustomsetting', array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'show_in_rest' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -114,7 +122,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"> public function test_get_item_with_filter() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'rest_pre_get_setting', array( $this, 'get_setting_custom_callback' ), 10, 3 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -155,7 +163,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"> public function test_update_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'PUT', '/wp/v2/settings' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'title', 'The new title!' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -176,7 +184,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"> public function test_update_item_with_filter() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</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( 'PUT', '/wp/v2/settings' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'title', 'The old title!' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -207,7 +215,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"> public function test_update_item_with_invalid_type() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'PUT', '/wp/v2/settings' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'title', array( 'rendered' => 'This should fail.' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -220,7 +228,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_item_with_null() {
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'posts_per_page', 9 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'PUT', '/wp/v2/settings' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'posts_per_page', null );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -233,7 +241,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_item_with_invalid_enum() {
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'posts_per_page', 9 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->administrator );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$administrator );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'PUT', '/wp/v2/settings' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'default_ping_status', 'open&closed' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestuserscontrollerphp"></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-users-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-users-controller.php 2016-10-27 01:41:08 UTC (rev 38974)
+++ trunk/tests/phpunit/tests/rest-api/rest-users-controller.php 2016-10-27 02:56:28 UTC (rev 38975)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10,21 +10,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group restapi
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * This function is run before each method
- */
- public function setUp() {
- parent::setUp();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $user;
+ protected static $editor;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->user = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( $factory ) {
+ self::$user = $factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'administrator',
</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->editor = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$editor = $factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'editor',
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_email' => 'editor@example.com',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ self::delete_user( self::$user );
+ self::delete_user( self::$editor );
+ }
+
+ /**
+ * This function is run before each method
+ */
+ public function setUp() {
+ parent::setUp();
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->endpoint = new WP_REST_Users_Controller();
</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">@@ -46,7 +54,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
</span><span class="cx" style="display: block; padding: 0 10px"> // Single
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users/' . $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users/' . self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->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->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -75,7 +83,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"> public function test_get_items() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</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/users' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'context', 'view' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -90,7 +98,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"> public function test_get_items_with_edit_context() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</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/users' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'context', 'edit' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -113,7 +121,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 401, $response->get_status() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> //test with a user logged in but without sufficient capabilities; capability in question: 'list_users'
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'context', 'edit' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -127,8 +135,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array(), $response->get_data() );
</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->factory->post->create( array( 'post_author' => $this->editor ) );
- $this->factory->post->create( array( 'post_author' => $this->user, 'post_status' => 'draft' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->factory->post->create( array( 'post_author' => self::$editor ) );
+ $this->factory->post->create( array( 'post_author' => self::$user, 'post_status' => 'draft' ) );
</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/users' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -148,7 +156,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group test
</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_pagination_headers() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> // Start of the index, including the three existing users
</span><span class="cx" style="display: block; padding: 0 10px"> for ( $i = 0; $i < 47; $i++ ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->user->create( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -210,7 +218,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"> public function test_get_items_per_page() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> for ( $i = 0; $i < 20; $i++ ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->user->create( array( 'display_name' => "User {$i}" ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -224,7 +232,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"> public function test_get_items_page() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> for ( $i = 0; $i < 20; $i++ ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->user->create( array( 'display_name' => "User {$i}" ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -242,7 +250,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"> public function test_get_items_orderby_name() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> $low_id = $this->factory->user->create( array( 'display_name' => 'AAAAA' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $mid_id = $this->factory->user->create( array( 'display_name' => 'NNNNN' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $high_id = $this->factory->user->create( array( 'display_name' => 'ZZZZ' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -263,7 +271,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"> public function test_get_items_orderby_url() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $low_id = $this->factory->user->create( array( 'user_url' => 'http://a.com' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $high_id = $this->factory->user->create( array( 'user_url' => 'http://b.com' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -289,7 +297,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"> public function test_get_items_orderby_slug() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $high_id = $this->factory->user->create( array( 'user_nicename' => 'blogin' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $low_id = $this->factory->user->create( array( 'user_nicename' => 'alogin' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -315,7 +323,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"> public function test_get_items_orderby_email() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $high_id = $this->factory->user->create( array( 'user_email' => 'bemail@gmail.com' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $low_id = $this->factory->user->create( array( 'user_email' => 'aemail@gmail.com' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -356,7 +364,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"> public function test_get_items_offset() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> // 2 users created in __construct(), plus default user
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->user->create();
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -374,7 +382,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"> public function test_get_items_include_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> $id1 = $this->factory->user->create();
</span><span class="cx" style="display: block; padding: 0 10px"> $id2 = $this->factory->user->create();
</span><span class="cx" style="display: block; padding: 0 10px"> $id3 = $this->factory->user->create();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -400,7 +408,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"> public function test_get_items_exclude_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> $id1 = $this->factory->user->create();
</span><span class="cx" style="display: block; padding: 0 10px"> $id2 = $this->factory->user->create();
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -416,7 +424,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"> public function test_get_items_search() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'search', 'yololololo' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -440,7 +448,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"> public function test_get_items_slug_query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->factory->user->create( array( 'display_name' => 'foo', 'user_login' => 'bar' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $id2 = $this->factory->user->create( array( 'display_name' => 'Moo', 'user_login' => 'foo' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -453,7 +461,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Note: Do not test using editor role as there is an editor role created in testing and it makes it hard to test this functionality.
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_items_roles() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> $tango = $this->factory->user->create( array( 'display_name' => 'tango', 'role' => 'subscriber' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $yolo = $this->factory->user->create( array( 'display_name' => 'yolo', 'role' => 'author' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -472,14 +480,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'roles', 'author' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_user_cannot_view', $response, 401 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'roles', 'author' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_user_cannot_view', $response, 403 );
</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 test_get_items_invalid_roles() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> $lolz = $this->factory->user->create( array( 'display_name' => 'lolz', 'role' => 'author' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/users' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'roles', 'ilovesteak,author' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -497,7 +505,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"> $user_id = $this->factory->user->create();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</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', sprintf( '/wp/v2/users/%d', $user_id ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -506,7 +514,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"> public function test_prepare_item() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request;
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'context', 'edit' );
</span><span class="cx" style="display: block; padding: 0 10px"> $user = get_user_by( 'id', get_current_user_id() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -515,9 +523,9 @@
</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 test_get_user_avatar_urls() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', $this->editor ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$editor ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -526,7 +534,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 48, $data['avatar_urls'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 96, $data['avatar_urls'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = get_user_by( 'id', $this->editor );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = get_user_by( 'id', self::$editor );
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Ignore the subdomain, since 'get_avatar_url randomly sets the Gravatar
</span><span class="cx" style="display: block; padding: 0 10px"> * server when building the url string.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -535,7 +543,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"> public function test_get_user_invalid_id() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/users/100' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -543,7 +551,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"> public function test_get_user_empty_capabilities() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $lolz = $this->factory->user->create( array( 'display_name' => 'lolz', 'roles' => '' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -559,9 +567,9 @@
</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 test_get_item_without_permission() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', $this->user ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$user ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_user_cannot_view', $response, 403 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -622,7 +630,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"> public function test_get_current_user() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</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/users/me' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -631,7 +639,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $headers = $response->get_headers();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'Location', $headers );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( rest_url( 'wp/v2/users/' . $this->user ), $headers['Location'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( rest_url( 'wp/v2/users/' . self::$user ), $headers['Location'] );
</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"> public function test_get_current_user_without_permission() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -644,7 +652,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_create_item() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</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"> 'username' => 'testuser',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -670,7 +678,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_json_create_user() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</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"> 'username' => 'testjsonuser',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -687,7 +695,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"> public function test_create_user_without_permission() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor );
</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"> 'username' => 'homersimpson',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -705,7 +713,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_create_user_invalid_id() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</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"> 'id' => '156',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -724,7 +732,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_create_user_invalid_email() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</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"> 'username' => 'lisasimpson',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -742,7 +750,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_create_user_invalid_role() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</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"> 'username' => 'maggiesimpson',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -768,7 +776,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_url' => 'http://apple.com',
</span><span class="cx" style="display: block; padding: 0 10px"> ));
</span><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $userdata = get_userdata( $user_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $pw_before = $userdata->user_pass;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -803,7 +811,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $user1 = $this->factory->user->create( array( 'user_login' => 'test_json_user', 'user_email' => 'testjson@example.com' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $user2 = $this->factory->user->create( array( 'user_login' => 'test_json_user2', 'user_email' => 'testjson2@example.com' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</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( 'PUT', '/wp/v2/users/' . $user2 );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'email', 'testjson@example.com' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -816,7 +824,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $user1 = $this->factory->user->create( array( 'user_login' => 'test_json_user', 'user_email' => 'testjson@example.com' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $user2 = $this->factory->user->create( array( 'user_login' => 'test_json_user2', 'user_email' => 'testjson2@example.com' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</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( 'PUT', '/wp/v2/users/' . $user2 );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'username', 'test_json_user' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -829,7 +837,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $user1 = $this->factory->user->create( array( 'user_login' => 'test_json_user', 'user_email' => 'testjson@example.com' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $user2 = $this->factory->user->create( array( 'user_login' => 'test_json_user2', 'user_email' => 'testjson2@example.com' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</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( 'PUT', '/wp/v2/users/' . $user2 );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'slug', 'test_json_user' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -847,7 +855,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'last_name' => 'Original Last',
</span><span class="cx" style="display: block; padding: 0 10px"> ));
</span><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</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"> 'username' => 'test_json_update',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -882,7 +890,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_user_role() {
</span><span class="cx" style="display: block; padding: 0 10px"> $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', $user_id ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -900,14 +908,14 @@
</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 test_update_user_role_invalid_privilege_escalation() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', $this->editor ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', self::$editor ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'roles', array( 'administrator' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_cannot_edit_roles', $response, 403 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = get_userdata( $this->editor );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = get_userdata( self::$editor );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'editor', $user->caps );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayNotHasKey( 'administrator', $user->caps );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -954,22 +962,22 @@
</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 test_update_user_role_invalid_role() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</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 = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', $this->editor ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', self::$editor ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'roles', array( 'BeSharp' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertErrorResponse( 'rest_user_invalid_role', $response, 400 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = get_userdata( $this->editor );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = get_userdata( self::$editor );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'editor', $user->caps );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayNotHasKey( 'BeSharp', $user->caps );
</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 test_update_user_without_permission() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor );
</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"> 'username' => 'homersimpson',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -977,7 +985,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'email' => 'chunkylover53@aol.com',
</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 = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', $this->user ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', self::$user ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $params );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -987,7 +995,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_user_invalid_id() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</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"> 'id' => '156',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -996,7 +1004,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'email' => 'smartgirl63_@yahoo.com',
</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 = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', $this->editor ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', self::$editor ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->add_header( 'content-type', 'application/x-www-form-urlencoded' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( $params );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = $this->server->dispatch( $request );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1008,7 +1016,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $user_id = $this->factory->user->create( array( 'display_name' => 'Deleted User' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $userdata = get_userdata( $user_id ); // cache for later
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1024,7 +1032,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $user_id = $this->factory->user->create( array( 'display_name' => 'Deleted User' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $userdata = get_userdata( $user_id ); // cache for later
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1040,7 +1048,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $user_id = $this->factory->user->create();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->editor );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor );
</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( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $request['force'] = true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1051,7 +1059,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_delete_user_invalid_id() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</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( 'DELETE', '/wp/v2/users/100' );
</span><span class="cx" style="display: block; padding: 0 10px"> $request['force'] = true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1075,7 +1083,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $user_id, $post->post_author );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Delete our test user, and reassign to the new author
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $request['force'] = true;
</span><span class="cx" style="display: block; padding: 0 10px"> $request->set_param( 'reassign', $reassign_id );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1092,7 +1100,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $user_id = $this->factory->user->create();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->allow_user_to_manage_multisite();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</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( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $request['force'] = true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1219,7 +1227,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"> // Check for error on update.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/users/%d', $this->user ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/users/%d', self::$user ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $request->set_body_params( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'my_custom_int' => 'returnError',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1308,7 +1316,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"> protected function allow_user_to_manage_multisite() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( $this->user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$user );
</ins><span class="cx" style="display: block; padding: 0 10px"> $user = wp_get_current_user();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_multisite() ) {
</span></span></pre>
</div>
</div>
</body>
</html>