From 94999cb7ba7ee215964b4969946b8d153f185fa6 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Tue, 26 Jul 2022 12:49:06 +0500 Subject: [PATCH 1/2] Fix: recreate-network-alias throw error on single site --- includes/classes/Command.php | 4 ++++ tests/cypress/integration/wp-cli.spec.js | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/includes/classes/Command.php b/includes/classes/Command.php index 0d296a78f1..198b398bde 100644 --- a/includes/classes/Command.php +++ b/includes/classes/Command.php @@ -570,6 +570,10 @@ public function recreate_network_alias( $args, $assoc_args ) { $this->connect_check(); $this->index_occurring(); + if ( ! defined( 'EP_IS_NETWORK' ) || ! EP_IS_NETWORK ) { + WP_CLI::error( esc_html__( 'ElasticPress is not activated on network.', 'elasticpress' ) ); + } + $indexables = Indexables::factory()->get_all( false ); foreach ( $indexables as $indexable ) { diff --git a/tests/cypress/integration/wp-cli.spec.js b/tests/cypress/integration/wp-cli.spec.js index 364b94d76c..32d2f02fd3 100644 --- a/tests/cypress/integration/wp-cli.spec.js +++ b/tests/cypress/integration/wp-cli.spec.js @@ -144,6 +144,12 @@ describe('WP-CLI Commands', () => { it('Can recreate the alias index which points to every index in the network if user runs wp elasticpress recreate-network-alias command', () => {}); + it('wp elasticpress recreate-network-alias throws an error message if the plugin is not activated on the network', () => { + cy.wpCli('wp elasticpress recreate-network-alias', true) + .its('stderr') + .should('contain', 'ElasticPress is not activated on network'); + }); + it('Can activate and deactivate a feature', () => { cy.wpCli('wp elasticpress activate-feature search', true) .its('stderr') From 44008534af489f9ece736b01137d72016b6e6f6f Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Tue, 26 Jul 2022 21:14:26 +0500 Subject: [PATCH 2/2] Feedback addressed --- includes/classes/Command.php | 2 +- tests/cypress/integration/wp-cli.spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/classes/Command.php b/includes/classes/Command.php index 198b398bde..e8e2fe64bd 100644 --- a/includes/classes/Command.php +++ b/includes/classes/Command.php @@ -571,7 +571,7 @@ public function recreate_network_alias( $args, $assoc_args ) { $this->index_occurring(); if ( ! defined( 'EP_IS_NETWORK' ) || ! EP_IS_NETWORK ) { - WP_CLI::error( esc_html__( 'ElasticPress is not activated on network.', 'elasticpress' ) ); + WP_CLI::error( esc_html__( 'ElasticPress is not network activated.', 'elasticpress' ) ); } $indexables = Indexables::factory()->get_all( false ); diff --git a/tests/cypress/integration/wp-cli.spec.js b/tests/cypress/integration/wp-cli.spec.js index 32d2f02fd3..e8e19175ad 100644 --- a/tests/cypress/integration/wp-cli.spec.js +++ b/tests/cypress/integration/wp-cli.spec.js @@ -144,10 +144,10 @@ describe('WP-CLI Commands', () => { it('Can recreate the alias index which points to every index in the network if user runs wp elasticpress recreate-network-alias command', () => {}); - it('wp elasticpress recreate-network-alias throws an error message if the plugin is not activated on the network', () => { + it('Can throw an error while running wp elasticpress recreate-network-alias if the plugin is not network activated', () => { cy.wpCli('wp elasticpress recreate-network-alias', true) .its('stderr') - .should('contain', 'ElasticPress is not activated on network'); + .should('contain', 'ElasticPress is not network activated'); }); it('Can activate and deactivate a feature', () => {