From 6844831b2858367f714c5e5ca48350910abccb74 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 3 Apr 2024 11:21:02 -0600 Subject: [PATCH] that's not how check-updates works, instead return the latest version --- features/steps/given.php | 13 +++++++++---- features/steps/then.php | 1 - 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/features/steps/given.php b/features/steps/given.php index ec80832..9b306d9 100644 --- a/features/steps/given.php +++ b/features/steps/given.php @@ -157,15 +157,20 @@ function($world) { ); $steps->Given('/^the current WP version is not the latest$/', function ($world) { + // Fetch the latest WordPress version info from the WordPress.org API + $url = 'https://api.wordpress.org/core/version-check/1.7/'; + $json = file_get_contents($url); + $data = json_decode($json, true); + + // Extract the latest version number + $latestVersion = $data['offers'][0]['current']; + // Use wp-cli to get the currently installed WordPress version. $currentVersion = $world->proc('wp core version')->run(); - // Use wp-cli to get the latest WordPress version available. - $latestVersion = $world->proc('wp core check-update --field=version')->run(); - // Normalize versions (remove new lines). $currentVersion = trim($currentVersion->stdout); - $latestVersion = trim($latestVersion->stdout); + $latestVersion = trim($latestVersion); // If there's no update available or the current version is the latest, throw an exception to skip the test. if (empty($latestVersion) || $currentVersion === $latestVersion) { diff --git a/features/steps/then.php b/features/steps/then.php index b6712e5..5551519 100644 --- a/features/steps/then.php +++ b/features/steps/then.php @@ -13,7 +13,6 @@ function ( $world, $return_code ) { $steps->Then( '/^(STDOUT|STDERR) should (be|contain|not contain):$/', function ( $world, $stream, $action, PyStringNode $expected ) { - // Conditional handling of WP version check. if (isset($world->isLatestWPVersion) && $world->isLatestWPVersion) { return;