Make WordPress Core

Ticket #7392: revisions.php

File revisions.php, 1.7 KB (added by adamsilverstein, 12 years ago)

corrected php doc, removed empty setup teardown

Line 
1<?php
2/**
3 * @group revisions
4 */
5class Tests_Revisions extends WP_UnitTestCase {
6
7        /**
8        * @ticket 7392
9        */
10        function test_revision_dont_save_revision_if_unchanged() {
11                $post_id = $this->factory->post->create( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) );
12
13                wp_update_post( array( 'post_content'   => 'some updated content', 'ID' => $post_id ) );        //1st revision
14                $this->assertEquals( 1, count( wp_get_post_revisions( $post_id ) ) ); //should be 1 revision so far
15
16                //update the post
17                wp_update_post( array( 'post_content'   => 'new update for some updated content', 'ID' => $post_id ) ); //2nd revision
18                $this->assertEquals( 2, count( wp_get_post_revisions( $post_id ) ) ); //should be 2 revision so far
19
20                //next try to save another identical update, tests for patch that prevents storing duplicates
21                wp_update_post( array( 'post_content'   => 'new update for some updated content', 'ID' => $post_id ) ); //content unchanged, shouldn't save
22                $this->assertEquals( 2, count( wp_get_post_revisions( $post_id ) ) ); //should still be 2 revision
23
24                //next try to save another update, same content, but new ttile, should save revision
25                wp_update_post( array( 'post_title' => 'some-post-changed', 'post_content'      => 'new update for some updated content', 'ID' => $post_id ) );
26                $this->assertEquals( 3, count( wp_get_post_revisions( $post_id ) ) ); //should  be 3 revision
27
28                //next try to save another identical update
29                wp_update_post( array( 'post_title' => 'some-post-changed', 'post_content'      => 'new update for some updated content', 'ID' => $post_id ) ); //content unchanged, shouldn't save
30                $this->assertEquals( 3, count( wp_get_post_revisions( $post_id ) ) ); //should still be 3 revision
31        }
32}