Skip to content

Commit e0157bf

Browse files
Copilotswissspidy
andcommitted
Fix format output to suppress success message and use standard test fixtures
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent c62f573 commit e0157bf

4 files changed

Lines changed: 19 additions & 58 deletions

File tree

features/language-core.feature

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -487,21 +487,12 @@ Feature: Manage core translation files for a WordPress install
487487
"""
488488
[]
489489
"""
490-
And STDERR should contain:
491-
"""
492-
Success: Translations are up to date.
493-
"""
490+
And STDERR should be empty
494491

495492
When I run `wp language core update --format=csv`
496493
Then STDOUT should be empty
497-
And STDERR should contain:
498-
"""
499-
Success: Translations are up to date.
500-
"""
494+
And STDERR should be empty
501495

502496
When I run `wp language core update --format=summary`
503497
Then STDOUT should be empty
504-
And STDERR should contain:
505-
"""
506-
Success: Translations are up to date.
507-
"""
498+
And STDERR should be empty

features/language-plugin.feature

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -448,38 +448,21 @@ Feature: Manage plugin translation files for a WordPress install
448448
@require-wp-4.0
449449
Scenario: Plugin translation update with format flag
450450
Given a WP install
451-
And a wp-content/plugins/test-plugin/test-plugin.php file:
452-
"""
453-
<?php
454-
/*
455-
Plugin Name: Test Plugin
456-
Version: 1.0.0
457-
*/
458-
"""
459451

460-
When I run `wp plugin activate test-plugin`
452+
When I run `wp plugin install hello-dolly --force`
461453
Then STDERR should be empty
462454

463-
When I run `wp language plugin update test-plugin --format=json`
455+
When I run `wp language plugin update hello-dolly --format=json`
464456
Then STDOUT should be:
465457
"""
466458
[]
467459
"""
468-
And STDERR should contain:
469-
"""
470-
Success: Translations are up to date.
471-
"""
460+
And STDERR should be empty
472461

473462
When I run `wp language plugin update --all --format=csv`
474463
Then STDOUT should be empty
475-
And STDERR should contain:
476-
"""
477-
Success: Translations are up to date.
478-
"""
464+
And STDERR should be empty
479465

480466
When I run `wp language plugin update --all --format=summary`
481467
Then STDOUT should be empty
482-
And STDERR should contain:
483-
"""
484-
Success: Translations are up to date.
485-
"""
468+
And STDERR should be empty

features/language-theme.feature

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -332,37 +332,21 @@ Feature: Manage theme translation files for a WordPress install
332332
@require-wp-4.0
333333
Scenario: Theme translation update with format flag
334334
Given a WP install
335-
And a wp-content/themes/test-theme/style.css file:
336-
"""
337-
/*
338-
Theme Name: Test Theme
339-
Version: 1.0.0
340-
*/
341-
"""
342335

343-
When I run `wp theme activate test-theme`
336+
When I try `wp theme install twentyten`
344337
Then STDERR should be empty
345338

346-
When I run `wp language theme update test-theme --format=json`
339+
When I run `wp language theme update twentyten --format=json`
347340
Then STDOUT should be:
348341
"""
349342
[]
350343
"""
351-
And STDERR should contain:
352-
"""
353-
Success: Translations are up to date.
354-
"""
344+
And STDERR should be empty
355345

356346
When I run `wp language theme update --all --format=csv`
357347
Then STDOUT should be empty
358-
And STDERR should contain:
359-
"""
360-
Success: Translations are up to date.
361-
"""
348+
And STDERR should be empty
362349

363350
When I run `wp language theme update --all --format=summary`
364351
Then STDOUT should be empty
365-
And STDERR should contain:
366-
"""
367-
Success: Translations are up to date.
368-
"""
352+
And STDERR should be empty

src/WP_CLI/CommandWithTranslation.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ public function update( $args, $assoc_args ) {
3333
$format = Utils\get_flag_value( $assoc_args, 'format' );
3434

3535
if ( empty( $updates ) ) {
36-
if ( $format && in_array( $format, array( 'json', 'csv' ), true ) ) {
37-
Utils\format_items( $format, array(), array() );
36+
if ( $format ) {
37+
if ( in_array( $format, array( 'json', 'csv' ), true ) ) {
38+
Utils\format_items( $format, array(), array() );
39+
}
40+
} else {
41+
WP_CLI::success( 'Translations are up to date.' );
3842
}
39-
WP_CLI::success( 'Translations are up to date.' );
4043

4144
return;
4245
}

0 commit comments

Comments
 (0)