<!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>[35245] trunk/tests/phpunit/tests: Unit Tests: better fixtures for `Tests_Admin_Includes_Post`.</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/35245">35245</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/35245","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-17 19:47:07 +0000 (Sat, 17 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: better fixtures for `Tests_Admin_Includes_Post`.
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="#trunktestsphpunittestsadminincludesPostphp">trunk/tests/phpunit/tests/admin/includesPost.php</a></li>
<li><a href="#trunktestsphpunittestsuserphp">trunk/tests/phpunit/tests/user.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestsadminincludesPostphp"></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/admin/includesPost.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/admin/includesPost.php 2015-10-17 19:24:20 UTC (rev 35244)
+++ trunk/tests/phpunit/tests/admin/includesPost.php 2015-10-17 19:47:07 UTC (rev 35245)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3,17 +3,39 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @group admin
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-class Tests_Admin_includesPost extends WP_UnitTestCase {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+class Tests_Admin_Includes_Post extends WP_UnitTestCase {
+ protected static $contributor_id;
+ protected static $author_ids;
+ protected static $editor_id;
+ protected static $admin_id;
+ protected static $post_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">+ protected static $user_ids = array();
+
+ public static function wpSetUpBeforeClass( $factory ) {
+ self::$user_ids = self::$author_ids = $factory->user->create_many( 2, array( 'role' => 'author' ) );
+
+ self::$user_ids[] = self::$contributor_id = $factory->user->create( array( 'role' => 'contributor' ) );
+ self::$user_ids[] = self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
+ self::$user_ids[] = self::$admin_id = $factory->user->create( array( 'role' => 'administrator' ) );
+
+ self::$post_id = $factory->post->create();
+ }
+
+ public static function wpTearDownAfterClass() {
+ foreach ( self::$user_ids as $id ) {
+ self::delete_user( $id );
+ }
+
+ wp_delete_post( self::$post_id, true );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> function test__wp_translate_postdata_cap_checks_contributor() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $contributor_id = self::factory()->user->create( array( 'role' => 'contributor' ) );
- $editor_id = self::factory()->user->create( array( 'role' => 'editor' ) );
</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">- wp_set_current_user( $contributor_id );
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Create New Draft Post
</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_data['post_author'] = $contributor_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_post_data['post_author'] = self::$contributor_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $_post_data['post_type'] = 'post';
</span><span class="cx" style="display: block; padding: 0 10px"> $_post_data['saveasdraft'] = true;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -24,7 +46,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Submit Post for Approval
</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_data['post_author'] = $contributor_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_post_data['post_author'] = self::$contributor_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $_post_data['post_type'] = 'post';
</span><span class="cx" style="display: block; padding: 0 10px"> $_post_data['publish'] = true;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -35,7 +57,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Create New Draft Post for another user
</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_data['post_author'] = $editor_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_post_data['post_author'] = self::$editor_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $_post_data['post_type'] = 'post';
</span><span class="cx" style="display: block; padding: 0 10px"> $_post_data['saveasdraft'] = true;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -46,8 +68,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Edit Draft Post for another user
</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_data['post_ID'] = self::factory()->post->create( array( 'post_author' => $editor_id ) );
- $_post_data['post_author'] = $editor_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_post_data['post_ID'] = self::factory()->post->create( array( 'post_author' => self::$editor_id ) );
+ $_post_data['post_author'] = self::$editor_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $_post_data['post_type'] = 'post';
</span><span class="cx" style="display: block; padding: 0 10px"> $_post_data['post_status'] = 'draft';
</span><span class="cx" style="display: block; padding: 0 10px"> $_post_data['saveasdraft'] = true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -59,14 +81,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"> function test__wp_translate_postdata_cap_checks_editor() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $contributor_id = self::factory()->user->create( array( 'role' => 'contributor' ) );
- $editor_id = self::factory()->user->create( array( 'role' => 'editor' ) );
</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_set_current_user( $editor_id );
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Create New Draft Post
</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_data['post_author'] = $editor_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_post_data['post_author'] = self::$editor_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $_post_data['post_type'] = 'post';
</span><span class="cx" style="display: block; padding: 0 10px"> $_post_data['saveasdraft'] = true;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -77,7 +96,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Publish Post
</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_data['post_author'] = $editor_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_post_data['post_author'] = self::$editor_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $_post_data['post_type'] = 'post';
</span><span class="cx" style="display: block; padding: 0 10px"> $_post_data['publish'] = true;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -88,7 +107,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Create New Draft Post for another user
</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_data['post_author'] = $contributor_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_post_data['post_author'] = self::$contributor_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $_post_data['post_type'] = 'post';
</span><span class="cx" style="display: block; padding: 0 10px"> $_post_data['saveasdraft'] = true;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -99,8 +118,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Edit Draft Post for another user
</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_data['post_ID'] = self::factory()->post->create( array( 'post_author' => $contributor_id ) );
- $_post_data['post_author'] = $contributor_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_post_data['post_ID'] = self::factory()->post->create( array( 'post_author' => self::$contributor_id ) );
+ $_post_data['post_author'] = self::$contributor_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $_post_data['post_type'] = 'post';
</span><span class="cx" style="display: block; padding: 0 10px"> $_post_data['post_status'] = 'draft';
</span><span class="cx" style="display: block; padding: 0 10px"> $_post_data['saveasdraft'] = true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -117,8 +136,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 25272
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function test_edit_post_auto_draft() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = self::factory()->user->create( array( 'role' => 'editor' ) );
- wp_set_current_user( $user_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"> $post = self::factory()->post->create_and_get( array( 'post_status' => 'auto-draft' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'auto-draft', $post->post_status );
</span><span class="cx" style="display: block; padding: 0 10px"> $post_data = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -135,8 +153,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 30615
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_edit_post_should_parse_tax_input_by_name_rather_than_slug_for_nonhierarchical_taxonomies() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $u = self::factory()->user->create( array( 'role' => 'editor' ) );
- wp_set_current_user( $u );
</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"> register_taxonomy( 'wptests_tax', array( 'post' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $t1 = self::factory()->term->create( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -150,10 +167,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'slug' => 'foo',
</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">- $p = self::factory()->post->create();
-
</del><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_ID' => $p,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'tax_input' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'wptests_tax' => 'foo,baz',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -161,7 +176,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> edit_post( $post_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">- $found = wp_get_post_terms( $p, 'wptests_tax' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $found = wp_get_post_terms( self::$post_id, 'wptests_tax' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Should contain the term with the name 'foo', not the slug.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertContains( $t1, wp_list_pluck( $found, 'term_id' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -174,20 +189,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 30615
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_edit_post_should_not_create_terms_for_an_empty_tag_input_field() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $u = self::factory()->user->create( array( 'role' => 'editor' ) );
- wp_set_current_user( $u );
</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"> register_taxonomy( 'wptests_tax', array( 'post' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $t1 = self::factory()->term->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::factory()->term->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'taxonomy' => 'wptests_tax',
</span><span class="cx" style="display: block; padding: 0 10px"> 'name' => 'foo',
</span><span class="cx" style="display: block; padding: 0 10px"> 'slug' => 'bar',
</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">- $p = self::factory()->post->create();
-
</del><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_ID' => $p,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'tax_input' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'wptests_tax' => ' ',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -195,7 +207,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> edit_post( $post_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">- $found = wp_get_post_terms( $p, 'wptests_tax' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $found = wp_get_post_terms( self::$post_id, 'wptests_tax' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEmpty( $found );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -204,19 +216,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 27792
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function test_bulk_edit_posts_stomping() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $admin = self::factory()->user->create( array( 'role' => 'administrator' ) );
- $users = self::factory()->user->create_many( 2, array( 'role' => 'author' ) );
- wp_set_current_user( $admin );
</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"> $post1 = self::factory()->post->create( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $users[0],
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_author' => self::$author_ids[0],
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment_status' => 'open',
</span><span class="cx" style="display: block; padding: 0 10px"> 'ping_status' => 'open',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</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"> $post2 = self::factory()->post->create( array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $users[1],
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_author' => self::$author_ids[1],
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment_status' => 'closed',
</span><span class="cx" style="display: block; padding: 0 10px"> 'ping_status' => 'closed',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'draft',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -231,13 +241,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'post' => array( $post1, $post2 ),
</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">- $done = bulk_edit_posts( $request );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ bulk_edit_posts( $request );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check that the first post's values don't stomp the second post.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'draft', $post->post_status );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $users[1], $post->post_author );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$author_ids[1], $post->post_author );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'closed', $post->comment_status );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'closed', $post->ping_status );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -263,7 +273,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 18306
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_sample_permalink_html_should_use_default_permalink_for_view_post_link_when_pretty_permalinks_are_disabled() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
</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"> $future_date = date( 'Y-m-d H:i:s', time() + 100 );
</span><span class="cx" style="display: block; padding: 0 10px"> $p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -279,7 +289,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_sample_permalink_html_should_use_pretty_permalink_for_view_post_link_when_pretty_permalinks_are_enabled() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->set_permalink_structure( '/%postname%/' );
</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( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
</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"> $future_date = date( 'Y-m-d H:i:s', time() + 100 );
</span><span class="cx" style="display: block; padding: 0 10px"> $p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -296,7 +306,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_sample_permalink_html_should_use_correct_permalink_for_view_post_link_when_changing_slug() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->set_permalink_structure( '/%postname%/' );
</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( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
</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"> // Published posts should use published permalink
</span><span class="cx" style="display: block; padding: 0 10px"> $p = self::factory()->post->create( array( 'post_status' => 'publish', 'post_name' => 'foo' ) );
</span></span></pre></div>
<a id="trunktestsphpunittestsuserphp"></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/user.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/user.php 2015-10-17 19:24:20 UTC (rev 35244)
+++ trunk/tests/phpunit/tests/user.php 2015-10-17 19:47:07 UTC (rev 35245)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -244,11 +244,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"> foreach ( $roles as $role => $level ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = self::factory()->user->create( array(
- 'user_email' => 'user_19265_' . $role . '@burritos.com',
- 'user_login' => 'user_19265_' . $role,
- 'role' => $role
- ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user_id = self::factory()->user->create( array( 'role' => $role ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $user = new WP_User( $user_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( isset( $user->user_level ) );
</span></span></pre>
</div>
</div>
</body>
</html>