Skip to content

Commit bf304ba

Browse files
Copilotswissspidy
andcommitted
Add dry-run with format flag tests and fix documentation
- Add test scenarios for dry-run combined with format flags (json, csv, summary) for core, plugin, and theme language update commands - Fix documentation to remove misleading "default: table" and clarify actual behavior when no format is specified - When no format is specified, commands show progress messages and success/warning/error messages without formatted table output - This addresses the missing test coverage identified in code review Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 5fd48aa commit bf304ba

6 files changed

Lines changed: 135 additions & 6 deletions

‎features/language-core.feature‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,3 +499,51 @@ Feature: Manage core translation files for a WordPress install
499499
Success: Translations are up to date.
500500
"""
501501
And STDERR should be empty
502+
503+
@require-wp-6.0 @require-php-7.2
504+
Scenario Outline: Core translation update with dry-run and format flag
505+
Given an empty directory
506+
And WP files
507+
And a database
508+
And I run `wp core download --version=<original> --force`
509+
And wp-config.php
510+
And I run `wp core install --url='localhost:8001' --title='Test' --admin_user=wpcli --admin_email=admin@example.com --admin_password=1`
511+
512+
When I run `wp language core install en_CA ja`
513+
Then STDERR should be empty
514+
515+
Given I try `wp core download --version=<update> --force`
516+
Then the return code should be 0
517+
And I run `wp core update-db`
518+
519+
When I run `wp language core list --fields=language,status,update`
520+
Then STDOUT should be a table containing rows:
521+
| language | status | update |
522+
| en_CA | installed | available |
523+
| ja | installed | available |
524+
525+
When I run `wp language core update --dry-run --format=json`
526+
Then STDOUT should be JSON containing:
527+
"""
528+
[{"Type":"Core","Name":"WordPress","Version":"<update>"}]
529+
"""
530+
And STDERR should be empty
531+
532+
When I run `wp language core update --dry-run --format=csv`
533+
Then STDOUT should contain:
534+
"""
535+
Type,Name,Version,Language
536+
"""
537+
And STDOUT should contain:
538+
"""
539+
Core,WordPress,<update>
540+
"""
541+
And STDERR should be empty
542+
543+
When I run `wp language core update --dry-run --format=summary`
544+
Then STDOUT should be empty
545+
And STDERR should be empty
546+
547+
Examples:
548+
| original | update |
549+
| 6.5 | 6.6 |

‎features/language-plugin.feature‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,3 +519,42 @@ Feature: Manage plugin translation files for a WordPress install
519519
Success: Updated 1/1 translation.
520520
"""
521521
And STDERR should be empty
522+
523+
@require-wp-4.0
524+
Scenario: Plugin translation update with dry-run and format flag
525+
Given a WP install
526+
And an empty cache
527+
528+
When I run `wp plugin install akismet --version=3.2 --force`
529+
Then STDERR should be empty
530+
531+
When I run `wp language plugin install akismet de_DE`
532+
Then STDERR should be empty
533+
534+
When I run `wp plugin install akismet --version=4.0 --force`
535+
And I run `wp language plugin list akismet --fields=plugin,language,update,status`
536+
Then STDOUT should be a table containing rows:
537+
| plugin | language | update | status |
538+
| akismet | de_DE | available | installed |
539+
540+
When I run `wp language plugin update akismet --dry-run --format=json`
541+
Then STDOUT should be JSON containing:
542+
"""
543+
[{"Type":"Plugin","Name":"Akismet Anti-spam: Spam Protection"}]
544+
"""
545+
And STDERR should be empty
546+
547+
When I run `wp language plugin update akismet --dry-run --format=csv`
548+
Then STDOUT should contain:
549+
"""
550+
Type,Name,Version,Language
551+
"""
552+
And STDOUT should contain:
553+
"""
554+
Plugin,Akismet Anti-spam: Spam Protection
555+
"""
556+
And STDERR should be empty
557+
558+
When I run `wp language plugin update akismet --dry-run --format=summary`
559+
Then STDOUT should be empty
560+
And STDERR should be empty

‎features/language-theme.feature‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,3 +403,42 @@ Feature: Manage theme translation files for a WordPress install
403403
Success: Updated 1/1 translation.
404404
"""
405405
And STDERR should be empty
406+
407+
@require-wp-4.0
408+
Scenario: Theme translation update with dry-run and format flag
409+
Given a WP install
410+
And an empty cache
411+
412+
When I run `wp theme install twentyfifteen --version=2.0 --force`
413+
Then STDERR should be empty
414+
415+
When I run `wp language theme install twentyfifteen de_DE`
416+
Then STDERR should be empty
417+
418+
When I run `wp theme install twentyfifteen --version=2.5 --force`
419+
And I run `wp language theme list twentyfifteen --fields=theme,language,update,status`
420+
Then STDOUT should be a table containing rows:
421+
| theme | language | update | status |
422+
| twentyfifteen | de_DE | available | installed |
423+
424+
When I run `wp language theme update twentyfifteen --dry-run --format=json`
425+
Then STDOUT should be JSON containing:
426+
"""
427+
[{"Type":"Theme","Name":"Twenty Fifteen"}]
428+
"""
429+
And STDERR should be empty
430+
431+
When I run `wp language theme update twentyfifteen --dry-run --format=csv`
432+
Then STDOUT should contain:
433+
"""
434+
Type,Name,Version,Language
435+
"""
436+
And STDOUT should contain:
437+
"""
438+
Theme,Twenty Fifteen
439+
"""
440+
And STDERR should be empty
441+
442+
When I run `wp language theme update twentyfifteen --dry-run --format=summary`
443+
Then STDOUT should be empty
444+
And STDERR should be empty

‎src/Core_Language_Command.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,10 @@ public function uninstall( $args ) {
340340
* : Preview which translations would be updated.
341341
*
342342
* [--format=<format>]
343-
* : Render output in a particular format.
343+
* : Render output in a particular format. When not specified, updates show
344+
* : progress messages and success/warning/error messages. When specified,
345+
* : the output format changes based on the selected format.
344346
* ---
345-
* default: table
346347
* options:
347348
* - table
348349
* - csv

‎src/Plugin_Language_Command.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,10 @@ public function uninstall( $args, $assoc_args ) {
589589
* : Preview which translations would be updated.
590590
*
591591
* [--format=<format>]
592-
* : Render output in a particular format.
592+
* : Render output in a particular format. When not specified, updates show
593+
* : progress messages and success/warning/error messages. When specified,
594+
* : the output format changes based on the selected format.
593595
* ---
594-
* default: table
595596
* options:
596597
* - table
597598
* - csv

‎src/Theme_Language_Command.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,10 @@ public function uninstall( $args, $assoc_args ) {
608608
* : Preview which translations would be updated.
609609
*
610610
* [--format=<format>]
611-
* : Render output in a particular format.
611+
* : Render output in a particular format. When not specified, updates show
612+
* : progress messages and success/warning/error messages. When specified,
613+
* : the output format changes based on the selected format.
612614
* ---
613-
* default: table
614615
* options:
615616
* - table
616617
* - csv

0 commit comments

Comments
 (0)