Skip to content

Commit 84f3aa4

Browse files
Fix behat test failing
1 parent 6c0b7f6 commit 84f3aa4

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

features/user.feature

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -379,26 +379,6 @@ Feature: Manage WordPress users
379379
administrator
380380
"""
381381
382-
Scenario: Show error when trying to remove capability same as role
383-
Given a WP install
384-
385-
When I run `wp user create testuser2 [email protected] --first_name=test --last_name=user --role=contributor --porcelain`
386-
Then STDOUT should be a number
387-
And save STDOUT as {USER_ID}
388-
389-
When I run `wp user list-caps {USER_ID}`
390-
Then STDOUT should contain:
391-
"""
392-
contributor
393-
"""
394-
395-
When I run `wp user remove-cap {USER_ID} contributor`
396-
Then the return code should be 1
397-
And STDERR should be:
398-
"""
399-
Error: There is a role similar to 'contributor' capability. Use `wp user remove-role` instead.
400-
"""
401-
402382
Scenario: Managing user capabilities
403383
Given a WP install
404384
@@ -452,6 +432,33 @@ Feature: Manage WordPress users
452432
publish_posts
453433
"""
454434
435+
Scenario: Show error when trying to remove capability same as role
436+
Given a WP install
437+
438+
When I run `wp user create testuser2 [email protected] --first_name=test --last_name=user --role=contributor --porcelain`
439+
Then STDOUT should be a number
440+
And save STDOUT as {USER_ID}
441+
442+
When I run `wp user list-caps {USER_ID}`
443+
Then STDOUT should contain:
444+
"""
445+
contributor
446+
"""
447+
448+
When I run `wp user get {USER_ID} --field=roles`
449+
Then STDOUT should contain:
450+
"""
451+
contributor
452+
"""
453+
454+
When I try `wp user remove-cap {USER_ID} contributor`
455+
Then the return code should be 1
456+
And STDERR should be:
457+
"""
458+
Error: There is a role similar to 'contributor' capability. Use `wp user remove-role` instead.
459+
"""
460+
And STDOUT should be empty
461+
455462
Scenario: Show password when creating a user
456463
Given a WP install
457464

src/User_Command.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,9 @@ public function remove_cap( $args, $assoc_args ) {
884884
}
885885
WP_CLI::error( "No such '{$cap}' cap for {$user->user_login} ({$user->ID})." );
886886
}
887+
887888
$user_roles = $user->roles;
888-
if ( ! empty( $user_role ) && in_array( $cap, $user_roles, true ) ) {
889+
if ( ! empty( $user_roles ) && in_array( $cap, $user_roles, true ) ) {
889890
WP_CLI::error( "There is a role similar to '{$cap}' capability. Use `wp user remove-role` instead." );
890891
}
891892
$user->remove_cap( $cap );

0 commit comments

Comments
 (0)