<!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>[53782] trunk/tests/phpunit/tests/post.php: Tests: Bring some modernization to `wp_insert_post()` tests.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/53782">53782</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/53782","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-07-26 13:53:19 +0000 (Tue, 26 Jul 2022)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Tests: Bring some modernization to `wp_insert_post()` tests.
Includes:
* Using `assertIsInt()` instead of `assertIsNumeric()` for post IDs.
* Using consistent variable names for post data and retrieved posts.
* Removing added filters before performing assertions, not after.
* Removing unused `Tests_Post::$post_ids` property.
* Correcting the order of arguments in some assertions.
* Converting some `foreach()` loops to data providers.
* Wrapping long lines for better readability.
Follow-up to [13/tests], [14/tests], [167/tests], [496/tests], [1174/tests], [1246/tests], [1287/tests], [1307/tests], [1326/tests], <a href="https://core.trac.wordpress.org/changeset/30510">[30510]</a>, <a href="https://core.trac.wordpress.org/changeset/33261">[33261]</a>, <a href="https://core.trac.wordpress.org/changeset/33630">[33630]</a>, <a href="https://core.trac.wordpress.org/changeset/34762">[34762]</a>, <a href="https://core.trac.wordpress.org/changeset/46279">[46279]</a>, <a href="https://core.trac.wordpress.org/changeset/50012">[50012]</a>, <a href="https://core.trac.wordpress.org/changeset/51438">[51438]</a>.
See <a href="https://core.trac.wordpress.org/ticket/55652">#55652</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 2022-07-26 13:21:55 UTC (rev 53781)
+++ trunk/tests/phpunit/tests/post.php 2022-07-26 13:53:19 UTC (rev 53782)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -35,15 +35,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$editor_id );
</span><span class="cx" style="display: block; padding: 0 10px"> _set_cron_array( array() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- $this->post_ids = array();
</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="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"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- private function next_schedule_for_post( $hook, $id ) {
- return wp_next_scheduled( 'publish_future_post', array( 0 => (int) $id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private function next_schedule_for_post( $hook, $post_id ) {
+ return wp_next_scheduled( 'publish_future_post', array( 0 => (int) $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"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -58,65 +56,76 @@
</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"> * Test simple valid behavior: insert and get a post.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @dataProvider data_vb_insert_get_delete
</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 test_vb_insert_get_delete() {
- register_post_type( 'cpt', array( 'taxonomies' => array( 'post_tag', 'ctax' ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_vb_insert_get_delete( $post_type ) {
+ register_post_type(
+ 'cpt',
+ array(
+ 'taxonomies' => array( 'post_tag', 'ctax' ),
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'ctax', 'cpt' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_types = array( 'post', 'cpt' );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $post_types as $post_type ) {
- $post = array(
- 'post_author' => self::$editor_id,
- 'post_status' => 'publish',
- 'post_content' => "{$post_type}_content",
- 'post_title' => "{$post_type}_title",
- 'tax_input' => array(
- 'post_tag' => 'tag1,tag2',
- 'ctax' => 'cterm1,cterm2',
- ),
- 'post_type' => $post_type,
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data = array(
+ 'post_author' => self::$editor_id,
+ 'post_status' => 'publish',
+ 'post_content' => "{$post_type}_content",
+ 'post_title' => "{$post_type}_title",
+ 'tax_input' => array(
+ 'post_tag' => 'tag1,tag2',
+ 'ctax' => 'cterm1,cterm2',
+ ),
+ 'post_type' => $post_type,
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Insert a post and make sure the ID is OK.
- $id = wp_insert_post( $post );
- $this->assertIsNumeric( $id );
- $this->assertGreaterThan( 0, $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Insert a post and make sure the ID is OK.
+ $post_id = wp_insert_post( $data );
+ $this->assertIsInt( $post_id );
+ $this->assertGreaterThan( 0, $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">- // Fetch the post and make sure it matches.
- $out = get_post( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Fetch the post and make sure it matches.
+ $post = get_post( $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">- $this->assertSame( $post['post_content'], $out->post_content );
- $this->assertSame( $post['post_title'], $out->post_title );
- $this->assertSame( $post['post_status'], $out->post_status );
- $this->assertEquals( $post['post_author'], $out->post_author );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $data['post_content'], $post->post_content );
+ $this->assertSame( $data['post_title'], $post->post_title );
+ $this->assertSame( $data['post_status'], $post->post_status );
+ $this->assertEquals( $data['post_author'], $post->post_author );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Test cache state.
- $pcache = wp_cache_get( $id, 'posts' );
- $this->assertInstanceOf( 'stdClass', $pcache );
- $this->assertSame( $id, $pcache->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Test cache state.
+ $post_cache = wp_cache_get( $post_id, 'posts' );
+ $this->assertInstanceOf( 'stdClass', $post_cache );
+ $this->assertSame( $post_id, $post_cache->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">- update_object_term_cache( $id, $post_type );
- $tcache = wp_cache_get( $id, 'post_tag_relationships' );
- $this->assertIsArray( $tcache );
- $this->assertCount( 2, $tcache );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_object_term_cache( $post_id, $post_type );
+ $term_cache = wp_cache_get( $post_id, 'post_tag_relationships' );
+ $this->assertIsArray( $term_cache );
+ $this->assertCount( 2, $term_cache );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tcache = wp_cache_get( $id, 'ctax_relationships' );
- if ( 'cpt' === $post_type ) {
- $this->assertIsArray( $tcache );
- $this->assertCount( 2, $tcache );
- } else {
- $this->assertFalse( $tcache );
- }
-
- wp_delete_post( $id, true );
- $this->assertFalse( wp_cache_get( $id, 'posts' ) );
- $this->assertFalse( wp_cache_get( $id, 'post_tag_relationships' ) );
- $this->assertFalse( wp_cache_get( $id, 'ctax_relationships' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term_cache = wp_cache_get( $post_id, 'ctax_relationships' );
+ if ( 'cpt' === $post_type ) {
+ $this->assertIsArray( $term_cache );
+ $this->assertCount( 2, $term_cache );
+ } else {
+ $this->assertFalse( $term_cache );
</ins><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">+ wp_delete_post( $post_id, true );
+
+ $this->assertFalse( wp_cache_get( $post_id, 'posts' ) );
+ $this->assertFalse( wp_cache_get( $post_id, 'post_tag_relationships' ) );
+ $this->assertFalse( wp_cache_get( $post_id, 'ctax_relationships' ) );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $GLOBALS['wp_taxonomies']['post_tag']->object_type = array( 'post' );
</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 function data_vb_insert_get_delete() {
+ $post_types = array( 'post', 'cpt' );
+
+ return $this->text_array_to_dataprovider( $post_types );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Insert a post with a future date, and make sure the status and cron schedule are correct.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -123,7 +132,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_vb_insert_future() {
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_author' => self::$editor_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => 'content',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -132,23 +141,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"> // Insert a post and make sure the ID is OK.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = wp_insert_post( $post );
- $this->post_ids[] = $id;
- // dmp( _get_cron_array() );
- $this->assertIsNumeric( $id );
- $this->assertGreaterThan( 0, $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = wp_insert_post( $data );
+ $this->assertIsInt( $post_id );
+ $this->assertGreaterThan( 0, $post_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Fetch the post and make sure it matches.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $out = get_post( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( $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">- $this->assertSame( $post['post_content'], $out->post_content );
- $this->assertSame( $post['post_title'], $out->post_title );
- $this->assertSame( 'future', $out->post_status );
- $this->assertEquals( $post['post_author'], $out->post_author );
- $this->assertSame( $post['post_date'], $out->post_date );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $data['post_content'], $post->post_content );
+ $this->assertSame( $data['post_title'], $post->post_title );
+ $this->assertSame( 'future', $post->post_status );
+ $this->assertEquals( $data['post_author'], $post->post_author );
+ $this->assertSame( $data['post_date'], $post->post_date );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // There should be a publish_future_post hook scheduled on the future date.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $future_date, $this->next_schedule_for_post( 'publish_future_post', $id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $future_date, $this->next_schedule_for_post( 'publish_future_post', $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"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -159,7 +166,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $future_date_1 = strtotime( 'June 21st +1 year' );
</span><span class="cx" style="display: block; padding: 0 10px"> $future_date_2 = strtotime( 'Jan 11th +1 year' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_author' => self::$editor_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => 'content',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -168,31 +175,29 @@
</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"> // Insert a post and make sure the ID is OK.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = wp_insert_post( $post );
- $this->post_ids[] = $id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = wp_insert_post( $data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Fetch the post and make sure has the correct date and status.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $out = get_post( $id );
- $this->assertSame( 'future', $out->post_status );
- $this->assertSame( $post['post_date'], $out->post_date );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( $post_id );
+ $this->assertSame( 'future', $post->post_status );
+ $this->assertSame( $data['post_date'], $post->post_date );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check that there's a publish_future_post job scheduled at the right time.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $future_date_1, $this->next_schedule_for_post( 'publish_future_post', $id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $future_date_1, $this->next_schedule_for_post( 'publish_future_post', $post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Now save it again with a date further in the future.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data['ID'] = $post_id;
+ $data['post_date'] = date_format( date_create( "@{$future_date_2}" ), 'Y-m-d H:i:s' );
+ $data['post_date_gmt'] = null;
+ wp_update_post( $data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post['ID'] = $id;
- $post['post_date'] = date_format( date_create( "@{$future_date_2}" ), 'Y-m-d H:i:s' );
- $post['post_date_gmt'] = null;
- wp_update_post( $post );
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Fetch the post again and make sure it has the new post_date.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $out = get_post( $id );
- $this->assertSame( 'future', $out->post_status );
- $this->assertSame( $post['post_date'], $out->post_date );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( $post_id );
+ $this->assertSame( 'future', $post->post_status );
+ $this->assertSame( $data['post_date'], $post->post_date );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // And the correct date on the cron job.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $future_date_2, $this->next_schedule_for_post( 'publish_future_post', $id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $future_date_2, $this->next_schedule_for_post( 'publish_future_post', $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"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -204,7 +209,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"> $future_date_2 = strtotime( '+2 day' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_author' => self::$editor_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => 'content',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -213,31 +218,29 @@
</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"> // Insert a post and make sure the ID is OK.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = wp_insert_post( $post );
- $this->post_ids[] = $id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = wp_insert_post( $data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Fetch the post and make sure has the correct date and status.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $out = get_post( $id );
- $this->assertSame( 'future', $out->post_status );
- $this->assertSame( $post['post_date'], $out->post_date );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( $post_id );
+ $this->assertSame( 'future', $post->post_status );
+ $this->assertSame( $data['post_date'], $post->post_date );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check that there's a publish_future_post job scheduled at the right time.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $future_date_1, $this->next_schedule_for_post( 'publish_future_post', $id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $future_date_1, $this->next_schedule_for_post( 'publish_future_post', $post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Now save it again with a date further in the future.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data['ID'] = $post_id;
+ $data['post_date'] = date_format( date_create( "@{$future_date_2}" ), 'Y-m-d H:i:s' );
+ $data['post_date_gmt'] = null;
+ wp_update_post( $data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post['ID'] = $id;
- $post['post_date'] = date_format( date_create( "@{$future_date_2}" ), 'Y-m-d H:i:s' );
- $post['post_date_gmt'] = null;
- wp_update_post( $post );
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Fetch the post again and make sure it has the new post_date.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $out = get_post( $id );
- $this->assertSame( 'future', $out->post_status );
- $this->assertSame( $post['post_date'], $out->post_date );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( $post_id );
+ $this->assertSame( 'future', $post->post_status );
+ $this->assertSame( $data['post_date'], $post->post_date );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // And the correct date on the cron job.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $future_date_2, $this->next_schedule_for_post( 'publish_future_post', $id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $future_date_2, $this->next_schedule_for_post( 'publish_future_post', $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"> /**
</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"> public function test_vb_insert_future_draft() {
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_author' => self::$editor_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'draft',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => 'content',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -255,23 +258,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"> // Insert a post and make sure the ID is OK.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = wp_insert_post( $post );
- $this->post_ids[] = $id;
- // dmp( _get_cron_array() );
- $this->assertIsNumeric( $id );
- $this->assertGreaterThan( 0, $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = wp_insert_post( $data );
+ $this->assertIsInt( $post_id );
+ $this->assertGreaterThan( 0, $post_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Fetch the post and make sure it matches.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $out = get_post( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( $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">- $this->assertSame( $post['post_content'], $out->post_content );
- $this->assertSame( $post['post_title'], $out->post_title );
- $this->assertSame( 'draft', $out->post_status );
- $this->assertEquals( $post['post_author'], $out->post_author );
- $this->assertSame( $post['post_date'], $out->post_date );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $data['post_content'], $post->post_content );
+ $this->assertSame( $data['post_title'], $post->post_title );
+ $this->assertSame( 'draft', $post->post_status );
+ $this->assertEquals( $data['post_author'], $post->post_author );
+ $this->assertSame( $data['post_date'], $post->post_date );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // There should be a publish_future_post hook scheduled on the future date.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $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">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -281,7 +282,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_vb_insert_future_change_to_draft() {
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_author' => self::$editor_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => 'content',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -290,75 +291,82 @@
</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"> // Insert a post and make sure the ID is OK.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = wp_insert_post( $post );
- $this->post_ids[] = $id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = wp_insert_post( $data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Fetch the post and make sure has the correct date and status.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $out = get_post( $id );
- $this->assertSame( 'future', $out->post_status );
- $this->assertSame( $post['post_date'], $out->post_date );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( $post_id );
+ $this->assertSame( 'future', $post->post_status );
+ $this->assertSame( $data['post_date'], $post->post_date );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check that there's a publish_future_post job scheduled at the right time.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $future_date_1, $this->next_schedule_for_post( 'publish_future_post', $id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $future_date_1, $this->next_schedule_for_post( 'publish_future_post', $post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Now save it again with status set to draft.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data['ID'] = $post_id;
+ $data['post_status'] = 'draft';
+ wp_update_post( $data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post['ID'] = $id;
- $post['post_status'] = 'draft';
- wp_update_post( $post );
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Fetch the post again and make sure it has the new post_date.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $out = get_post( $id );
- $this->assertSame( 'draft', $out->post_status );
- $this->assertSame( $post['post_date'], $out->post_date );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( $post_id );
+ $this->assertSame( 'draft', $post->post_status );
+ $this->assertSame( $data['post_date'], $post->post_date );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // And the correct date on the cron job.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $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"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Insert a future post, then edit and change the status, and make sure cron gets it right.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @dataProvider data_vb_insert_future_change_status
</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 test_vb_insert_future_change_status() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_vb_insert_future_change_status( $status ) {
</ins><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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $statuses = array( 'draft', 'static', 'object', 'attachment', 'inherit', 'pending' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data = array(
+ 'post_author' => self::$editor_id,
+ 'post_status' => 'publish',
+ 'post_content' => "{$status}_content",
+ 'post_title' => "{$status}_title",
+ 'post_date' => date_format( date_create( "@{$future_date_1}" ), 'Y-m-d H:i:s' ),
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $statuses as $status ) {
- $post = array(
- 'post_author' => self::$editor_id,
- 'post_status' => 'publish',
- 'post_content' => "{$status}_content",
- 'post_title' => "{$status}_title",
- 'post_date' => date_format( date_create( "@{$future_date_1}" ), 'Y-m-d H:i:s' ),
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Insert a post and make sure the ID is OK.
+ $post_id = wp_insert_post( $data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Insert a post and make sure the ID is OK.
- $id = wp_insert_post( $post );
- $this->post_ids[] = $id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Fetch the post and make sure has the correct date and status.
+ $post = get_post( $post_id );
+ $this->assertSame( 'future', $post->post_status );
+ $this->assertSame( $data['post_date'], $post->post_date );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Fetch the post and make sure has the correct date and status.
- $out = get_post( $id );
- $this->assertSame( 'future', $out->post_status );
- $this->assertSame( $post['post_date'], $out->post_date );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Check that there's a publish_future_post job scheduled at the right time.
+ $this->assertSame( $future_date_1, $this->next_schedule_for_post( 'publish_future_post', $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">- // Check that there's a publish_future_post job scheduled at the right time.
- $this->assertSame( $future_date_1, $this->next_schedule_for_post( 'publish_future_post', $id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Now save it again with status changed.
+ $data['ID'] = $post_id;
+ $data['post_status'] = $status;
+ wp_update_post( $data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Now save it again with status changed.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Fetch the post again and make sure it has the new post_date.
+ $post = get_post( $post_id );
+ $this->assertSame( $status, $post->post_status );
+ $this->assertSame( $data['post_date'], $post->post_date );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post['ID'] = $id;
- $post['post_status'] = $status;
- wp_update_post( $post );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // And the correct date on the cron job.
+ $this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $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">- // Fetch the post again and make sure it has the new post_date.
- $out = get_post( $id );
- $this->assertSame( $status, $out->post_status );
- $this->assertSame( $post['post_date'], $out->post_date );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function data_vb_insert_future_change_status() {
+ $statuses = array(
+ 'draft',
+ 'static',
+ 'object',
+ 'attachment',
+ 'inherit',
+ 'pending',
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // And the correct date on the cron job.
- $this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $id ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $this->text_array_to_dataprovider( $statuses );
</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">@@ -367,7 +375,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_vb_insert_future_private() {
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_author' => self::$editor_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'private',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => 'content',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -376,23 +384,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"> // Insert a post and make sure the ID is OK.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = wp_insert_post( $post );
- $this->post_ids[] = $id;
- // dmp( _get_cron_array() );
- $this->assertIsNumeric( $id );
- $this->assertGreaterThan( 0, $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = wp_insert_post( $data );
+ $this->assertIsInt( $post_id );
+ $this->assertGreaterThan( 0, $post_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Fetch the post and make sure it matches.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $out = get_post( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( $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">- $this->assertSame( $post['post_content'], $out->post_content );
- $this->assertSame( $post['post_title'], $out->post_title );
- $this->assertSame( 'private', $out->post_status );
- $this->assertEquals( $post['post_author'], $out->post_author );
- $this->assertSame( $post['post_date'], $out->post_date );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $data['post_content'], $post->post_content );
+ $this->assertSame( $data['post_title'], $post->post_title );
+ $this->assertSame( 'private', $post->post_status );
+ $this->assertEquals( $data['post_author'], $post->post_author );
+ $this->assertSame( $data['post_date'], $post->post_date );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // There should be a publish_future_post hook scheduled on the future date.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $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"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -401,7 +407,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 17180
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_vb_insert_invalid_date() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_author' => self::$editor_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => 'content',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -410,12 +416,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"> // Test both return paths with or without WP_Error.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $insert_post = wp_insert_post( $post, true );
- $this->assertWPError( $insert_post );
- $this->assertSame( 'invalid_date', $insert_post->get_error_code() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = wp_insert_post( $data, true );
+ $this->assertWPError( $post_id );
+ $this->assertSame( 'invalid_date', $post_id->get_error_code() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $insert_post = wp_insert_post( $post );
- $this->assertSame( 0, $insert_post );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = wp_insert_post( $data );
+ $this->assertSame( 0, $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"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -424,7 +430,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_vb_insert_future_change_to_private() {
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_author' => self::$editor_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => 'content',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -433,30 +439,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"> // Insert a post and make sure the ID is OK.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = wp_insert_post( $post );
- $this->post_ids[] = $id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = wp_insert_post( $data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Fetch the post and make sure has the correct date and status.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $out = get_post( $id );
- $this->assertSame( 'future', $out->post_status );
- $this->assertSame( $post['post_date'], $out->post_date );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( $post_id );
+ $this->assertSame( 'future', $post->post_status );
+ $this->assertSame( $data['post_date'], $post->post_date );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check that there's a publish_future_post job scheduled at the right time.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $future_date_1, $this->next_schedule_for_post( 'publish_future_post', $id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $future_date_1, $this->next_schedule_for_post( 'publish_future_post', $post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Now save it again with status set to draft.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data['ID'] = $post_id;
+ $data['post_status'] = 'private';
+ wp_update_post( $data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post['ID'] = $id;
- $post['post_status'] = 'private';
- wp_update_post( $post );
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Fetch the post again and make sure it has the new post_date.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $out = get_post( $id );
- $this->assertSame( 'private', $out->post_status );
- $this->assertSame( $post['post_date'], $out->post_date );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( $post_id );
+ $this->assertSame( 'private', $post->post_status );
+ $this->assertSame( $data['post_date'], $post->post_date );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // And the correct date on the cron job.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $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"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -465,7 +469,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_insert_post_should_not_allow_a_bare_numeric_slug_that_might_conflict_with_a_date_archive_when_generating_from_an_empty_post_title() {
</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">- $p = wp_insert_post(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = wp_insert_post(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => '',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => 'test',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -474,11 +478,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">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = get_post( $p );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( $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">- $this->set_permalink_structure();
-
- $this->assertSame( "$p-2", $post->post_name );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( "$post_id-2", $post->post_name );
</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">@@ -488,7 +490,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_insert_post_should_invalidate_post_cache_before_generating_guid_when_post_name_is_empty_and_is_generated_from_the_post_ID() {
</span><span class="cx" style="display: block; padding: 0 10px"> register_post_type( 'wptests_pt' );
</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 = wp_insert_post(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = wp_insert_post(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => '',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => 'wptests_pt',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -496,9 +498,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">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = get_post( $p );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( $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">- $this->assertStringContainsString( 'wptests_pt=' . $p, $post->guid );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertStringContainsString( 'wptests_pt=' . $post_id, $post->guid );
</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">@@ -514,7 +516,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertIsNumeric( $post_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertIsInt( $post_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertGreaterThan( 0, $post_id );
</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">@@ -547,7 +549,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_delete_future_post_cron() {
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_author' => self::$editor_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => 'content',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -556,16 +558,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"> // Insert a post and make sure the ID is OK.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = wp_insert_post( $post );
- $this->post_ids[] = $id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = wp_insert_post( $data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check that there's a publish_future_post job scheduled at the right time.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $future_date, $this->next_schedule_for_post( 'publish_future_post', $id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $future_date, $this->next_schedule_for_post( 'publish_future_post', $post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Now delete the post and make sure the cron entry is removed.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_delete_post( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_delete_post( $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">- $this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $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"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -578,7 +579,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_permalink_without_title() {
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_author' => self::$editor_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => 'content',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -587,24 +588,26 @@
</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"> // Insert a post and make sure the ID is OK.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = wp_insert_post( $post );
- $this->post_ids[] = $id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = wp_insert_post( $data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $plink = get_permalink( $id );
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Permalink should include the post ID at the end.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( get_option( 'siteurl' ) . '/2007/10/31/' . $id . '/', $plink );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = get_option( 'siteurl' ) . '/2007/10/31/' . $post_id . '/';
+ $this->assertSame( $expected, get_permalink( $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"> public function test_wp_publish_post() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $draft_id = self::factory()->post->create( array( 'post_status' => 'draft' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $draft_id = self::factory()->post->create(
+ array(
+ 'post_status' => 'draft',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $draft_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'draft', $post->post_status );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_publish_post( $draft_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $draft_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'publish', $post->post_status );
</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">@@ -625,8 +628,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $future_date, $post->post_date );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_publish_post( $post_id );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'publish', $post->post_status );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $future_date, $post->post_date );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -653,7 +656,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_publish_post_with_content_filtering() {
</span><span class="cx" style="display: block; padding: 0 10px"> kses_remove_filters();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_id = wp_insert_post( array( 'post_title' => '<script>Test</script>' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = wp_insert_post(
+ array(
+ 'post_title' => '<script>Test</script>',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '<script>Test</script>', $post->post_title );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'draft', $post->post_status );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -666,10 +673,11 @@
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ kses_remove_filters();
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post->ID );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'Test', $post->post_title );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- kses_remove_filters();
</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">@@ -678,7 +686,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_publish_post_and_avoid_content_filtering() {
</span><span class="cx" style="display: block; padding: 0 10px"> kses_remove_filters();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_id = wp_insert_post( array( 'post_title' => '<script>Test</script>' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = wp_insert_post(
+ array(
+ 'post_title' => '<script>Test</script>',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '<script>Test</script>', $post->post_title );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'draft', $post->post_status );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -686,10 +698,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> kses_init_filters();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_publish_post( $post->ID );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ kses_remove_filters();
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post->ID );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '<script>Test</script>', $post->post_title );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- kses_remove_filters();
</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">@@ -697,8 +710,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_post_ancestors_within_loop() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $post;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $parent_id = self::factory()->post->create();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get( array( 'post_parent' => $parent_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = self::factory()->post->create_and_get(
+ array(
+ 'post_parent' => $parent_id,
+ )
+ );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( array( $parent_id ), get_post_ancestors( 0 ) );
</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">@@ -706,7 +725,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 23474
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_invalid_post_id() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_id = self::factory()->post->create( array( 'post_name' => 'get-page-uri-post-name' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = self::factory()->post->create();
</ins><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id, ARRAY_A );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post['ID'] = 123456789;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -721,9 +740,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_parse_post_content_single_page() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $multipage, $pages, $numpages;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $post_id = self::factory()->post->create(
+ array(
+ 'post_content' => 'Page 0',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px"> setup_postdata( $post );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 0, $multipage );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $pages );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $numpages );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -732,9 +757,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_parse_post_content_multi_page() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $multipage, $pages, $numpages;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $post_id = self::factory()->post->create(
+ array(
+ 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px"> setup_postdata( $post );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $multipage );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 4, $pages );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 4, $numpages );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -743,9 +774,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_parse_post_content_remaining_single_page() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $multipage, $pages, $numpages;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $post_id = self::factory()->post->create(
+ array(
+ 'post_content' => 'Page 0',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px"> setup_postdata( $post );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 0, $multipage );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $pages );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $numpages );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -754,9 +791,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_parse_post_content_remaining_multi_page() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $multipage, $pages, $numpages;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $post_id = self::factory()->post->create(
+ array(
+ 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px"> setup_postdata( $post );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $multipage );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 4, $pages );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 4, $numpages );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -768,9 +811,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_parse_post_content_starting_with_nextpage() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $multipage, $pages, $numpages;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_id = self::factory()->post->create( array( 'post_content' => '<!--nextpage-->Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $post_id = self::factory()->post->create(
+ array(
+ 'post_content' => '<!--nextpage-->Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px"> setup_postdata( $post );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $multipage );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 4, $pages );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 4, $numpages );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -782,9 +831,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_parse_post_content_starting_with_nextpage_multi() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $multipage, $pages, $numpages;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_id = self::factory()->post->create( array( 'post_content' => '<!--nextpage-->Page 0' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $post_id = self::factory()->post->create(
+ array(
+ 'post_content' => '<!--nextpage-->Page 0',
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px"> setup_postdata( $post );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 0, $multipage );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertCount( 1, $pages );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, $numpages );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -799,8 +854,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> register_taxonomy( 'test_tax', 'post' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $title = 'title';
- $post_data = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $title = 'title';
+ $data = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_author' => self::$editor_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => 'content',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -809,13 +864,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'test_tax' => array( 'term', 'term2', 'term3' ),
</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">- $insert_post_id = wp_insert_post( $post_data, true, true );
- $this->assertIsInt( $insert_post_id );
- $this->assertGreaterThan( 0, $insert_post_id );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = get_post( $insert_post_id );
- $this->assertEquals( $post->post_author, self::$editor_id );
- $this->assertSame( $post->post_title, $title );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = wp_insert_post( $data, true, true );
+ $this->assertIsInt( $post_id );
+ $this->assertGreaterThan( 0, $post_id );
+
+ $post = get_post( $post_id );
+ $this->assertEquals( self::$editor_id, $post->post_author );
+ $this->assertSame( $title, $post->post_title );
</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">@@ -824,6 +880,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_count_posts() {
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> self::factory()->post->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => $post_type,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -830,15 +887,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_author' => self::$editor_id,
</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">+
</ins><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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> _unregister_post_type( $post_type );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( new stdClass, wp_count_posts( $post_type, 'readable' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $count = wp_count_posts( $post_type, 'readable' );
+ $this->assertEquals( new stdClass, $count );
</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_wp_count_posts_filtered() {
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> self::factory()->post->create_many(
</span><span class="cx" style="display: block; padding: 0 10px"> 3,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -846,14 +907,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_author' => self::$editor_id,
</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">+
</ins><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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'wp_count_posts', array( $this, 'filter_wp_count_posts' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> $count2 = wp_count_posts( $post_type, 'readable' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_filter( 'wp_count_posts', array( $this, 'filter_wp_count_posts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 2, $count2->publish );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- remove_filter( 'wp_count_posts', array( $this, 'filter_wp_count_posts' ) );
</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"> public function filter_wp_count_posts( $counts ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -865,10 +926,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $post_ids = self::factory()->post->create_many( 3 );
</span><span class="cx" style="display: block; padding: 0 10px"> $initial_counts = wp_count_posts();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $key = array_rand( $post_ids );
- $_post = get_post( $post_ids[ $key ], ARRAY_A );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $key = array_rand( $post_ids );
+ $_post = get_post( $post_ids[ $key ], ARRAY_A );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $_post['post_status'] = 'draft';
</span><span class="cx" style="display: block; padding: 0 10px"> wp_insert_post( $_post );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_ids[ $key ] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'draft', $post->post_status );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEquals( 'publish', $post->post_status );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1025,6 +1088,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_insert_post_cpt_default_comment_ping_status_open() {
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $post_id = self::factory()->post->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_author' => self::$editor_id,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1036,9 +1100,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ _unregister_post_type( $post_type );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'open', $post->comment_status );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'open', $post->ping_status );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- _unregister_post_type( $post_type );
</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">@@ -1047,6 +1112,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_insert_post_cpt_default_comment_ping_status_closed() {
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $post_id = self::factory()->post->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_author' => self::$editor_id,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1058,9 +1124,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ _unregister_post_type( $post_type );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'closed', $post->comment_status );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'closed', $post->ping_status );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- _unregister_post_type( $post_type );
</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,6 +1226,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> stick_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( is_sticky( $post_id ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> unstick_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( is_sticky( $post_id ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1217,7 +1285,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 15946
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_insert_post_should_respect_post_date_gmt() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_author' => self::$editor_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => 'content',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1226,15 +1294,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"> // Insert a post and make sure the ID is OK.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = wp_insert_post( $post );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_id = wp_insert_post( $data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $out = get_post( $id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = get_post( $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">- $this->assertSame( $post['post_content'], $out->post_content );
- $this->assertSame( $post['post_title'], $out->post_title );
- $this->assertEquals( $post['post_author'], $out->post_author );
- $this->assertSame( get_date_from_gmt( $post['post_date_gmt'] ), $out->post_date );
- $this->assertSame( $post['post_date_gmt'], $out->post_date_gmt );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( $data['post_content'], $post->post_content );
+ $this->assertSame( $data['post_title'], $post->post_title );
+ $this->assertEquals( $data['post_author'], $post->post_author );
+ $this->assertSame( get_date_from_gmt( $data['post_date_gmt'] ), $post->post_date );
+ $this->assertSame( $data['post_date_gmt'], $post->post_date_gmt );
</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_wp_delete_post_reassign_hierarchical_post_type() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1251,9 +1319,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_parent' => $parent_page_id,
</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">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $parent_page_id, get_post( $page_id )->post_parent );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_delete_post( $parent_page_id, true );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $grandparent_page_id, get_post( $page_id )->post_parent );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_delete_post( $grandparent_page_id, true );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 0, get_post( $page_id )->post_parent );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1265,7 +1336,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 30937
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_insert_post_for_customize_changeset_should_not_drop_post_name() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 10, has_filter( 'wp_insert_post_data', '_wp_customize_changeset_filter_insert_post_data' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $changeset_data = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1370,7 +1440,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"> $post = get_post( $post_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- self::assertEqualsWithDelta( strtotime( gmdate( 'Y-m-d H:i:s' ) ), strtotime( $post->post_date_gmt ), 2, 'The dates should be equal' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::assertEqualsWithDelta(
+ strtotime( gmdate( 'Y-m-d H:i:s' ) ),
+ strtotime( $post->post_date_gmt ),
+ 2,
+ 'The dates should be equal'
+ );
</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">@@ -1428,7 +1503,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"> $post = get_post( $post_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEqualsWithDelta( strtotime( gmdate( 'Y-m-d H:i:s' ) ), strtotime( $post->post_date ), 2, 'The dates should be equal' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualsWithDelta(
+ strtotime( gmdate( 'Y-m-d H:i:s' ) ),
+ strtotime( $post->post_date ),
+ 2,
+ 'The dates should be equal'
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = self::factory()->post->create(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1438,7 +1518,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"> $post = get_post( $post_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEqualsWithDelta( strtotime( gmdate( 'Y-m-d H:i:s' ) ), strtotime( $post->post_date ), 2, 'The dates should be equal' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualsWithDelta(
+ strtotime( gmdate( 'Y-m-d H:i:s' ) ),
+ strtotime( $post->post_date ),
+ 2,
+ 'The dates should be equal'
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Empty post_date_gmt without floating status
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1448,8 +1533,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"> $post = get_post( $post_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEqualsWithDelta( strtotime( gmdate( 'Y-m-d H:i:s' ) ), strtotime( $post->post_date ), 2, 'The dates should be equal' );
- $this->assertEqualsWithDelta( strtotime( gmdate( 'Y-m-d H:i:s' ) ), strtotime( get_gmt_from_date( $post->post_date ) ), 2, 'The dates should be equal' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualsWithDelta(
+ strtotime( gmdate( 'Y-m-d H:i:s' ) ),
+ strtotime( $post->post_date ),
+ 2,
+ 'The dates should be equal'
+ );
+ $this->assertEqualsWithDelta(
+ strtotime( gmdate( 'Y-m-d H:i:s' ) ),
+ strtotime( get_gmt_from_date( $post->post_date ) ),
+ 2,
+ 'The dates should be equal'
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = self::factory()->post->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1458,8 +1553,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"> $post = get_post( $post_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEqualsWithDelta( strtotime( gmdate( 'Y-m-d H:i:s' ) ), strtotime( $post->post_date ), 2, 'The dates should be equal' );
- $this->assertEqualsWithDelta( strtotime( gmdate( 'Y-m-d H:i:s' ) ), strtotime( get_gmt_from_date( $post->post_date ) ), 2, 'The dates should be equal' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualsWithDelta(
+ strtotime( gmdate( 'Y-m-d H:i:s' ) ),
+ strtotime( $post->post_date ),
+ 2,
+ 'The dates should be equal'
+ );
+ $this->assertEqualsWithDelta(
+ strtotime( gmdate( 'Y-m-d H:i:s' ) ),
+ strtotime( get_gmt_from_date( $post->post_date ) ),
+ 2,
+ 'The dates should be equal'
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Valid post_date_gmt
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = self::factory()->post->create(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1629,7 +1734,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $invalid_date = '2020-12-41 14:15:27';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $resolved_post_date = wp_resolve_post_date();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEqualsWithDelta( strtotime( gmdate( 'Y-m-d H:i:s' ) ), strtotime( $resolved_post_date ), 2, 'The dates should be equal' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualsWithDelta(
+ strtotime( gmdate( 'Y-m-d H:i:s' ) ),
+ strtotime( $resolved_post_date ),
+ 2,
+ 'The dates should be equal'
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $resolved_post_date = wp_resolve_post_date( '', $post_date_gmt );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( get_date_from_gmt( $post_date_gmt ), $resolved_post_date );
</span></span></pre>
</div>
</div>
</body>
</html>