Skip to content

Commit bca70d7

Browse files
authored
Merge pull request #552 from wp-cli/fix/wp-cli-bundle-composer-fatal
2 parents 412e98d + d4cea11 commit bca70d7

File tree

3 files changed

+152
-101
lines changed

3 files changed

+152
-101
lines changed

composer.lock

Lines changed: 17 additions & 99 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

features/requests.feature

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,136 @@ Feature: Requests integration with both v1 and v2
9696
"""
9797
Success: Installed 1 of 1 plugins.
9898
"""
99+
100+
Scenario: Composer stack with Requests v1 pulling wp-cli/wp-cli-bundle
101+
Given an empty directory
102+
And a composer.json file:
103+
"""
104+
{
105+
"name": "example/wordpress",
106+
"type": "project",
107+
"extra": {
108+
"wordpress-install-dir": "wp",
109+
"installer-paths": {
110+
"content/plugins/{$name}/": [
111+
"type:wordpress-plugin"
112+
],
113+
"content/themes/{$name}/": [
114+
"type:wordpress-theme"
115+
]
116+
}
117+
},
118+
"repositories": [
119+
{
120+
"type": "composer",
121+
"url": "https://wpackagist.org"
122+
}
123+
],
124+
"require": {
125+
"johnpbloch/wordpress": "6.1"
126+
},
127+
"require-dev": {
128+
"wp-cli/wp-cli-bundle": "dev-main as 2.8.1"
129+
},
130+
"minimum-stability": "dev",
131+
"config": {
132+
"allow-plugins": {
133+
"johnpbloch/wordpress-core-installer": true
134+
}
135+
}
136+
}
137+
"""
138+
# Note: Composer outputs messages to stderr.
139+
And I run `composer install --no-interaction 2>&1`
140+
And a wp-cli.yml file:
141+
"""
142+
path: wp
143+
"""
144+
And an extra-config.php file:
145+
"""
146+
require __DIR__ . "/../vendor/autoload.php";
147+
"""
148+
And the {RUN_DIR}/vendor/wp-cli/wp-cli/bundle/rmccue/requests directory should exist
149+
And the {RUN_DIR}/vendor/rmccue/requests directory should not exist
150+
151+
When I run `vendor/bin/wp config create --dbname={DB_NAME} --dbuser={DB_USER} --dbpass={DB_PASSWORD} --dbhost={DB_HOST} --extra-php < extra-config.php`
152+
Then STDOUT should be:
153+
"""
154+
Success: Generated 'wp-config.php' file.
155+
"""
156+
157+
When I run `vendor/bin/wp config set WP_DEBUG true --raw`
158+
Then STDOUT should be:
159+
"""
160+
Success: Updated the constant 'WP_DEBUG' in the 'wp-config.php' file with the raw value 'true'.
161+
"""
162+
163+
When I run `vendor/bin/wp config set WP_DEBUG_DISPLAY true --raw`
164+
Then STDOUT should be:
165+
"""
166+
Success: Added the constant 'WP_DEBUG_DISPLAY' to the 'wp-config.php' file with the raw value 'true'.
167+
"""
168+
169+
When I run `vendor/bin/wp db create`
170+
Then STDOUT should be:
171+
"""
172+
Success: Database created.
173+
"""
174+
175+
# This can throw deprecated warnings on PHP 8.1+.
176+
When I try `vendor/bin/wp core install --url=localhost:8181 --title=Composer --admin_user=admin --admin_password=password [email protected]`
177+
Then STDOUT should contain:
178+
"""
179+
Success: WordPress installed successfully.
180+
"""
181+
182+
When I run `vendor/bin/wp core version`
183+
Then STDOUT should contain:
184+
"""
185+
6.1
186+
"""
187+
188+
# This can throw deprecated warnings on PHP 8.1+.
189+
When I try `vendor/bin/wp eval 'var_dump( \WP_CLI\Utils\http_request( "GET", "https://example.com/" ) );'`
190+
Then STDOUT should contain:
191+
"""
192+
object(Requests_Response)
193+
"""
194+
And STDOUT should contain:
195+
"""
196+
HTTP/1.1 200 OK
197+
"""
198+
199+
# This can throw deprecated warnings on PHP 8.1+.
200+
When I try `vendor/bin/wp plugin install duplicate-post --activate`
201+
Then STDOUT should contain:
202+
"""
203+
Success: Installed 1 of 1 plugins.
204+
"""
205+
206+
And I launch in the background `wp server --host=localhost --port=8181`
207+
And I run `wp option set blogdescription 'Just another Composer-based WordPress site'`
208+
209+
When I run `curl -sS localhost:8181`
210+
Then STDOUT should contain:
211+
"""
212+
Just another Composer-based WordPress site
213+
"""
214+
215+
When I run `vendor/bin/wp eval 'echo COOKIEHASH;'`
216+
And save STDOUT as {COOKIEHASH}
217+
Then STDOUT should not be empty
218+
219+
When I run `vendor/bin/wp eval 'echo wp_generate_auth_cookie( 1, 32503680000 );'`
220+
And save STDOUT as {AUTH_COOKIE}
221+
Then STDOUT should not be empty
222+
223+
When I run `curl -b 'wordpress_{COOKIEHASH}={AUTH_COOKIE}' -sS localhost:8181/wp-admin/plugins.php`
224+
Then STDOUT should contain:
225+
"""
226+
Plugins</h1>
227+
"""
228+
And STDOUT should contain:
229+
"""
230+
plugin=duplicate-post
231+
"""

utils/make-phar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ function get_composer_versions( $current_version ) {
190190
->in( WP_CLI_BUNDLE_ROOT . '/php' )
191191
->in( WP_CLI_VENDOR_DIR . '/mustache' )
192192
->in( WP_CLI_VENDOR_DIR . '/eftec/bladeone' )
193-
->in( WP_CLI_VENDOR_DIR . '/rmccue/requests' )
193+
->in( WP_CLI_ROOT . '/bundle/rmccue/requests' )
194194
->in( WP_CLI_VENDOR_DIR . '/composer' )
195195
->in( WP_CLI_VENDOR_DIR . '/symfony' )
196196
->notName( 'behat-tags.php' )
@@ -290,7 +290,7 @@ function get_composer_versions( $current_version ) {
290290
add_file( $phar, WP_CLI_VENDOR_DIR . '/composer/composer/LICENSE' );
291291
add_file( $phar, WP_CLI_VENDOR_DIR . '/composer/composer/res/composer-schema.json' );
292292
}
293-
add_file( $phar, WP_CLI_VENDOR_DIR . '/rmccue/requests/certificates/cacert.pem' );
293+
add_file( $phar, WP_CLI_ROOT . '/bundle/rmccue/requests/certificates/cacert.pem' );
294294

295295
set_file_contents( $phar, WP_CLI_ROOT . '/COMPOSER_VERSIONS', get_composer_versions( $current_version ) );
296296
set_file_contents( $phar, WP_CLI_ROOT . '/VERSION', $current_version );

0 commit comments

Comments
 (0)