File tree Expand file tree Collapse file tree 2 files changed +31
-5
lines changed
Expand file tree Collapse file tree 2 files changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -139,7 +139,33 @@ Feature: Manage sites in a multisite installation
139139 When I try the previous command again
140140 Then STDERR should contain:
141141 """
142- Site with slug '42' does not exist.
142+ Error: Could not find site with slug '42'.
143+ """
144+ And the return code should be 1
145+
146+ Scenario : Archive a site by a numeric slug
147+ Given a WP multisite install
148+
149+ When I run `wp site create --slug=42`
150+ Then STDOUT should contain:
151+ """
152+ Success: Site 2 created: http
153+ """
154+ And STDOUT should contain:
155+ """
156+ ://example.com/42/
157+ """
158+
159+ When I run `wp site archive --slug=42`
160+ Then STDOUT should contain:
161+ """
162+ Success: Site 2 archived.
163+ """
164+
165+ When I try `wp site archive --slug=43`
166+ Then STDERR should contain:
167+ """
168+ Error: Could not find site with slug '43'.
143169 """
144170 And the return code should be 1
145171
Original file line number Diff line number Diff line change @@ -334,7 +334,7 @@ public function delete( $args, $assoc_args ) {
334334 if ( isset ( $ assoc_args ['slug ' ] ) ) {
335335 $ blog_id = get_id_from_blogname ( $ assoc_args ['slug ' ] );
336336 if ( null === $ blog_id ) {
337- WP_CLI ::error ( " Site with slug ' { $ assoc_args ['slug ' ]} ' does not exist. " );
337+ WP_CLI ::error ( sprintf ( ' Could not find site with slug \' %s \' . ' , $ assoc_args ['slug ' ] ) );
338338 }
339339 $ blog = get_blog_details ( $ blog_id );
340340 } else {
@@ -982,11 +982,11 @@ private function get_sites_ids( $args, $assoc_args ) {
982982 $ slug = Utils \get_flag_value ( $ assoc_args , 'slug ' , false );
983983
984984 if ( $ slug ) {
985- $ blog = get_blog_details ( trim ( $ slug , '/ ' ) );
986- if ( ! $ blog ) {
985+ $ blog_id = get_id_from_blogname ( trim ( $ slug , '/ ' ) );
986+ if ( null === $ blog_id ) {
987987 WP_CLI ::error ( sprintf ( 'Could not find site with slug \'%s \'. ' , $ slug ) );
988988 }
989- return [ $ blog -> blog_id ];
989+ return [ $ blog_id ];
990990 }
991991
992992 return $ args ;
You can’t perform that action at this time.
0 commit comments