WordPress.org

Make WordPress Core

Ticket #38433: 38433.diff

File 38433.diff, 1.8 KB (added by santilinwp, 10 months ago)
  • tests/phpunit/tests/user/capabilities.php

    diff --git a/tests/phpunit/tests/user/capabilities.php b/tests/phpunit/tests/user/capabilities.php
    index 86d70c3ea2..26ae4c830f 100644
    a b class Tests_User_Capabilities extends WP_UnitTestCase { 
    15721572                $user->remove_cap( 'publish_posts' );
    15731573                $this->assertFalse( $user->has_cap( 'publish_posts' ) );
    15741574        }
    1575 
     1575        /**
     1576         * @group santilin
     1577         */
    15761578        function test_subscriber_cant_edit_posts() {
    15771579                $user = self::$users['subscriber'];
    15781580                wp_set_current_user( $user->ID );
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    15801582                $post = self::factory()->post->create( array( 'post_author' => 1 ) );
    15811583
    15821584                $this->assertFalse( current_user_can( 'edit_post', $post ) );
     1585                $this->assertFalse( current_user_can_for_blog( get_current_blog_id(), 'edit_post', $post ) );
     1586                $this->assertFalse( current_user_can( 'edit_post', $post + 1 ) );
     1587                $this->assertFalse( current_user_can_for_blog( get_current_blog_id(), 'edit_post', $post + 1 ) );
     1588        }
     1589
     1590        /**
     1591         * @group santilin
     1592         */
     1593        function test_editor_can_edit_posts() {
     1594                $user = self::$users['editor'];
     1595                wp_set_current_user( $user->ID );
     1596
     1597                $post = self::factory()->post->create( array( 'post_author' => $user->ID ) );
     1598
     1599                $this->assertTrue( current_user_can( 'edit_post', $post ) );
    15831600                $this->assertFalse( current_user_can( 'edit_post', $post + 1 ) );
     1601                $this->assertTrue( current_user_can_for_blog( get_current_blog_id(), 'edit_post', $post ) );
     1602                $this->assertFalse( current_user_can_for_blog( get_current_blog_id(), 'edit_post', $post + 1 ) );
     1603                // The following assert fails when it shouldnt
     1604                $this->assertFalse( current_user_can_for_blog( 12345, 'edit_post', $post ) );
     1605                $this->assertFalse( current_user_can_for_blog( 12345, 'edit_post', $post + 1 ) );
    15841606        }
    15851607
    15861608        /**