Changeset 1251 in tests
- Timestamp:
- 03/29/2013 01:01:45 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/post/revisions.php
r1237 r1251 38 38 wp_set_current_user( $admin_user_id ); 39 39 $revisions = wp_get_post_revisions( $post_id ); 40 $this->assertCount( 1, $revisions );40 $this->assertCount( 2, $revisions ); 41 41 42 42 $lastrevision = end( $revisions ); … … 59 59 function test_revision_dont_save_revision_if_unchanged() { 60 60 $post_id = $this->factory->post->create( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) ); 61 62 wp_update_post( array( 'post_content' => 'some updated content', 'ID' => $post_id ) ); //1st revision 63 $this->assertCount( 1, wp_get_post_revisions( $post_id ) ); //should be 1 revision so far 61 $this->assertCount( 1, wp_get_post_revisions( $post_id ) ); // Just the initial revision 62 63 // First update 64 wp_update_post( array( 'post_content' => 'some updated content', 'ID' => $post_id ) ); 65 66 $this->assertCount( 2, wp_get_post_revisions( $post_id ) ); // should be 2 revisions so far 64 67 65 68 //update the post 66 69 wp_update_post( array( 'post_content' => 'new update for some updated content', 'ID' => $post_id ) ); //2nd revision 67 $this->assertCount( 2, wp_get_post_revisions( $post_id ) ); //should be 2revision so far70 $this->assertCount( 3, wp_get_post_revisions( $post_id ) ); // should be 3 revision so far 68 71 69 72 //next try to save another identical update, tests for patch that prevents storing duplicates 70 73 wp_update_post( array( 'post_content' => 'new update for some updated content', 'ID' => $post_id ) ); //content unchanged, shouldn't save 71 $this->assertCount( 2, wp_get_post_revisions( $post_id ) ); //should still be 2 revision74 $this->assertCount( 3, wp_get_post_revisions( $post_id ) ); //should still be 2 revision 72 75 73 76 //next try to save another update, same content, but new ttile, should save revision 74 77 wp_update_post( array( 'post_title' => 'some-post-changed', 'post_content' => 'new update for some updated content', 'ID' => $post_id ) ); 75 $this->assertCount( 3, wp_get_post_revisions( $post_id ) ); //should be 3 revision78 $this->assertCount( 4, wp_get_post_revisions( $post_id ) ); //should be 3 revision 76 79 77 80 //next try to save another identical update 78 81 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 79 $this->assertCount( 3, wp_get_post_revisions( $post_id ) ); //should still be 3 revision82 $this->assertCount( 4, wp_get_post_revisions( $post_id ) ); //should still be 3 revision 80 83 } 81 84 … … 88 91 89 92 $post_id = $this->factory->post->create( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) ); 90 93 $this->assertCount( 1, wp_get_post_revisions( $post_id ) ); 94 91 95 wp_update_post( array( 'post_content' => 'some updated content', 'ID' => $post_id ) ); //1st revision 92 $this->assertCount( 1, wp_get_post_revisions( $post_id ) );93 96 $this->assertCount( 2, wp_get_post_revisions( $post_id ) ); 97 94 98 //update the post 95 99 wp_update_post( array( 'post_content' => 'new update for some updated content', 'ID' => $post_id ) ); //2nd revision 96 $this->assertCount( 2, wp_get_post_revisions( $post_id ) );97 100 $this->assertCount( 3, wp_get_post_revisions( $post_id ) ); 101 98 102 //next try to save another identical update, tests for patch that prevents storing duplicates 99 103 wp_update_post( array( 'post_content' => 'new update for some updated content', 'ID' => $post_id ) ); //content unchanged, shouldn't save 100 $this->assertCount( 3, wp_get_post_revisions( $post_id ) );101 104 $this->assertCount( 4, wp_get_post_revisions( $post_id ) ); 105 102 106 //next try to save another update, same content, but new ttile, should save revision 103 107 wp_update_post( array( 'post_title' => 'some-post-changed', 'post_content' => 'new update for some updated content', 'ID' => $post_id ) ); 104 $this->assertCount( 4, wp_get_post_revisions( $post_id ) );105 108 $this->assertCount( 5, wp_get_post_revisions( $post_id ) ); 109 106 110 //next try to save another identical update 107 111 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 108 $this->assertCount( 5, wp_get_post_revisions( $post_id ) );112 $this->assertCount( 6, wp_get_post_revisions( $post_id ) ); 109 113 110 114 remove_filter( 'wp_save_post_revision_check_for_changes', '__return_false' ); … … 123 127 124 128 $revisions = wp_get_post_revisions( $post_id ); 125 $this->assertCount( 1, $revisions );129 $this->assertCount( 2, $revisions ); 126 130 $this->assertTrue( user_can( $editor_user_id, 'read_post', $post_id ) ); 127 131 … … 148 152 149 153 $revisions = wp_get_post_revisions( $post_id ); 150 $this->assertCount( 1, $revisions );154 $this->assertCount( 2, $revisions ); 151 155 foreach ( $revisions as $revision ) { 152 156 $this->assertTrue( user_can( $editor_user_id, 'edit_post', $revision->post_parent ) ); … … 173 177 // Diff checks if you can read both left and right revisions 174 178 $revisions = wp_get_post_revisions( $post_id ); 175 $this->assertCount( 2, $revisions );179 $this->assertCount( 3, $revisions ); 176 180 foreach ( $revisions as $revision ) { 177 181 $this->assertTrue( user_can( $editor_user_id, 'read_post', $revision->ID ) ); … … 202 206 203 207 $revisions = wp_get_post_revisions( $post_id ); 204 $this->assertCount( 1, $revisions );208 $this->assertCount( 2, $revisions ); 205 209 $this->assertTrue( user_can( $editor_user_id, 'read_post', $post_id ) ); 206 210 … … 238 242 239 243 $revisions = wp_get_post_revisions( $post_id ); 240 $this->assertCount( 1, $revisions );244 $this->assertCount( 2, $revisions ); 241 245 foreach ( $revisions as $revision ) { 242 246 $this->assertTrue( user_can( $editor_user_id, 'edit_post', $revision->post_parent ) ); … … 273 277 274 278 $revisions = wp_get_post_revisions( $post_id ); 275 $this->assertCount( 1, $revisions );279 $this->assertCount( 2, $revisions ); 276 280 foreach ( $revisions as $revision ) { 277 281 $this->assertTrue( current_user_can( 'edit_post', $revision->post_parent ) ); … … 282 286 283 287 $revisions = wp_get_post_revisions( $post_id ); 284 $this->assertCount( 2, $revisions );288 $this->assertCount( 3, $revisions ); 285 289 foreach ( $revisions as $revision ) { 286 290 $this->assertFalse( current_user_can( 'edit_post', $revision->post_parent ) ); … … 310 314 // Diff checks if you can read both left and right revisions 311 315 $revisions = wp_get_post_revisions( $post_id ); 312 $this->assertEquals( count( $revisions ), 2);316 $this->assertEquals( count( $revisions ), 3 ); 313 317 foreach ( $revisions as $revision ) { 314 318 $this->assertTrue( user_can( $editor_user_id, 'read_post', $revision->ID ) );
Note: See TracChangeset
for help on using the changeset viewer.