Warn when deleting multisite user with no blog roles#408
Warn when deleting multisite user with no blog roles#408danielbachhuber merged 5 commits intowp-cli:mainfrom
Conversation
danielbachhuber
left a comment
There was a problem hiding this comment.
I'm new to Behat and my attempt hangs when doing
composer behat -- features/user.feature. Any suggestions?
To confirm, you've created a database for the test suite to connect to?
What happens when you run composer behat -- features/user.feature --format pretty?
I have no clue what functional tests should look like for this scenario.
It seems like you made a pretty good start! Do you have some specific questions we could help with?
src/User_Command.php
Outdated
| $result = wpmu_delete_user( $user_id ); | ||
| $message = "Deleted user {$user_id}."; | ||
| } else if (is_multisite() && empty($user->roles)) { | ||
| $message = "No roles found for user {$user_id} on " . get_site_url($blog_id) . ', no users deleted.'; |
There was a problem hiding this comment.
Should we use home_url() like below?
Also, there will be some PHPCS warnings on your current code.
There was a problem hiding this comment.
My computer is running php PHP 8.2.4 and I'm getting a single error that prevents phpcs from working properly.
I had to do phpcs --standard=WP_CLI_CS User_Command.php -d error_reporting="E_ALL&~E_DEPRECATED to actaully get accurate( I hope ) report from running phpcs.
Yes, the database setup/install-package-test step all went fine. I've updated the tests with |
|
@danielbachhuber I've updated the PR to try and address the issues you pointed out. Thanks for suggestions. |
|
@MannyAdumbire Yes in Behat tests you must pass |
@MannyAdumbire Ah, yeah that will cause the tests to hang. |
danielbachhuber
left a comment
There was a problem hiding this comment.
Just one minor nit, then should be good if the tests pass.
features/user.feature
Outdated
| And save STDOUT as {BOB_ID} | ||
|
|
||
| When I run `wp user delete bobjones --yes` | ||
| Then STDOUT should not be empty |
There was a problem hiding this comment.
Can we use a Then STDOUT should contain:, and also have a And STDERR should be empty?
There was a problem hiding this comment.
done!
I was going based off current test
https://github.com/wp-cli/entity-command/blob/1f013e1b097a6af7a1ae85ea797f076486a7c749/features/user.feature#L70-71
but makes sense. hope this works. ;)
features/user.feature
Outdated
| When I run `wp user delete bobjones --yes` | ||
| Then STDOUT should be: | ||
| """ | ||
| Success: Removed user {BOB_ID} from https://example.com. |
There was a problem hiding this comment.
@danielbachhuber Is this Then more specific than necessary? I'm now noticing example that I could have copied
There was a problem hiding this comment.
entity-command/features/user.feature
Line 345 in 1f013e1
There was a problem hiding this comment.
Is this
Thenmore specific than necessary? I'm now noticing example that I could have copied
@MannyAdumbire I don't have strong feelings one way or the other. A little less specific would be fine.
There was a problem hiding this comment.
cool! I made it less specific then for consistency with the other step.
|
I'm all set as far as changes. |
danielbachhuber
left a comment
There was a problem hiding this comment.
Great work on this, @MannyAdumbire — thanks again!


Fixes #403
I have no clue what functional tests should look like for this scenario.
I'm new to Behat and my attempt hangs when doing
composer behat -- features/user.feature. Any suggestions?