Skip to content

Commit

Permalink
Fix tests for Requests v2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed May 31, 2023
1 parent 620abff commit 476647a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"wp-cli/db-command": "^1.3 || ^2",
"wp-cli/entity-command": "^1.3 || ^2",
"wp-cli/extension-command": "^1.2 || ^2",
"wp-cli/wp-cli-tests": "^3.1.4"
"wp-cli/wp-cli-tests": "^3.2.7"
},
"config": {
"process-timeout": 7200,
Expand Down
6 changes: 3 additions & 3 deletions features/core-check-update.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ Feature: Check for more recent versions
Given a WP install
And I try `wp theme install twentytwenty --activate`

When I run `wp core download --version=4.4 --force`
When I run `wp core download --version=5.8 --force`
Then STDOUT should not be empty

When I run `wp core check-update`
Then STDOUT should be a table containing rows:
| version | update_type | package_url |
| {WP_VERSION-latest} | major | https://downloads.wordpress.org/release/wordpress-{WP_VERSION-latest}.zip |
| {WP_VERSION-4.4-latest} | minor | https://downloads.wordpress.org/release/wordpress-{WP_VERSION-4.4-latest}-partial-0.zip |
| {WP_VERSION-5.8-latest} | minor | https://downloads.wordpress.org/release/wordpress-{WP_VERSION-5.8-latest}-partial-0.zip |

When I run `wp core check-update --format=count`
Then STDOUT should be:
Expand All @@ -33,7 +33,7 @@ Feature: Check for more recent versions
When I run `wp core check-update --minor`
Then STDOUT should be a table containing rows:
| version | update_type | package_url |
| {WP_VERSION-4.4-latest} | minor | https://downloads.wordpress.org/release/wordpress-{WP_VERSION-4.4-latest}-partial-0.zip |
| {WP_VERSION-5.8-latest} | minor | https://downloads.wordpress.org/release/wordpress-{WP_VERSION-5.8-latest}-partial-0.zip |

When I run `wp core check-update --minor --format=count`
Then STDOUT should be:
Expand Down
1 change: 0 additions & 1 deletion features/core-download.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Feature: Download WordPress
And save STDOUT 'Downloading WordPress ([\d\.]+)' as {VERSION}
Then the wp-settings.php file should exist
And the {SUITE_CACHE_DIR}/core/wordpress-{VERSION}-en_US.tar.gz file should exist
And the {SUITE_CACHE_DIR}/core/wordpress-{WP_VERSION-latest}-en_US.tar.gz file should exist

When I run `mkdir inner`
And I run `cd inner && wp core download`
Expand Down
9 changes: 8 additions & 1 deletion features/core-update.feature
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ Feature: Update WordPress core
And I try `wp theme install twentytwenty --activate`

When I run `wp core download --version=4.1.30 --force`
Then STDOUT should not be empty
Then STDOUT should contain:
"""
Success: WordPress downloaded.
"""

# This version of WP throws a PHP notice
When I try `wp core update --minor`
Expand Down Expand Up @@ -260,6 +263,10 @@ Feature: Update WordPress core
Then the wp-includes/Requests/Exception/Transport/Curl.php file should not exist
Then the wp-includes/Requests/Exception/Http/Status502.php file should not exist
Then the wp-includes/Requests/Iri.php file should not exist
And STDOUT should contain:
"""
Success: WordPress updated successfully.
"""

When I run `wp core update --version=5.9-beta1 --force`
Then the wp-includes/Requests/Transport/cURL.php file should not exist
Expand Down
5 changes: 2 additions & 3 deletions src/WP_CLI/Core/CoreUpgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace WP_CLI\Core;

use Exception;
use Requests_Response;
use WP_CLI;
use WP_CLI\Utils;
use WP_Error;
Expand All @@ -27,7 +26,7 @@ class CoreUpgrader extends DefaultCoreUpgrader {
/**
* CoreUpgrader constructor.
*
* @param WP_Upgrader_Skin|null $skin
* @param \WP_Upgrader_Skin|null $skin
*/
public function __construct( $skin = null, $insecure = false ) {
$this->insecure = $insecure;
Expand Down Expand Up @@ -115,7 +114,7 @@ function () use ( $temp ) {

$this->skin->feedback( 'downloading_package', $package );

/** @var Requests_Response|null $req */
/** @var \Requests_Response|\WpOrg\Requests\Response null $req */
try {
$response = Utils\http_request( 'GET', $package, null, $headers, $options );
} catch ( Exception $e ) {
Expand Down

0 comments on commit 476647a

Please sign in to comment.