From 0842857b5c28b04a393e0669a980a0f79b4ff3e6 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Mon, 10 Oct 2016 14:39:35 +0000 Subject: [PATCH] Role/Capability: Add tests for all user roles that check custom capabilities that do not have any form of handling (eg. in a `map_meta_cap` filter). See #38191 git-svn-id: https://develop.svn.wordpress.org/trunk@38769 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/user/capabilities.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/tests/user/capabilities.php b/tests/phpunit/tests/user/capabilities.php index ad0ad0806d..5a70aaae52 100644 --- a/tests/phpunit/tests/user/capabilities.php +++ b/tests/phpunit/tests/user/capabilities.php @@ -457,9 +457,11 @@ class Tests_User_Capabilities extends WP_UnitTestCase { } + $this->assertFalse( $user->has_cap( 'start_a_fire' ), "User with the {$role} role should not have a custom capability" ); + $this->assertFalse( user_can( $user, 'start_a_fire' ), "User with the {$role} role should not have a custom capability" ); + $this->assertFalse( $user->has_cap( 'do_not_allow' ), "User with the {$role} role should not have the do_not_allow capability" ); $this->assertFalse( user_can( $user, 'do_not_allow' ), "User with the {$role} role should not have the do_not_allow capability" ); - } // special case for the link manager @@ -527,6 +529,9 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $this->assertTrue( user_can( $user, $cap ), "Super Admins should have the {$cap} capability" ); } + $this->assertTrue( $user->has_cap( 'start_a_fire' ), "Super admins should have all custom capabilities" ); + $this->assertTrue( user_can( $user, 'start_a_fire' ), "Super admins should have all custom capabilities" ); + $this->assertFalse( $user->has_cap( 'do_not_allow' ), 'Super Admins should not have the do_not_allow capability' ); $this->assertFalse( user_can( $user, 'do_not_allow' ), 'Super Admins should not have the do_not_allow capability' ); @@ -1479,6 +1484,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $this->assertFalse( current_user_can( $cap ), "Non-logged-in user should not have the {$cap} capability" ); } + $this->assertFalse( current_user_can( 'start_a_fire' ), "Non-logged-in user should not have a custom capability" ); $this->assertFalse( current_user_can( 'do_not_allow' ), "Non-logged-in user should not have the do_not_allow capability" ); }