Skip to content
Draft
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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,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:
Expand Down
8 changes: 8 additions & 0 deletions src/Context/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,14 @@ private static function get_process_env_variables(): array {
$env['WP_CLI_REQUIRE'] = $updated;
}

// 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';

$config_path = getenv( 'WP_CLI_CONFIG_PATH' );
if ( false !== $config_path ) {
$env['WP_CLI_CONFIG_PATH'] = $config_path;
Expand Down
Loading