Make WordPress Core

Ticket #30854: test_wp_first_revision_is_not_lost.2.diff

File test_wp_first_revision_is_not_lost.2.diff, 1.4 KB (added by adamsilverstein, 7 years ago)
  • src/wp-includes/post.php

     
    29952995        $post_ID = 0;
    29962996        $update = false;
    29972997        $guid = $postarr['guid'];
    2998 
     2998        error_log(json_encode($postarr));
    29992999        if ( ! empty( $postarr['ID'] ) ) {
     3000                error_log('UPDATE!!!');
    30003001                $update = true;
    30013002
    30023003                // Get the post ID and GUID.
  • tests/phpunit/tests/post/revisions.php

     
    382382
    383383                $this->assertEquals( $revision_ids, array_values( wp_list_pluck( $revisions, 'ID' ) ) );
    384384        }
     385
     386        /**
     387         * @ticket 39011
     388         */
     389        function test_wp_first_revision_is_not_lost() {
     390                $post = self::factory()->post->create_and_get( array(
     391                        'post_title' => 'some-post',
     392                        'post_type' => 'post',
     393                        'post_content' => 'Initial Content',
     394                ) );
     395                wp_update_post( $post );
     396                wp_update_post( array(
     397                        'ID' => $post->ID,
     398                        'post_content' => 'Update #1',
     399                ) );
     400
     401                wp_update_post( array(
     402                        'ID' => $post->ID,
     403                        'post_content' => 'Update #2',
     404                ) );
     405
     406                $revisions = wp_get_post_revisions( $post->ID );
     407                $earliest_revision = end( $revisions );
     408
     409                $this->assertEquals( 'Initial Content', $earliest_revision->post_content );
     410        }
    385411}