Skip to content

Commit

Permalink
Fix support for --grant=false argument (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbachhuber authored Mar 16, 2023
1 parent 80e2367 commit f586e09
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion features/cap.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Feature: Manage Cap
Success: Added 1 capability to 'contributor' role.
"""

When I run `wp cap add contributor behold observe`
When I run `wp cap add contributor behold observe --grant`
Then STDOUT should contain:
"""
Success: Added 2 capabilities to 'contributor' role.
Expand All @@ -38,6 +38,12 @@ Feature: Manage Cap
Success: Added 2 capabilities to 'contributor' role as false.
"""

When I run `wp cap add contributor inspire --grant=false`
Then STDOUT should contain:
"""
Success: Added 1 capability to 'contributor' role as false.
"""

When I run `wp cap list contributor`
Then STDOUT should contain:
"""
Expand Down
5 changes: 4 additions & 1 deletion src/Capabilities_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ public function add( $args, $assoc_args ) {

$role_obj = self::get_role( $role );

$grant = ! isset( $assoc_args['grant'] ) || ! empty( $assoc_args['grant'] );
$grant = true;
if ( isset( $assoc_args['grant'] ) ) {
$grant = ! $assoc_args['grant'] || 'false' === $assoc_args['grant'] ? false : true;
}

$count = 0;

Expand Down

0 comments on commit f586e09

Please sign in to comment.