Feature: Have a config file Scenario: No config file Given a WP installation When I run `wp --info` Then STDOUT should not contain: """ wp-cli.yml """ When I run `wp core is-installed` from 'wp-content' Then STDOUT should be empty Scenario: Config file in WP Root Given a WP installation And a sample.php file: """ """ Scenario: WP in a subdirectory Given a WP installation in 'foo' And a wp-cli.yml file: """ path: foo """ When I run `wp --info` Then STDOUT should contain: """ wp-cli.yml """ When I run `wp core is-installed` Then STDOUT should be empty When I run `wp core is-installed` from 'foo/wp-content' Then STDOUT should be empty When I run `mkdir -p other/subdir` And I run `wp core is-installed` from 'other/subdir' Then STDOUT should be empty Scenario: WP in a subdirectory (autodetected) Given a WP installation in 'foo' Given an index.php file: """ require('./foo/wp-blog-header.php'); """ When I run `wp core is-installed` Then STDOUT should be empty Given an index.php file: """ require dirname(__FILE__) . '/foo/wp-blog-header.php'; """ When I run `wp core is-installed` Then STDOUT should be empty When I run `mkdir -p other/subdir` And I run `echo ' other/subdir/index.php` And I run `wp core is-installed` from 'other/subdir' Then STDOUT should be empty Scenario: Nested installations Given a WP installation And a WP installation in 'foo' And a wp-cli.yml file: """ """ When I run `wp --info` from 'foo' Then STDOUT should not contain: """ wp-cli.yml """ Scenario: Disabled commands Given a WP installation And a config.yml file: """ disabled_commands: - eval-file - core multisite-convert """ # TODO: Throwing deprecations with PHP 8.1+ and WP < 5.9 When I try `WP_CLI_CONFIG_PATH=config.yml wp` Then STDOUT should not contain: """ eval-file """ When I try `WP_CLI_CONFIG_PATH=config.yml wp help eval-file` Then STDERR should contain: """ Error: The 'eval-file' command has been disabled from the config file. """ # TODO: Throwing deprecations with PHP 8.1+ and WP < 5.9 When I try `WP_CLI_CONFIG_PATH=config.yml wp core` Then STDOUT should not contain: """ or: wp core multisite-convert """ # TODO: Throwing deprecations with PHP 8.1+ and WP < 5.9 When I try `WP_CLI_CONFIG_PATH=config.yml wp help core` Then STDOUT should not contain: """ multisite-convert """ When I try `WP_CLI_CONFIG_PATH=config.yml wp core multisite-convert` Then STDERR should contain: """ command has been disabled """ When I try `WP_CLI_CONFIG_PATH=config.yml wp help core multisite-convert` Then STDERR should contain: """ Error: The 'core multisite-convert' command has been disabled from the config file. """ Scenario: 'core config' parameters Given an empty directory And WP files And a wp-cli.yml file: """ core config: dbname: wordpress dbuser: root extra-php: | define( 'WP_DEBUG', true ); define( 'WP_POST_REVISIONS', 50 ); """ When I run `wp core config --skip-check` And I run `grep WP_POST_REVISIONS wp-config.php` Then STDOUT should not be empty Scenario: Persist positional parameters when defined in a config Given a WP installation And a wp-cli.yml file: """ user create: - examplejoe - joe@example.com user_pass: joe role: administrator """ When I run `wp user create` Then STDOUT should not be empty When I run `wp user get examplejoe --field=roles` Then STDOUT should contain: """ administrator """ When I try `wp user create examplejane` Then STDERR should be: """ Error: Sorry, that email address is already used! """ When I run `wp user create examplejane jane@example.com` Then STDOUT should not be empty When I run `wp user get examplejane --field=roles` Then STDOUT should contain: """ administrator """ Scenario: Command-specific configs Given a WP installation And a wp-cli.yml file: """ eval: foo: bar post list: format: count """ # Arbitrary values should be passed, without warnings When I run `wp eval 'echo json_encode( $assoc_args );'` Then STDOUT should be JSON containing: """ {"foo": "bar"} """ # CLI args should trump config values When I run `wp post list` Then STDOUT should be a number When I run `wp post list --format=json` Then STDOUT should not be a number Scenario: Required files should not be loaded twice Given an empty directory And a custom-file.php file: """ 'before_wp_load' ) ); """ And a config.yml file: """ test-cmd: foo: bar apple: banana apple: banana """ And a wp-cli.yml file: """ _: merge: true test-cmd: bar: burrito apple: apple apple: apple """ When I run `wp --require=test-cmd.php test-cmd` Then STDOUT should be JSON containing: """ {"bar":"burrito","apple":"apple"} """ When I run `WP_CLI_CONFIG_PATH=config.yml wp --require=test-cmd.php test-cmd` Then STDOUT should be JSON containing: """ {"foo":"bar","apple":"apple","bar":"burrito"} """ Given a wp-cli.yml file: """ _: merge: false test-cmd: bar: burrito apple: apple apple: apple """ When I run `WP_CLI_CONFIG_PATH=config.yml wp --require=test-cmd.php test-cmd` Then STDOUT should be JSON containing: """ {"bar":"burrito","apple":"apple"} """ Scenario: Config inheritance from local to project Given an empty directory And a test-cmd.php file: """ 'before_wp_load' ) ); """ And a wp-cli.yml file: """ test-cmd: foo: bar apple: banana apple: banana """ When I run `wp --require=test-cmd.php test-cmd` Then STDOUT should be JSON containing: """ {"foo":"bar","apple":"banana"} """ Given a wp-cli.local.yml file: """ _: inherit: wp-cli.yml merge: true test-cmd: bar: burrito apple: apple apple: apple """ When I run `wp --require=test-cmd.php test-cmd` Then STDOUT should be JSON containing: """ {"foo":"bar","apple":"apple","bar":"burrito"} """ Given a wp-cli.local.yml file: """ test-cmd: bar: burrito apple: apple apple: apple """ When I run `wp --require=test-cmd.php test-cmd` Then STDOUT should be JSON containing: """ {"bar":"burrito","apple":"apple"} """ @require-wp-3.9 Scenario: WordPress installation with local dev DOMAIN_CURRENT_SITE Given a WP multisite installation And a local-dev.php file: """ ` to override. """ When I run `wp option get home --url=example.com` Then STDOUT should be: """ https://example.com """ Scenario: BOM found in wp-config.php file Given a WP installation And a wp-config.php file: """