Conversation
|
@robertogerola Thanks, can you write the php unit test for this PR? see : Also add descriptions to documents. |
|
@codeigniter4/core-team |
|
Personally, i would choose short options with single letters and |
|
Hello, just made the changes : -n for new username and -m for new email. |
Is there any command that does not need user input? |
|
Thanks for the command argument change, I think that is the correct way to handle it. |
I remember someone raised this issue, but I couldn't find PR/IS CI4 threads on GitHub. |
|
CI 4.3 provide a way to write tests for methods that require user input.
It is not good to have no test at all, so if there are commands without user input, We use mocking the test target because there is no other way. shield/tests/Commands/SetupTest.php Lines 44 to 50 in 44bbf2c But I don't think it is good practice. Because mock is not a true product code. |
|
CI 4.3 was released, so you can write tests for CLI input. I think we can skip the tests for CI 4.2. |
It was wrong. 4.3 is not enough to write tests for this command. |
|
Closed by #833 |
Supersedes #567,#568
With the User command is possible by cli to run these actions on users :
'create', 'activate', 'deactivate', 'changename', 'changeemail', 'delete', 'password', 'list', 'addgroup', 'removegroup'Available options :
'-i' => 'User id'
'-u' => 'User name'
'-e' => 'User email'
'-n' => 'New username'
'-m' => 'New email'
'-g' => 'Group name'
1. create a new user
./spark shield:user create -u newuser -e newuser@myemail.com2. activate a user
by username :
./spark shield:user activate -u usernameor
by email :
./spark shield:user activate -e user@myemail.com3. deactivate a user
by username :
./spark shield:user deactivate -u usernameor
by email :
./spark shield:user deactivate -e user@myemail.com4. change user name
by username :
./spark shield:user changename -u username -n newusernameor
by email :
./spark shield:user changename -e user@myemail.com -n newusername5. change user email
by username :
./spark shield:user changeemail -u username -m newuseremail@myemail.comor
by email :
./spark shield:user changeemail -e user@myemail.com -m newuseremail@myemail.com6. delete a user
by user id :
./spark shield:user delete -i 123or
by username :
./spark shield:user delete -u useror
by email :
./spark shield:user delete -e user@myemail.com7. change a user password
by username :
./spark shield:user password -u usernameor
by email :
./spark shield:user password -e user@myemail.com8. list users
List all users :
./spark shield:user listor filter by username and/or email
./spark shield:user list -u user -e user@myemail.com9. add a user to a group
by username :
./spark shield:user addgroup -u username -g mygroupor
by email :
./spark shield:user addgroup -e user@myemail.com -g mygroup10. remove a user from a group
by username :
./spark shield:user removegroup -u username -g mygroupor
by email :
./spark shield:user removegroup -e user@myemail.com -g mygroupAll the options are optional and if the username or email are not passed on command line, a prompt will ask the user for the necessary information to complete the required task. The data inserted are validated and every operation asks for a confirmation too proceed.