Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 23 additions & 105 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

133 changes: 133 additions & 0 deletions features/requests.feature
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,136 @@ Feature: Requests integration with both v1 and v2
"""
Success: Installed 1 of 1 plugins.
"""

Scenario: Composer stack with Requests v1 pulling wp-cli/wp-cli-bundle
Given an empty directory
And a composer.json file:
"""
{
"name": "example/wordpress",
"type": "project",
"extra": {
"wordpress-install-dir": "wp",
"installer-paths": {
"content/plugins/{$name}/": [
"type:wordpress-plugin"
],
"content/themes/{$name}/": [
"type:wordpress-theme"
]
}
},
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
}
],
"require": {
"johnpbloch/wordpress": "6.1"
},
"require-dev": {
"wp-cli/wp-cli-bundle": "dev-main as 2.8.1"
},
"minimum-stability": "dev",
"config": {
"allow-plugins": {
"johnpbloch/wordpress-core-installer": true
}
}
}
"""
# Note: Composer outputs messages to stderr.
And I run `composer install --no-interaction 2>&1`
And a wp-cli.yml file:
"""
path: wp
"""
And an extra-config.php file:
"""
require __DIR__ . "/../vendor/autoload.php";
"""
And the {RUN_DIR}/vendor/wp-cli/wp-cli/bundle/rmccue/requests directory should exist
And the {RUN_DIR}/vendor/rmccue/requests directory should not exist

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`
Then STDOUT should be:
"""
Success: Generated 'wp-config.php' file.
"""

When I run `vendor/bin/wp config set WP_DEBUG true --raw`
Then STDOUT should be:
"""
Success: Updated the constant 'WP_DEBUG' in the 'wp-config.php' file with the raw value 'true'.
"""

When I run `vendor/bin/wp config set WP_DEBUG_DISPLAY true --raw`
Then STDOUT should be:
"""
Success: Added the constant 'WP_DEBUG_DISPLAY' to the 'wp-config.php' file with the raw value 'true'.
"""

When I run `vendor/bin/wp db create`
Then STDOUT should be:
"""
Success: Database created.
"""

# This can throw deprecated warnings on PHP 8.1+.
When I try `vendor/bin/wp core install --url=localhost:8181 --title=Composer --admin_user=admin --admin_password=password --admin_email=admin@example.com`
Then STDOUT should contain:
"""
Success: WordPress installed successfully.
"""

When I run `vendor/bin/wp core version`
Then STDOUT should contain:
"""
6.1
"""

# This can throw deprecated warnings on PHP 8.1+.
When I try `vendor/bin/wp eval 'var_dump( \WP_CLI\Utils\http_request( "GET", "https://example.com/" ) );'`
Then STDOUT should contain:
"""
object(Requests_Response)
"""
And STDOUT should contain:
"""
HTTP/1.1 200 OK
"""

# This can throw deprecated warnings on PHP 8.1+.
When I try `vendor/bin/wp plugin install duplicate-post --activate`
Then STDOUT should contain:
"""
Success: Installed 1 of 1 plugins.
"""

And I launch in the background `wp server --host=localhost --port=8181`
And I run `wp option set blogdescription 'Just another Composer-based WordPress site'`

When I run `curl -sS localhost:8181`
Then STDOUT should contain:
"""
Just another Composer-based WordPress site
"""

When I run `vendor/bin/wp eval 'echo COOKIEHASH;'`
And save STDOUT as {COOKIEHASH}
Then STDOUT should not be empty

When I run `vendor/bin/wp eval 'echo wp_generate_auth_cookie( 1, 32503680000 );'`
And save STDOUT as {AUTH_COOKIE}
Then STDOUT should not be empty

When I run `curl -b 'wordpress_{COOKIEHASH}={AUTH_COOKIE}' -sS localhost:8181/wp-admin/plugins.php`
Then STDOUT should contain:
"""
Plugins</h1>
"""
And STDOUT should contain:
"""
plugin=duplicate-post
"""
4 changes: 2 additions & 2 deletions utils/make-phar.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function get_composer_versions( $current_version ) {
->in( WP_CLI_BUNDLE_ROOT . '/php' )
->in( WP_CLI_VENDOR_DIR . '/mustache' )
->in( WP_CLI_VENDOR_DIR . '/eftec/bladeone' )
->in( WP_CLI_VENDOR_DIR . '/rmccue/requests' )
->in( WP_CLI_ROOT . '/bundle/rmccue/requests' )
->in( WP_CLI_VENDOR_DIR . '/composer' )
->in( WP_CLI_VENDOR_DIR . '/symfony' )
->notName( 'behat-tags.php' )
Expand Down Expand Up @@ -290,7 +290,7 @@ function get_composer_versions( $current_version ) {
add_file( $phar, WP_CLI_VENDOR_DIR . '/composer/composer/LICENSE' );
add_file( $phar, WP_CLI_VENDOR_DIR . '/composer/composer/res/composer-schema.json' );
}
add_file( $phar, WP_CLI_VENDOR_DIR . '/rmccue/requests/certificates/cacert.pem' );
add_file( $phar, WP_CLI_ROOT . '/bundle/rmccue/requests/certificates/cacert.pem' );

set_file_contents( $phar, WP_CLI_ROOT . '/COMPOSER_VERSIONS', get_composer_versions( $current_version ) );
set_file_contents( $phar, WP_CLI_ROOT . '/VERSION', $current_version );
Expand Down