Support for adding and removing of multiple user roles by shawnhooper · Pull Request #437 · wp-cli/entity-command · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions README.md
40 changes: 38 additions & 2 deletions features/user.feature
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,50 @@ Feature: Manage WordPress users
Scenario: Managing user roles
Given a WP install

When I try `wp user add-role 1`
Then the return code should be 1
And STDERR should be:
"""
Error: Please specify at least one role to add.
"""
And STDOUT should be empty

When I run `wp user add-role 1 editor`
Then STDOUT should not be empty
And I run `wp user get 1 --field=roles`
Then STDOUT should be:
"""
Success: Added 'editor' role for admin (1).
"""

When I run `wp user get 1 --field=roles`
Then STDOUT should be:
"""
administrator, editor
"""

When I run `wp user add-role 1 editor contributor`
Then STDOUT should be:
"""
Success: Added 'editor', 'contributor' roles for admin (1).
"""

When I run `wp user get 1 --field=roles`
Then STDOUT should be:
"""
administrator, editor, contributor
"""

When I run `wp user remove-role 1 editor contributor`
Then STDOUT should be:
"""
Success: Removed 'editor', 'contributor' roles from admin (1).
"""

When I run `wp user get 1 --field=roles`
Then STDOUT should be:
"""
administrator
"""

When I try `wp user add-role 1 edit`
Then STDERR should contain:
"""
Expand Down
48 changes: 35 additions & 13 deletions src/User_Command.php