Skip to content

Commit 75b5b55

Browse files
committed
Accept multiple signups in activate command
1 parent e3bfbbc commit 75b5b55

File tree

2 files changed

+76
-29
lines changed

2 files changed

+76
-29
lines changed

features/signup.feature

Lines changed: 66 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,61 +45,78 @@ Feature: Manage signups in a multisite installation
4545
Given a WP multisite install
4646
And I run `wp eval 'wpmu_signup_user( "bobuser", "[email protected]" );'`
4747

48+
When I run `wp signup get 1 --field=user_login`
49+
Then STDOUT should be:
50+
"""
51+
bobuser
52+
"""
53+
4854
When I run `wp signup get bobuser --fields=signup_id,user_login,user_email,active --format=csv`
4955
Then STDOUT should be:
5056
"""
5157
signup_id,user_login,user_email,active
5258
1,bobuser,[email protected],0
5359
"""
5460

55-
Scenario: Delete signup
61+
Scenario: Activate signup
5662
Given a WP multisite install
63+
And I run `wp eval 'wpmu_signup_user( "bobuser", "[email protected]" );'`
5764

58-
When I run `wp eval 'wpmu_signup_user( "bobuser", "[email protected]" );'`
59-
And I run `wp signup get bobuser --field=user_login`
65+
When I run `wp signup get bobuser --field=active`
6066
Then STDOUT should be:
6167
"""
62-
bobuser
68+
0
6369
"""
6470

65-
When I run `wp signup delete bobuser@example.com`
66-
Then STDOUT should be:
71+
When I run `wp signup activate bobuser`
72+
Then STDOUT should contain:
6773
"""
68-
Success: Signup 1 deleted.
74+
Success: Signup 1 activated.
6975
"""
7076

71-
When I try `wp signup get bobuser`
77+
When I try the previous command again
7278
Then STDERR should be:
7379
"""
74-
Error: Invalid signup ID, email, login, or activation key: 'bobuser'
80+
Warning: Failed activating signup 1.
7581
"""
7682

77-
Scenario: Activate signup
83+
When I run `wp signup get bobuser --field=active`
84+
Then STDOUT should be:
85+
"""
86+
1
87+
"""
88+
89+
When I run `wp user get bobuser --field=user_email`
90+
Then STDOUT should be:
91+
"""
92+
93+
"""
94+
95+
Scenario: Activate multiple signups
7896
Given a WP multisite install
7997
And I run `wp eval 'wpmu_signup_user( "bobuser", "[email protected]" );'`
98+
And I run `wp eval 'wpmu_signup_user( "johnuser", "[email protected]" );'`
8099

81-
And I run `wp signup get bobuser --field=active`
100+
When I run `wp signup list --active=0 --format=count`
82101
Then STDOUT should be:
83102
"""
84-
0
103+
2
85104
"""
86105

87-
When I run `wp signup activate bobuser`
106+
When I run `wp signup activate bobuser johnuser`
88107
Then STDOUT should contain:
89108
"""
90109
Success: Signup 1 activated.
91110
"""
92-
93-
When I run `wp signup get bobuser --field=active`
94-
Then STDOUT should be:
111+
And STDOUT should contain:
95112
"""
96-
1
113+
Success: Signup 2 activated.
97114
"""
98115

99-
When I run `wp user get bobuser --field=user_email`
116+
When I run `wp signup list --active=1 --format=count`
100117
Then STDOUT should be:
101118
"""
102-
119+
2
103120
"""
104121

105122
Scenario: Activate blog signup entry
@@ -124,3 +141,33 @@ Feature: Manage signups in a multisite installation
124141
| domain | path |
125142
| example.com | / |
126143
| example.com | /bobsite/ |
144+
145+
Scenario: Delete signups
146+
Given a WP multisite install
147+
And I run `wp eval 'wpmu_signup_user( "bobuser", "[email protected]" );'`
148+
And I run `wp eval 'wpmu_signup_user( "johnuser", "[email protected]" );'`
149+
150+
When I run `wp signup get bobuser --field=user_email`
151+
Then STDOUT should be:
152+
"""
153+
154+
"""
155+
156+
When I run `wp signup get johnuser --field=user_email`
157+
Then STDOUT should be:
158+
"""
159+
160+
"""
161+
162+
When I run `wp signup delete bobuser@example.com johnuser@example.com`
163+
Then STDOUT should be:
164+
"""
165+
Success: Signup 1 deleted.
166+
Success: Signup 2 deleted.
167+
"""
168+
169+
When I try `wp signup get bobuser`
170+
Then STDERR should be:
171+
"""
172+
Error: Invalid signup ID, email, login, or activation key: 'bobuser'
173+
"""

src/Signup_Command.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,12 @@ public function get( $args, $assoc_args ) {
198198
}
199199

200200
/**
201-
* Activates a signup.
201+
* Activates one or more signups.
202202
*
203203
* ## OPTIONS
204204
*
205-
* <signup>
206-
* : Signup ID, user login, user email, or activation key.
205+
* <signup>...
206+
* : Signup ID, user login, user email, or activation key of the signup(s) to activate.
207207
*
208208
* ## EXAMPLES
209209
*
@@ -214,16 +214,16 @@ public function get( $args, $assoc_args ) {
214214
* @package wp-cli
215215
*/
216216
public function activate( $args, $assoc_args ) {
217-
$signup = $this->fetcher->get_check( $args[0] );
217+
$signups = $this->fetcher->get_many( $args );
218218

219-
if ( $signup ) {
219+
foreach ( $signups as $signup ) {
220220
$result = wpmu_activate_signup( $signup->activation_key );
221-
}
222221

223-
if ( is_wp_error( $result ) ) {
224-
WP_CLI::error( "Failed activating signup {$signup->signup_id}." );
225-
} else {
226-
WP_CLI::success( "Signup {$signup->signup_id} activated. Password: {$result['password']}" );
222+
if ( is_wp_error( $result ) ) {
223+
WP_CLI::warning( "Failed activating signup {$signup->signup_id}." );
224+
} else {
225+
WP_CLI::success( "Signup {$signup->signup_id} activated. Password: {$result['password']}" );
226+
}
227227
}
228228
}
229229

0 commit comments

Comments
 (0)