diff --git a/README.md b/README.md index c75adaa57..882e5f657 100644 --- a/README.md +++ b/README.md @@ -437,6 +437,15 @@ chmod +x ~/wp-cli/wp WP_CLI_BIN_DIR=~/wp-cli composer behat ``` +#### Project configuration trust + +WP-CLI asks for confirmation before acting on `require`, `exec`, `env` or `ssh-args` directives found in a project-level `wp-cli.yml` file. Test fixtures create such files all the time and a test run cannot answer an interactive prompt, so the Behat context passes `WP_CLI_TRUST_PROJECT_CONFIG=1` to every command it runs. + +Set the `WP_CLI_TRUST_PROJECT_CONFIG` environment variable yourself to override that default for the whole run. Individual scenarios can override it per command: + +```gherkin +When I try `WP_CLI_TRUST_PROJECT_CONFIG=false wp cli version` + ### Setting up the tests in Travis CI Basic rules for setting up the test framework with Travis CI: diff --git a/src/Context/FeatureContext.php b/src/Context/FeatureContext.php index 4b84f4841..316aa4bc6 100644 --- a/src/Context/FeatureContext.php +++ b/src/Context/FeatureContext.php @@ -546,6 +546,14 @@ private static function get_process_env_variables(): array { } } + // Test fixtures routinely create project-level `wp-cli.yml` files that contain + // `require`, `exec`, `env` or `ssh-args` directives. WP-CLI gates those behind a + // trust confirmation, which cannot be answered in a non-interactive test run, so + // trust them by default. Scenarios that specifically test the trust mechanism can + // still override this by prefixing their command with their own value. + $trust_project_config = getenv( 'WP_CLI_TRUST_PROJECT_CONFIG' ); + $env['WP_CLI_TRUST_PROJECT_CONFIG'] = false !== $trust_project_config ? $trust_project_config : '1'; + $env = array_filter( array_merge( $env, self::get_php_tuning_env_variables() ), static function ( $value ) {