From 22330d02cb9107dacd1b71a8f60bfefe7d2d6536 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 18 Dec 2013 14:57:37 +0100 Subject: [PATCH] Env var support, documented xdebug usage --- README.md | 20 +++++++++++++++++++ .../Context/SilverStripeContext.php | 12 ++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 54514ea..4f11337 100644 --- a/README.md +++ b/README.md @@ -338,6 +338,26 @@ where `10000` is the number of millisecods you wish the session to wait. It is very useful when you want to look at the error or developer console inside the browser or if you want to interact with the session page manually. +### Can I set breakpoints through XDebug? + +If you have [XDebug](http://xdebug.org) set up, breakpoints are your friend. +The problem is that you can only connect the debugger to the PHP execution +in the CLI, or in the browser, not both at the same time. + +First of all, ensure that `xdebug.remote_autostart` is set to `Off`, +otherwise you'll always have an active debugging session in CLI, never in the browser. + +Then you can choose to enable XDebug for the current CLI run: + + XDEBUG_CONFIG="idekey=macgdbp" vendor/bin/behat + +Or you can use the `TESTSESSION_PARAMS` environment variable to pass additional +parameters to `dev/testsession/start`, and debug in the browser instead. + + TESTSESSION_PARAMS="XDEBUG_SESSION_START=macgdbp" vendor/bin/behat @app + +The `macgdbp` IDE key needs to match your `xdebug.idekey` php.ini setting. + ### How do I use SauceLabs.com for remote Selenium2 testing? Here's a sample profile for your `behat.yml`: diff --git a/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php b/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php index 38319db..32ed1be 100644 --- a/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php +++ b/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php @@ -161,13 +161,19 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex /** * Returns a parameter map of state to set within the test session. + * Takes TESTSESSION_PARAMS environment variable into account for run-specific configurations. * * @return array */ public function getTestSessionState() { - return array( - 'database' => $this->databaseName, - 'mailer' => 'SilverStripe\BehatExtension\Utility\TestMailer', + $extraParams = array(); + parse_str(getenv('TESTSESSION_PARAMS'), $extraParams); + return array_merge( + array( + 'database' => $this->databaseName, + 'mailer' => 'SilverStripe\BehatExtension\Utility\TestMailer', + ), + $extraParams ); }