diff --git a/.gitignore b/.gitignore index e3897102..55f5feed 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.phar composer.lock vendor +behat.yml diff --git a/.travis.yml b/.travis.yml index f125a612..f90b9142 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,11 +7,9 @@ cache: - $HOME/.composer/cache/files php: - - 5.3 - 5.4 - 5.5 - 5.6 - - hhvm matrix: include: diff --git a/behat.yml.dist b/behat.yml.dist index e0cbd419..ff86d66f 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -2,7 +2,9 @@ default: suites: default: path: %paths.base%/features - contexts: [Behat\MinkExtension\Context\MinkContext] + contexts: + - Behat\MinkExtension\Context\MinkContext + - Behat\MinkExtension\Tests\FeatureContext extensions: Behat\MinkExtension: base_url: http://en.wikipedia.org/ diff --git a/composer.json b/composer.json index 2e721d13..c49551ed 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ ], "require": { - "php": ">=5.3.2", + "php": ">=5.4", "behat/behat": "~3.0,>=3.0.5", "behat/mink": "~1.5", "symfony/config": "~2.2|~3.0" @@ -32,6 +32,12 @@ "psr-0": { "Behat\\MinkExtension": "src/" } }, + "autoload-dev": { + "psr-4": { + "Behat\\MinkExtension\\Tests\\": "features/src" + } + }, + "extra": { "branch-alias": { "dev-master": "2.1.x-dev" diff --git a/features/src/FeatureContext.php b/features/src/FeatureContext.php new file mode 100644 index 00000000..942a2894 --- /dev/null +++ b/features/src/FeatureContext.php @@ -0,0 +1,43 @@ +assertSession()->cookieEquals($cookieName, $cookieExpectedValue); + } + + /** + * @Then /^I should not have the "([^"]*)" cookie$/ + */ + public function iShouldNotHaveTheCookie($cookieName) + { + if ($this->getSession()->getCookie($cookieName)) { + throw new ExpectationException( + 'The cookie with name ' . $cookieName . ' was not found, but it should not be present.', + $this->getSession() + ); + } + } + +} diff --git a/features/xdebug.feature b/features/xdebug.feature new file mode 100644 index 00000000..233988e4 --- /dev/null +++ b/features/xdebug.feature @@ -0,0 +1,13 @@ +Feature: Xdebug + In order to properly develop with BDD + As a feature developer + I need to be able to use my debugger + + Scenario: Xdebug cookie should not be present on normal requests + Given I am on "/wiki/Main_Page" + Then I should not have the "XDEBUG_SESSION" cookie + + @MockXdebug + Scenario: Xdebug cookie should be passed on to requests + Given I am on "/wiki/Main_Page" + Then I should have the "XDEBUG_SESSION" cookie with value "xdebug" diff --git a/src/Behat/MinkExtension/Context/RawMinkContext.php b/src/Behat/MinkExtension/Context/RawMinkContext.php index 8e0a9279..43c58abb 100644 --- a/src/Behat/MinkExtension/Context/RawMinkContext.php +++ b/src/Behat/MinkExtension/Context/RawMinkContext.php @@ -25,6 +25,18 @@ class RawMinkContext implements MinkAwareContext private $mink; private $minkParameters; + /** + * Currently supports PHPSTORM. + * + * @beforeScenario + */ + public function setUpXdebugIfIdeIsConfigured() + { + if (isset($_SERVER['XDEBUG_CONFIG'])) { + $this->getSession()->setCookie('XDEBUG_SESSION', 'xdebug'); + } + } + /** * Sets Mink instance. *