<!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>[35183] trunk/tests/phpunit/tests/post.php: Unit Tests: in `Tests_Post`, create fixtures for users.</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/35183">35183</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/35183","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>wonderboymusic</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-10-15 03:30:09 +0000 (Thu, 15 Oct 2015)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Unit Tests: in `Tests_Post`, create fixtures for users.
See <a href="https://core.trac.wordpress.org/ticket/30017">#30017</a>, <a href="https://core.trac.wordpress.org/ticket/33968">#33968</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestspostphp">trunk/tests/phpunit/tests/post.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestspostphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/post.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/post.php 2015-10-15 03:07:48 UTC (rev 35182)
+++ trunk/tests/phpunit/tests/post.php 2015-10-15 03:30:09 UTC (rev 35183)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,20 +6,52 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group post
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Post extends WP_UnitTestCase {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $editor_id;
+ protected static $grammarian_id;
+
+ public static function setUpBeforeClass() {
+ parent::setUpBeforeClass();
+
+ $factory = new WP_UnitTest_Factory();
+
+ self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
+
+ add_role( 'grammarian', 'Grammarian', array(
+ 'read' => true,
+ 'edit_posts' => true,
+ 'edit_others_posts' => true,
+ 'edit_published_posts' => true,
+ ) );
+
+ self::$grammarian_id = $factory->user->create( array( 'role' => 'grammarian' ) );
+
+ self::commit_transaction();
+ }
+
+ public static function tearDownAfterClass() {
+ parent::tearDownAfterClass();
+
+ $ids = array( self::$editor_id, self::$grammarian_id );
+ foreach ( $ids as $id ) {
+ if ( is_multisite() ) {
+ wpmu_delete_user( $id );
+ } else {
+ wp_delete_user( $id );
+ }
+ }
+
+ self::commit_transaction();
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> 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->author_id = $this->factory->user->create( array( 'role' => 'editor' ) );
- $this->old_current_user = get_current_user_id();
- wp_set_current_user( $this->author_id );
- _set_cron_array(array());
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ wp_set_current_user( self::$editor_id );
+ _set_cron_array( array() );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->post_ids = 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">- function tearDown() {
- wp_set_current_user( $this->old_current_user );
- parent::tearDown();
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> // helper function: return the timestamp(s) of cron jobs for the specified hook and post
</span><span class="cx" style="display: block; padding: 0 10px"> function _next_schedule_for_post($hook, $id) {
</span><span class="cx" style="display: block; padding: 0 10px"> return wp_next_scheduled('publish_future_post', array(0=>intval($id)));
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -40,7 +72,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $post_types as $post_type ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => rand_str(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -94,7 +126,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $future_date = strtotime('+1 day');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => rand_str(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -129,7 +161,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"> $post = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => rand_str(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -171,7 +203,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $future_date_2 = strtotime('+2 day');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => rand_str(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -211,7 +243,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $future_date = strtotime('+1 day');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> 'post_status' => 'draft',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => rand_str(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -243,7 +275,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $future_date_1 = strtotime('+1 day');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => rand_str(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -284,7 +316,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ($statuses as $status) {
</span><span class="cx" style="display: block; padding: 0 10px"> $post = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => rand_str(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -324,7 +356,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $future_date = strtotime('+1 day');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> 'post_status' => 'private',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => rand_str(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -357,7 +389,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // insert a post with an invalid date, make sure it fails
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> 'post_status' => 'public',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => rand_str(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -378,7 +410,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $future_date_1 = strtotime('+1 day');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => rand_str(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -476,7 +508,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $future_date = strtotime('+1 day');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => rand_str(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -505,7 +537,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => '',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -769,7 +801,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $title = rand_str();
</span><span class="cx" style="display: block; padding: 0 10px"> $post_data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> 'post_status' => 'public',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => $title,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -781,7 +813,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( ( is_int($insert_post_id) && $insert_post_id > 0 ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $insert_post_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $post->post_author, $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( $post->post_author, self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $post->post_title, $title );
</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">@@ -793,7 +825,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> register_post_type( $post_type );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->post->create( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => $post_type,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> $count = wp_count_posts( $post_type, 'readable' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 1, $count->publish );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -806,7 +838,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> register_post_type( $post_type );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->factory->post->create_many( 3, array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => $post_type,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> $count1 = wp_count_posts( $post_type, 'readable' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 3, $count1->publish );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1026,7 +1058,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function test_wp_insert_post_default_comment_ping_status_open() {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = $this->factory->post->create( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> 'post_status' => 'public',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => rand_str(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1042,7 +1074,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function test_wp_insert_post_page_default_comment_ping_status_closed() {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = $this->factory->post->create( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> 'post_status' => 'public',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => rand_str(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1061,7 +1093,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $post_type = rand_str(20);
</span><span class="cx" style="display: block; padding: 0 10px"> register_post_type( $post_type, array( 'supports' => array( 'comments', 'trackbacks' ) ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = $this->factory->post->create( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> 'post_status' => 'public',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => rand_str(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1081,7 +1113,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $post_type = rand_str(20);
</span><span class="cx" style="display: block; padding: 0 10px"> register_post_type( $post_type );
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = $this->factory->post->create( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> 'post_status' => 'public',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => rand_str(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1101,16 +1133,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 24153
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function test_user_without_publish_cannot_affect_sticky() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Create a role with edit_others_posts.
- add_role( 'grammarian', 'Grammarian', array(
- 'read' => true,
- 'edit_posts' => true,
- 'edit_others_posts' => true,
- 'edit_published_posts' => true,
- ) );
- $editor_user = $this->factory->user->create( array( 'role' => 'grammarian' ) );
- $old_uid = get_current_user_id();
- wp_set_current_user( $editor_user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$grammarian_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Sanity Check.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( current_user_can( 'publish_posts' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1137,9 +1160,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( is_sticky( $saved_post->ID ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'Updated', $saved_post->post_title );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'Updated', $saved_post->post_content );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- // Teardown
- wp_set_current_user( $old_uid );
</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"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1159,16 +1179,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Sanity Check.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( is_sticky( $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">- // Create a role with edit_others_posts.
- add_role( 'grammarian', 'Grammarian', array(
- 'read' => true,
- 'edit_posts' => true,
- 'edit_others_posts' => true,
- 'edit_published_posts' => true,
- ) );
- $editor_user = $this->factory->user->create( array( 'role' => 'grammarian' ) );
- $old_uid = get_current_user_id();
- wp_set_current_user( $editor_user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$grammarian_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Sanity Check.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( current_user_can( 'publish_posts' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1188,9 +1199,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( is_sticky( $saved_post->ID ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'Updated', $saved_post->post_title );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'Updated', $saved_post->post_content );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- // Teardown
- wp_set_current_user( $old_uid );
</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"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1208,7 +1216,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_insert_post_author_null() {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = $this->factory->post->create( array( 'post_author' => null ) );
</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( $this->author_id, get_post( $post_id )->post_author );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$editor_id, get_post( $post_id )->post_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"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1216,7 +1224,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function test_wp_insert_post_should_respect_post_date_gmt() {
</span><span class="cx" style="display: block; padding: 0 10px"> $post = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_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"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => rand_str(),
</span></span></pre>
</div>
</div>
</body>
</html>