diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php index 62fbd7bc81..5c46db1b0c 100644 --- a/tests/phpunit/tests/post.php +++ b/tests/phpunit/tests/post.php @@ -314,19 +314,12 @@ class Tests_Post extends WP_UnitTestCase { } /** - * If a post is sticky and is updated by a user that does not have the publish_post capability, - * it should _stay_ sticky. + * If a sticky post is updated via `wp_update_post()` by a user + * without the `publish_posts` capability, it should stay sticky. * * @ticket 24153 */ - public function test_user_without_publish_cannot_affect_sticky() { - wp_set_current_user( self::$grammarian_id ); - - // Sanity check. - $this->assertFalse( current_user_can( 'publish_posts' ) ); - $this->assertTrue( current_user_can( 'edit_others_posts' ) ); - $this->assertTrue( current_user_can( 'edit_published_posts' ) ); - + public function test_user_without_publish_posts_cannot_affect_sticky() { // Create a sticky post. $post = self::factory()->post->create_and_get( array( @@ -339,6 +332,13 @@ class Tests_Post extends WP_UnitTestCase { // Sanity check. $this->assertTrue( is_sticky( $post->ID ) ); + wp_set_current_user( self::$grammarian_id ); + + // Sanity check. + $this->assertFalse( current_user_can( 'publish_posts' ) ); + $this->assertTrue( current_user_can( 'edit_others_posts' ) ); + $this->assertTrue( current_user_can( 'edit_published_posts' ) ); + // Edit the post. $post->post_title = 'Updated'; $post->post_content = 'Updated'; @@ -352,12 +352,12 @@ class Tests_Post extends WP_UnitTestCase { } /** - * If the `edit_post()` method is invoked by a user without publish_posts permission, - * the sticky status of the post should not be changed. + * If a sticky post is updated via `edit_post()` by a user + * without the `publish_posts` capability, it should stay sticky. * * @ticket 24153 */ - public function test_user_without_publish_cannot_affect_sticky_with_edit_post() { + public function test_user_without_publish_posts_cannot_affect_sticky_with_edit_post() { // Create a sticky post. $post = self::factory()->post->create_and_get( array(