Make WordPress Core


Ignore:
Timestamp:
11/29/2015 02:24:15 AM (10 years ago)
Author:
johnbillion
Message:

When a post is scheduled for publication, treat it the same as a published post when calculating the capabilities required to edit or delete it.

Fixes #33694

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/user/capabilities.php

    r35242 r35747  
    982982    }
    983983
     984    /**
     985     * @ticket 33694
     986     */
     987    function test_contributor_cannot_edit_scheduled_post() {
     988
     989        // Add a contributor
     990        $contributor = $this->factory->user->create_and_get( array(
     991            'role' => 'contributor',
     992        ) );
     993
     994        // Give them a scheduled post
     995        $post = $this->factory->post->create_and_get( array(
     996            'post_author' => $contributor->ID,
     997            'post_status' => 'future',
     998        ) );
     999
     1000        // Ensure contributor can't edit or trash the post
     1001        $this->assertFalse( user_can( $contributor->ID, 'edit_post', $post->ID ) );
     1002        $this->assertFalse( user_can( $contributor->ID, 'delete_post', $post->ID ) );
     1003
     1004        // Test the tests
     1005        $this->assertTrue( defined( 'EMPTY_TRASH_DAYS' ) );
     1006        $this->assertNotEmpty( EMPTY_TRASH_DAYS );
     1007
     1008        // Trash it
     1009        $trashed = wp_trash_post( $post->ID );
     1010        $this->assertNotEmpty( $trashed );
     1011
     1012        // Ensure contributor can't edit, un-trash, or delete the post
     1013        $this->assertFalse( user_can( $contributor->ID, 'edit_post', $post->ID ) );
     1014        $this->assertFalse( user_can( $contributor->ID, 'delete_post', $post->ID ) );
     1015
     1016    }
     1017
    9841018    function test_multisite_administrator_with_manage_network_users_can_edit_users() {
    9851019        if ( ! is_multisite() ) {
Note: See TracChangeset for help on using the changeset viewer.