Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Xdebug in Behat tests #189

Open
1 task done
BrianHenryIE opened this issue Jun 11, 2024 · 0 comments
Open
1 task done

Enable Xdebug in Behat tests #189

BrianHenryIE opened this issue Jun 11, 2024 · 0 comments

Comments

@BrianHenryIE
Copy link
Member

BrianHenryIE commented Jun 11, 2024

Feature Request

Describe your use case and the problem you are facing

When working with the Behat tests, I'd like to be able to step debug the actual WP CLI + WordPress code which is being run.

Describe the solution you'd like

Add a WP CLI environmental variable to enable Xdebug, which would prepend any WP CLI commands run by Behat with Xdebug environmental variables to enable it.

WP_CLI_TEST_XDEBUG=true composer behat

In wp-cli/wp-cli/php/WP_CLI/Process.php:73 add:

if( getenv( 'WP_CLI_TEST_XDEBUG' ) ) {
  $this->command = "XDEBUG_CONFIG=\"idekey=WP_CLI_TEST_XDEBUG remote_connect_back=1 log_level=0\" XDEBUG_MODE=debug $this->command";
}

Drawbacks:

Definitely slower. And I seem to have to click play often, but maybe that's just a PhpStorm setting I've got wrong.

Alternatives:

Edit every Behat feature to add XDEBUG_CONFIG="idekey=WP_CLI_XDEBUG remote_connect_back=1 log_level=0" XDEBUG_MODE=debug as needed.

I seem to need XDEBUG_SESSION=1 sometimes – I certainly did not need it when I opened the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant