File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -42,3 +42,37 @@ Feature: Check for more recent versions
4242 """
4343 1
4444 """
45+
46+ Scenario : Check output of check update in different formats (no updates available)
47+ Given a WP install
48+ And a setup.php file:
49+ """
50+ <?php
51+ global $wp_version;
52+
53+ $obj = new stdClass;
54+ $obj->updates = [];
55+ $obj->last_checked = strtotime( '1 January 2099' );
56+ $obj->version_checked = $wp_version;
57+ $obj->translations = [];
58+ set_site_transient( 'update_core', $obj );
59+ """
60+ And I run `wp eval-file setup.php`
61+
62+ When I run `wp core check-update`
63+ Then STDOUT should be:
64+ """
65+ Success: WordPress is at the latest version.
66+ """
67+
68+ When I run `wp core check-update --format=json`
69+ Then STDOUT should be:
70+ """
71+ []
72+ """
73+
74+ When I run `wp core check-update --format=yaml`
75+ Then STDOUT should be:
76+ """
77+ ---
78+ """
Original file line number Diff line number Diff line change @@ -77,16 +77,18 @@ class Core_Command extends WP_CLI_Command {
7777 * @subcommand check-update
7878 */
7979 public function check_update ( $ _ , $ assoc_args ) {
80+ $ format = Utils \get_flag_value ( $ assoc_args , 'format ' , 'table ' );
8081
8182 $ updates = $ this ->get_updates ( $ assoc_args );
82- if ( $ updates ) {
83+
84+ if ( $ updates || 'table ' !== $ format ) {
8385 $ updates = array_reverse ( $ updates );
8486 $ formatter = new Formatter (
8587 $ assoc_args ,
8688 [ 'version ' , 'update_type ' , 'package_url ' ]
8789 );
8890 $ formatter ->display_items ( $ updates );
89- } elseif ( empty ( $ assoc_args [ ' format ' ] ) || ' table ' === $ assoc_args [ ' format ' ] ) {
91+ } else {
9092 WP_CLI ::success ( 'WordPress is at the latest version. ' );
9193 }
9294 }
You can’t perform that action at this time.
0 commit comments