|
| 1 | +Feature: Requests integration with both v1 and v2 |
| 2 | + |
| 3 | + Scenario: Composer stack with Requests v1 |
| 4 | + Given an empty directory |
| 5 | + And a composer.json file: |
| 6 | + """ |
| 7 | + { |
| 8 | + "name": "wp-cli/composer-test", |
| 9 | + "type": "project", |
| 10 | + "require": { |
| 11 | + "wp-cli/wp-cli": "2.7.0", |
| 12 | + "wp-cli/core-command": "^2", |
| 13 | + "wp-cli/eval-command": "^2" |
| 14 | + } |
| 15 | + } |
| 16 | + """ |
| 17 | + # Note: Composer outputs messages to stderr. |
| 18 | + And I run `composer install --no-interaction 2>&1` |
| 19 | + |
| 20 | + When I run `vendor/bin/wp cli version` |
| 21 | + Then STDOUT should contain: |
| 22 | + """ |
| 23 | + WP-CLI 2.7.0 |
| 24 | + """ |
| 25 | + |
| 26 | + Given a WP installation |
| 27 | + And I run `vendor/bin/wp core update --version=5.8 --force` |
| 28 | + |
| 29 | + When I run `vendor/bin/wp core version` |
| 30 | + Then STDOUT should contain: |
| 31 | + """ |
| 32 | + 5.8 |
| 33 | + """ |
| 34 | + |
| 35 | + When I run `vendor/bin/wp eval 'var_dump( \WP_CLI\Utils\http_request( "GET", "https://example.com/" ) );'` |
| 36 | + Then STDOUT should contain: |
| 37 | + """ |
| 38 | + object(Requests_Response) |
| 39 | + """ |
| 40 | + And STDOUT should contain: |
| 41 | + """ |
| 42 | + HTTP/1.1 200 OK |
| 43 | + """ |
| 44 | + And STDERR should be empty |
| 45 | + |
| 46 | + Scenario: Current version with WordPress-bundled Requests v1 |
| 47 | + Given a WP installation |
| 48 | + And I run `wp core update --version=5.8 --force` |
| 49 | + |
| 50 | + When I run `wp core version` |
| 51 | + Then STDOUT should contain: |
| 52 | + """ |
| 53 | + 5.8 |
| 54 | + """ |
| 55 | + |
| 56 | + When I run `wp eval 'var_dump( \WP_CLI\Utils\http_request( "GET", "https://example.com/" ) );'` |
| 57 | + Then STDOUT should contain: |
| 58 | + """ |
| 59 | + object(WpOrg\Requests\Response) |
| 60 | + """ |
| 61 | + And STDOUT should contain: |
| 62 | + """ |
| 63 | + HTTP/1.1 200 OK |
| 64 | + """ |
| 65 | + And STDERR should be empty |
| 66 | + |
| 67 | + When I run `wp eval 'var_dump( \WpOrg\Requests\Requests::get( "https://example.com/" ) );'` |
| 68 | + Then STDOUT should contain: |
| 69 | + """ |
| 70 | + object(WpOrg\Requests\Response) |
| 71 | + """ |
| 72 | + And STDOUT should contain: |
| 73 | + """ |
| 74 | + HTTP/1.1 200 OK |
| 75 | + """ |
| 76 | + And STDERR should be empty |
| 77 | + |
| 78 | + When I run `wp eval 'var_dump( \Requests::get( "https://example.com/" ) );'` |
| 79 | + Then STDOUT should contain: |
| 80 | + """ |
| 81 | + object(WpOrg\Requests\Response) |
| 82 | + """ |
| 83 | + And STDOUT should contain: |
| 84 | + """ |
| 85 | + HTTP/1.1 200 OK |
| 86 | + """ |
| 87 | + And STDERR should be empty |
| 88 | + |
| 89 | + Scenario: Current version with WordPress-bundled Requests v2 |
| 90 | + Given a WP installation |
| 91 | + And I run `wp core update --version=6.2 --force` |
| 92 | + |
| 93 | + When I run `wp core version` |
| 94 | + Then STDOUT should contain: |
| 95 | + """ |
| 96 | + 6.2 |
| 97 | + """ |
| 98 | + |
| 99 | + When I run `wp eval 'var_dump( \WP_CLI\Utils\http_request( "GET", "https://example.com/" ) );'` |
| 100 | + Then STDOUT should contain: |
| 101 | + """ |
| 102 | + object(WpOrg\Requests\Response) |
| 103 | + """ |
| 104 | + And STDOUT should contain: |
| 105 | + """ |
| 106 | + HTTP/1.1 200 OK |
| 107 | + """ |
| 108 | + And STDERR should be empty |
| 109 | + |
| 110 | + When I run `wp eval 'var_dump( \WpOrg\Requests\Requests::get( "https://example.com/" ) );'` |
| 111 | + Then STDOUT should contain: |
| 112 | + """ |
| 113 | + object(WpOrg\Requests\Response) |
| 114 | + """ |
| 115 | + And STDOUT should contain: |
| 116 | + """ |
| 117 | + HTTP/1.1 200 OK |
| 118 | + """ |
| 119 | + And STDERR should be empty |
| 120 | + |
| 121 | + # Expect a deprecation warning here. |
| 122 | + When I try `wp eval 'var_dump( \Requests::get( "https://example.com/" ) );'` |
| 123 | + Then STDOUT should contain: |
| 124 | + """ |
| 125 | + object(WpOrg\Requests\Response) |
| 126 | + """ |
| 127 | + And STDOUT should contain: |
| 128 | + """ |
| 129 | + HTTP/1.1 200 OK |
| 130 | + """ |
| 131 | + And STDERR should contain: |
| 132 | + """ |
| 133 | + The PSR-0 `Requests_...` class names in the Requests library are deprecated. |
| 134 | + """ |
0 commit comments