Skip to content

Commit d1e1500

Browse files
Copilotswissspidy
andcommitted
Address code review feedback: move validation earlier and add test comments
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 4e3d71b commit d1e1500

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

features/plugin-update.feature

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ Feature: Update WordPress plugins
268268
Success: Updated 1 of 1 plugins (1 skipped).
269269
"""
270270

271+
# Tests for --auto-update-indicated feature
272+
# Note: These tests verify the flag handling and error cases.
273+
# The actual update behavior when autoupdate is true from the server
274+
# cannot be easily tested as it requires mocking WordPress.org API responses.
275+
# The update functionality itself is handled by the existing update_many method.
276+
271277
@require-wp-5.2
272278
Scenario: Show auto_update_indicated field in plugin list
273279
Given a WP install

src/Plugin_Command.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,11 @@ public function update( $args, $assoc_args ) {
763763
$all = Utils\get_flag_value( $assoc_args, 'all', false );
764764
$auto_update_indicated = Utils\get_flag_value( $assoc_args, 'auto-update-indicated', false );
765765

766+
// Don't allow --version to be set with --auto-update-indicated, as the version comes from the server.
767+
if ( $auto_update_indicated && isset( $assoc_args['version'] ) ) {
768+
WP_CLI::error( 'Cannot use --version with --auto-update-indicated. The version is determined by the server.' );
769+
}
770+
766771
// If --auto-update-indicated is set, we need to filter plugins by this flag.
767772
if ( $auto_update_indicated ) {
768773
// Get all plugins with their update info.
@@ -784,11 +789,6 @@ function ( $item ) {
784789
return;
785790
}
786791

787-
// Don't allow --version to be set with --auto-update-indicated, as the version comes from the server.
788-
if ( isset( $assoc_args['version'] ) ) {
789-
WP_CLI::error( 'Cannot use --version with --auto-update-indicated. The version is determined by the server.' );
790-
}
791-
792792
// Process the updates.
793793
parent::update_many( $args, $assoc_args );
794794
return;

0 commit comments

Comments
 (0)