Make WordPress Core

Ticket #38433: 38433 (1).diff

File 38433 (1).diff, 3.1 KB (added by sachinrajcp123, 7 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..b1d2ff66f9 100644
    a b class Tests_User_Capabilities extends WP_UnitTestCase { (this hunk was shorter than expected) 
    15091509                $this->assertTrue( current_user_can_for_blog( get_current_blog_id(), 'edit_posts' ) );
    15101510                $this->assertFalse( current_user_can_for_blog( get_current_blog_id(), 'foo_the_bar' ) );
    1511                 if ( ! is_multisite() ) {
    1512                         $this->assertTrue( current_user_can_for_blog( 12345, 'edit_posts' ) );
    1513                         return;
    1514                 }
     1511                $this->assertTrue( current_user_can_for_blog( 12345, 'edit_posts' ) );
     1512
     1513                wp_set_current_user( $old_uid );
     1514        }
     1515
     1516        /**
     1517         * @group ms-required
     1518         */
     1519        function test_multisite_current_user_can_for_blog() {
     1520                global $wpdb;
     1521
     1522                $user    = self::$users['administrator'];
     1523                $old_uid = get_current_user_id();
     1524                wp_set_current_user( $user->ID );
     1525
     1526                $this->assertTrue( current_user_can_for_blog( get_current_blog_id(), 'edit_posts' ) );
     1527                $this->assertFalse( current_user_can_for_blog( get_current_blog_id(), 'foo_the_bar' ) );
     1528
     1529                $suppress = $wpdb->suppress_errors();
     1530                $this->assertFalse( current_user_can_for_blog( 12345, 'edit_posts' ) );
    class Tests_User_Capabilities extends WP_UnitTestCase { 
    15821600                $this->assertFalse( current_user_can( 'edit_post', $post ) );
     1601                $this->assertFalse( current_user_can_for_blog( get_current_blog_id(), 'edit_post', $post ) );
     1602                $this->assertFalse( current_user_can( 'edit_post', $post + 1 ) );
     1603                $this->assertFalse( current_user_can_for_blog( get_current_blog_id(), 'edit_post', $post + 1 ) );
     1604        }
     1605
     1606        /**
     1607         * @group santilin
     1608         */
     1609        function test_editor_can_edit_posts() {
     1610                $user = self::$users['editor'];
     1611                wp_set_current_user( $user->ID );
     1612
     1613                $post = self::factory()->post->create( array( 'post_author' => $user->ID ) );
     1614
     1615                $this->assertTrue( current_user_can( 'edit_post', $post ) );
     1616                $this->assertFalse( current_user_can( 'edit_post', $post + 1 ) );
     1617                $this->assertTrue( current_user_can_for_blog( get_current_blog_id(), 'edit_post', $post ) );
     1618                $this->assertFalse( current_user_can_for_blog( get_current_blog_id(), 'edit_post', $post + 1 ) );
     1619                if ( is_multisite() ) {
     1620                        $this->assertFalse( current_user_can_for_blog( 12345, 'edit_post', $post ) );
     1621                        $this->assertFalse( current_user_can_for_blog( 12345, 'edit_post', $post + 1 ) );
     1622                } else {
     1623                        $this->assertTrue( current_user_can_for_blog( 12345, 'edit_post', $post ) );
     1624                        $this->assertFalse( current_user_can_for_blog( 12345, 'edit_post', $post + 1 ) );
     1625                }
    15831626        }