Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Xdebug support in PHPStorm #282

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.phar
composer.lock
vendor
behat.yml
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ cache:
- $HOME/.composer/cache/files

php:
- 5.3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the min version in composer.json is still 5.3, this is invalid

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the composer.json now. Thanks, let me know if it is not the correct way.

- 5.4
- 5.5
- 5.6
- hhvm

matrix:
include:
Expand Down
4 changes: 3 additions & 1 deletion behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
43 changes: 43 additions & 0 deletions features/src/FeatureContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Behat\MinkExtension\Tests;

use Behat\Mink\Exception\ExpectationException;
use Behat\MinkExtension\Context\RawMinkContext;

/**
* Feature context for testing advanced scenarios.
*/
class FeatureContext extends RawMinkContext
{

/**
* @BeforeScenario @MockXdebug
*/
public function setUpXdebugMock()
{
$_SERVER['XDEBUG_CONFIG'] = 'xdebug';
}

/**
* @Then /^I should have the "([^"]*)" cookie with value "([^"]*)"$/
*/
public function iShouldHaveTheCookieWithValue($cookieName, $cookieExpectedValue)
{
$this->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()
);
}
}

}
13 changes: 13 additions & 0 deletions features/xdebug.feature
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 12 additions & 0 deletions src/Behat/MinkExtension/Context/RawMinkContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down