Make WordPress Core

Ticket #39011: test_wp_first_revision_is_not_lost.diff

File test_wp_first_revision_is_not_lost.diff, 973 bytes (added by georgestephanis, 8 years ago)
  • 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
     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}