WordPress.org

Make WordPress Core

Changeset 1251 in tests


Ignore:
Timestamp:
03/29/13 01:01:45 (13 months ago)
Author:
markjaquith
Message:

We now store a revision for the current version, so these counts must be bumped. see #16215

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/post/revisions.php

    r1237 r1251  
    3838        wp_set_current_user( $admin_user_id ); 
    3939        $revisions = wp_get_post_revisions( $post_id ); 
    40         $this->assertCount( 1, $revisions ); 
     40        $this->assertCount( 2, $revisions ); 
    4141 
    4242        $lastrevision = end( $revisions ); 
     
    5959    function test_revision_dont_save_revision_if_unchanged() { 
    6060        $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 
    6467 
    6568        //update the post 
    6669        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 2 revision so far 
     70        $this->assertCount( 3, wp_get_post_revisions( $post_id ) ); // should be 3 revision so far 
    6871 
    6972        //next try to save another identical update, tests for patch that prevents storing duplicates 
    7073        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 revision 
     74        $this->assertCount( 3, wp_get_post_revisions( $post_id ) ); //should still be 2 revision 
    7275 
    7376        //next try to save another update, same content, but new ttile, should save revision 
    7477        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 revision 
     78        $this->assertCount( 4, wp_get_post_revisions( $post_id ) ); //should  be 3 revision 
    7679 
    7780        //next try to save another identical update 
    7881        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 revision 
     82        $this->assertCount( 4, wp_get_post_revisions( $post_id ) ); //should still be 3 revision 
    8083    } 
    8184 
     
    8891 
    8992        $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 
    9195        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 
    9498        //update the post 
    9599        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 
    98102        //next try to save another identical update, tests for patch that prevents storing duplicates 
    99103        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 
    102106        //next try to save another update, same content, but new ttile, should save revision 
    103107        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 
    106110        //next try to save another identical update 
    107111        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 ) ); 
    109113 
    110114        remove_filter( 'wp_save_post_revision_check_for_changes', '__return_false' ); 
     
    123127 
    124128        $revisions = wp_get_post_revisions( $post_id ); 
    125         $this->assertCount( 1, $revisions ); 
     129        $this->assertCount( 2, $revisions ); 
    126130        $this->assertTrue( user_can( $editor_user_id, 'read_post', $post_id ) ); 
    127131 
     
    148152 
    149153        $revisions = wp_get_post_revisions( $post_id ); 
    150         $this->assertCount( 1, $revisions ); 
     154        $this->assertCount( 2, $revisions ); 
    151155        foreach ( $revisions as $revision ) { 
    152156             $this->assertTrue( user_can( $editor_user_id, 'edit_post', $revision->post_parent ) ); 
     
    173177        // Diff checks if you can read both left and right revisions 
    174178        $revisions = wp_get_post_revisions( $post_id ); 
    175         $this->assertCount( 2, $revisions ); 
     179        $this->assertCount( 3, $revisions ); 
    176180        foreach ( $revisions as $revision ) { 
    177181            $this->assertTrue( user_can( $editor_user_id, 'read_post', $revision->ID ) ); 
     
    202206 
    203207        $revisions = wp_get_post_revisions( $post_id ); 
    204         $this->assertCount( 1, $revisions ); 
     208        $this->assertCount( 2, $revisions ); 
    205209        $this->assertTrue( user_can( $editor_user_id, 'read_post', $post_id ) ); 
    206210 
     
    238242 
    239243        $revisions = wp_get_post_revisions( $post_id ); 
    240         $this->assertCount( 1, $revisions ); 
     244        $this->assertCount( 2, $revisions ); 
    241245        foreach ( $revisions as $revision ) { 
    242246            $this->assertTrue( user_can( $editor_user_id, 'edit_post', $revision->post_parent ) ); 
     
    273277 
    274278        $revisions = wp_get_post_revisions( $post_id ); 
    275         $this->assertCount( 1, $revisions ); 
     279        $this->assertCount( 2, $revisions ); 
    276280        foreach ( $revisions as $revision ) { 
    277281            $this->assertTrue( current_user_can( 'edit_post', $revision->post_parent ) ); 
     
    282286 
    283287        $revisions = wp_get_post_revisions( $post_id ); 
    284         $this->assertCount( 2, $revisions ); 
     288        $this->assertCount( 3, $revisions ); 
    285289        foreach ( $revisions as $revision ) { 
    286290            $this->assertFalse( current_user_can( 'edit_post', $revision->post_parent ) ); 
     
    310314        // Diff checks if you can read both left and right revisions 
    311315        $revisions = wp_get_post_revisions( $post_id ); 
    312         $this->assertEquals( count( $revisions ), 2 ); 
     316        $this->assertEquals( count( $revisions ), 3 ); 
    313317        foreach ( $revisions as $revision ) { 
    314318            $this->assertTrue( user_can( $editor_user_id, 'read_post', $revision->ID ) ); 
Note: See TracChangeset for help on using the changeset viewer.