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 { |
| 1508 | 1508 | |
| 1509 | 1509 | $this->assertTrue( current_user_can_for_blog( get_current_blog_id(), 'edit_posts' ) ); |
| 1510 | 1510 | $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' ) ); |
| 1515 | 1528 | |
| 1516 | 1529 | $suppress = $wpdb->suppress_errors(); |
| 1517 | 1530 | $this->assertFalse( current_user_can_for_blog( 12345, 'edit_posts' ) ); |
| … |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
| 1524 | 1537 | wp_set_current_user( $old_uid ); |
| 1525 | 1538 | } |
| 1526 | 1539 | |
| | 1540 | |
| 1527 | 1541 | /** |
| 1528 | 1542 | * @group ms-required |
| 1529 | 1543 | */ |
| … |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
| 1572 | 1586 | $user->remove_cap( 'publish_posts' ); |
| 1573 | 1587 | $this->assertFalse( $user->has_cap( 'publish_posts' ) ); |
| 1574 | 1588 | } |
| 1575 | | |
| | 1589 | /** |
| | 1590 | * @group santilin |
| | 1591 | */ |
| 1576 | 1592 | function test_subscriber_cant_edit_posts() { |
| 1577 | 1593 | $user = self::$users['subscriber']; |
| 1578 | 1594 | wp_set_current_user( $user->ID ); |
| … |
… |
class Tests_User_Capabilities extends WP_UnitTestCase { |
| 1580 | 1596 | $post = self::factory()->post->create( array( 'post_author' => 1 ) ); |
| 1581 | 1597 | |
| 1582 | 1598 | $this->assertFalse( current_user_can( 'edit_post', $post ) ); |
| | 1599 | $this->assertFalse( current_user_can_for_blog( get_current_blog_id(), 'edit_post', $post ) ); |
| | 1600 | $this->assertFalse( current_user_can( 'edit_post', $post + 1 ) ); |
| | 1601 | $this->assertFalse( current_user_can_for_blog( get_current_blog_id(), 'edit_post', $post + 1 ) ); |
| | 1602 | } |
| | 1603 | |
| | 1604 | /** |
| | 1605 | * @group santilin |
| | 1606 | */ |
| | 1607 | function test_editor_can_edit_posts() { |
| | 1608 | $user = self::$users['editor']; |
| | 1609 | wp_set_current_user( $user->ID ); |
| | 1610 | |
| | 1611 | $post = self::factory()->post->create( array( 'post_author' => $user->ID ) ); |
| | 1612 | |
| | 1613 | $this->assertTrue( current_user_can( 'edit_post', $post ) ); |
| 1583 | 1614 | $this->assertFalse( current_user_can( 'edit_post', $post + 1 ) ); |
| | 1615 | $this->assertTrue( current_user_can_for_blog( get_current_blog_id(), 'edit_post', $post ) ); |
| | 1616 | $this->assertFalse( current_user_can_for_blog( get_current_blog_id(), 'edit_post', $post + 1 ) ); |
| | 1617 | if ( is_multisite() ) { |
| | 1618 | $this->assertFalse( current_user_can_for_blog( 12345, 'edit_post', $post ) ); |
| | 1619 | $this->assertFalse( current_user_can_for_blog( 12345, 'edit_post', $post + 1 ) ); |
| | 1620 | } else { |
| | 1621 | $this->assertTrue( current_user_can_for_blog( 12345, 'edit_post', $post ) ); |
| | 1622 | $this->assertFalse( current_user_can_for_blog( 12345, 'edit_post', $post + 1 ) ); |
| | 1623 | } |
| 1584 | 1624 | } |
| 1585 | 1625 | |
| 1586 | 1626 | /** |