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
28 changes: 27 additions & 1 deletion features/site.feature
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,33 @@ Feature: Manage sites in a multisite installation
When I try the previous command again
Then STDERR should contain:
"""
Site with slug '42' does not exist.
Error: Could not find site with slug '42'.
"""
And the return code should be 1

Scenario: Archive a site by a numeric slug
Given a WP multisite install

When I run `wp site create --slug=42`
Then STDOUT should contain:
"""
Success: Site 2 created: http
"""
And STDOUT should contain:
"""
://example.com/42/
"""

When I run `wp site archive --slug=42`
Then STDOUT should contain:
"""
Success: Site 2 archived.
"""

When I try `wp site archive --slug=43`
Then STDERR should contain:
"""
Error: Could not find site with slug '43'.
"""
And the return code should be 1

Expand Down
8 changes: 4 additions & 4 deletions src/Site_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public function delete( $args, $assoc_args ) {
if ( isset( $assoc_args['slug'] ) ) {
$blog_id = get_id_from_blogname( $assoc_args['slug'] );
if ( null === $blog_id ) {
WP_CLI::error( "Site with slug '{$assoc_args['slug']}' does not exist." );
WP_CLI::error( sprintf( 'Could not find site with slug \'%s\'.', $assoc_args['slug'] ) );
}
$blog = get_blog_details( $blog_id );
} else {
Expand Down Expand Up @@ -982,11 +982,11 @@ private function get_sites_ids( $args, $assoc_args ) {
$slug = Utils\get_flag_value( $assoc_args, 'slug', false );

if ( $slug ) {
$blog = get_blog_details( trim( $slug, '/' ) );
if ( ! $blog ) {
$blog_id = get_id_from_blogname( trim( $slug, '/' ) );
if ( null === $blog_id ) {
WP_CLI::error( sprintf( 'Could not find site with slug \'%s\'.', $slug ) );
}
return [ $blog->blog_id ];
return [ $blog_id ];
}

return $args;
Expand Down