Skip to content
This repository was archived by the owner on Mar 20, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 6 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
*.phar
composer.lock
vendor
.idea
Copy link
Member

Choose a reason for hiding this comment

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

this one must be removed. It is specific to your system, not to the project, so it should not be added in the project-level ignore rules. See https://help.github.com/articles/ignoring-files/ to know how to ignore it on your system

behat.yml
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
80 changes: 44 additions & 36 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,48 @@
{
"name": "behat/mink-extension",
"type": "behat-extension",
"description": "Mink extension for Behat",
"keywords": ["web", "test", "browser", "gui"],
"homepage": "http://extensions.behat.org/mink",
"license": "MIT",
"authors": [
{
"name": "Konstantin Kudryashov",
"email": "ever.zet@gmail.com"
},
{
"name": "Christophe Coevoet",
"email": "stof@notk.org"
}
],

"require": {
"php": ">=5.3.2",
"behat/behat": "~3.0,>=3.0.5",
"behat/mink": "~1.5",
"symfony/config": "~2.2|~3.0"
"name": "behat/mink-extension",
Copy link
Member

Choose a reason for hiding this comment

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

please don't change the indentation of the file

"type": "behat-extension",
"description": "Mink extension for Behat",
"keywords": [
"web",
"test",
"browser",
"gui"
],
"homepage": "http://extensions.behat.org/mink",
"license": "MIT",
"authors": [
{
"name": "Konstantin Kudryashov",
"email": "ever.zet@gmail.com"
},

"require-dev": {
"phpspec/phpspec": "~2.0",
"behat/mink-goutte-driver": "~1.1"
},

"autoload": {
"psr-0": { "Behat\\MinkExtension": "src/" }
},

"extra": {
"branch-alias": {
"dev-master": "2.1.x-dev"
}
{
"name": "Christophe Coevoet",
"email": "stof@notk.org"
}
],
"require": {
"php": ">=5.3.2",
"behat/behat": "~3.0,>=3.0.5",
"behat/mink": "~1.5",
"symfony/config": "~2.2|~3.0"
},
"require-dev": {
"phpspec/phpspec": "~2.0",
"behat/mink-goutte-driver": "~1.1"
},
"autoload": {
"psr-0": {
"Behat\\MinkExtension": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Behat\\MinkExtension\\Tests\\": "features/src"
}
},
"extra": {
"branch-alias": {
"dev-master": "2.1.x-dev"
}
}
}
4 changes: 2 additions & 2 deletions features/search.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Feature: Search
I need to be able to search for a word

Scenario: Searching for a page that does exist
Given I am on "/wiki/Main_Page"
Given I am on "http://en.wikipedia.org/wiki/Main_Page"

Choose a reason for hiding this comment

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

When I fill in "search" with "Behavior Driven Development"
And I press "searchButton"
Then I should see "agile software development"

Scenario: Searching for a page that does NOT exist
Given I am on "/wiki/Main_Page"
Given I am on "http://en.wikipedia.org/wiki/Main_Page"
When I fill in "search" with "Glory Driven Development"
And I press "searchButton"
Then I should see "Search results"
54 changes: 54 additions & 0 deletions features/src/FeatureContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?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($cookie_name, $cookie_expected_value) {
Copy link
Member

Choose a reason for hiding this comment

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

please respect our coding standards. We use PSR-2, so variable names are camelCased, and the curly brace should go on the next line (as done for the previous method)

if ($cookie_real_value = $this->getSession()->getCookie($cookie_name)) {
if ($cookie_real_value !== $cookie_expected_value) {
throw new ExpectationException(
'The cookie with name ' . $cookie_name . ' was found, but does not contain ' . $cookie_real_value . ', yet it contains ' . $cookie_expected_value . '.',
$this->getSession()
Copy link
Member

Choose a reason for hiding this comment

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

passing the session in the constructor is deprecated. Please use the new API.

Btw, you could use the Mink assertion API for this: $this->assertSession()->cookieEquals(...) instead of duplicating its logic

);
}
} else {
throw new ExpectationException(
'The cookie with name ' . $cookie_name . ' was not found',
$this->getSession()
);
}
}

/**
* @Then /^I should not have the "([^"]*)" cookie$/
*/
public function iShouldNotHaveTheCookie($cookie_name)
{
if ($cookie_real_value = $this->getSession()->getCookie($cookie_name)) {
throw new ExpectationException(
'The cookie with name ' . $cookie_name . ' 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 "http://en.wikipedia.org/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 "http://en.wikipedia.org/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