added addtional documents, added examples to all step definitions for additional clarity when running 'behat -di' or 'behat -dl'

This commit is contained in:
Sajjad Hossain
2015-06-01 12:39:30 -04:00
parent ee050d39c8
commit 1d12b01eeb

View File

@@ -22,7 +22,10 @@ use Behat\Gherkin\Node\TableNode;
class MinkContext extends RawMinkContext implements TranslatableContext
{
/**
* Opens homepage.
* Opens homepage
* Example: Given I am on "/"
* Example: When I go to "/"
* Example: And I go to "/"
*
* @Given /^(?:|I )am on (?:|the )homepage$/
* @When /^(?:|I )go to (?:|the )homepage$/
@@ -33,7 +36,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Opens specified page.
* Opens specified page
* Example: Given I am on "http://batman.com"
* Example: When I am on "http://batman.com"
* Example: And I go to "http://batman.com"
*
* @Given /^(?:|I )am on "(?P<page>[^"]+)"$/
* @When /^(?:|I )go to "(?P<page>[^"]+)"$/
@@ -44,7 +50,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Reloads current page.
* Reloads current page
* Example: Given I reload the page
* Example: When I reload the page
* Example: And I reload the page
*
* @When /^(?:|I )reload the page$/
*/
@@ -54,7 +63,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Moves backward one page in history.
* Moves backward one page in history
* Example: Given I move backward one page
* Example: When I move backward one page
* Example: And I move backward one page
*
* @When /^(?:|I )move backward one page$/
*/
@@ -65,6 +77,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
/**
* Moves forward one page in history
* Example: Given I move forward one page
* Example: When I move forward one page
* Example: And I move forward one page
*
* @When /^(?:|I )move forward one page$/
*/
@@ -74,7 +89,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Presses button with specified id|name|title|alt|value.
* Presses button with specified id|name|title|alt|value
* Example: Given I press "Log In"
* Example: When I press "Log In"
* Example: And I press "Log In"
*
* @When /^(?:|I )press "(?P<button>(?:[^"]|\\")*)"$/
*/
@@ -85,7 +103,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Clicks link with specified id|title|alt|text.
* Clicks link with specified id|title|alt|text
* Example: Given I follow "Log In"
* Example: When I follow "Log In"
* Example: And I follow "Log In"
*
* @When /^(?:|I )follow "(?P<link>(?:[^"]|\\")*)"$/
*/
@@ -96,7 +117,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Fills in form field with specified id|name|label|value.
* Fills in form field with specified id|name|label|value
* Example: Given I fill in "username" with: "bwayne"
* Example: When I fill in "username" with: "bwayne"
* Example: And I fill in "bwayne" for "username"
*
* @When /^(?:|I )fill in "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)"$/
* @When /^(?:|I )fill in "(?P<field>(?:[^"]|\\")*)" with:$/
@@ -110,7 +134,16 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Fills in form fields with provided table.
* Fills in form fields with provided table
* Example: Given I fill in the following"
* | username | bruceWayne |
* | password | iLoveBats123 |
* Example: When I fill in the following"
* | username | bruceWayne |
* | password | iLoveBats123 |
* Example: And I fill in the following"
* | username | bruceWayne |
* | password | iLoveBats123 |
*
* @When /^(?:|I )fill in the following:$/
*/
@@ -122,7 +155,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Selects option in select field with specified id|name|label|value.
* Selects option in select field with specified id|name|label|value
* Example: Given I select "Bats" from "user_fears"
* Example: When I select "Bats" from "user_fears"
* Example: And I select "Bats" from "user_fears"
*
* @When /^(?:|I )select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/
*/
@@ -134,7 +170,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Selects additional option in select field with specified id|name|label|value.
* Selects additional option in select field with specified id|name|label|value
* Example: Given I additionally select "Deceased" from "parents_alive_status"
* Example: When I additionally select "Deceased" from "parents_alive_status"
* Example: And I additionally select "Deceased" from "parents_alive_status"
*
* @When /^(?:|I )additionally select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/
*/
@@ -146,7 +185,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks checkbox with specified id|name|label|value.
* Checks checkbox with specified id|name|label|value
* Example: Given I check "Pearl Necklace" from "itemsClaimed"
* Example: When I check "Pearl Necklace" from "itemsClaimed"
* Example: And I check "Pearl Necklace" from "itemsClaimed"
*
* @When /^(?:|I )check "(?P<option>(?:[^"]|\\")*)"$/
*/
@@ -157,7 +199,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Unchecks checkbox with specified id|name|label|value.
* Unchecks checkbox with specified id|name|label|value
* Example: Given I uncheck "Broadway Plays" from "hobbies"
* Example: When I uncheck "Broadway Plays" from "hobbies"
* Example: And I uncheck "Broadway Plays" from "hobbies"
*
* @When /^(?:|I )uncheck "(?P<option>(?:[^"]|\\")*)"$/
*/
@@ -168,7 +213,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Attaches file to field with specified id|name|label|value.
* Attaches file to field with specified id|name|label|value
* Example: Given I attach "bwayne_profile.png" to "profileImageUpload"
* Example: When I attach "bwayne_profile.png" to "profileImageUpload"
* Example: And I attach "bwayne_profile.png" to "profileImageUpload"
*
* @When /^(?:|I )attach the file "(?P<path>[^"]*)" to "(?P<field>(?:[^"]|\\")*)"$/
*/
@@ -187,7 +235,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that current page PATH is equal to specified.
* Checks, that current page PATH is equal to specified
* Example: Then I should be on "/"
* Example: And I should be on "/bats"
* Example: And I should be on "http://google.com"
*
* @Then /^(?:|I )should be on "(?P<page>[^"]+)"$/
*/
@@ -197,7 +248,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that current page is the homepage.
* Checks, that current page is the homepage
* Example: Then I should be on the homepage
* Example: And I should be on the homepage
*
* @Then /^(?:|I )should be on (?:|the )homepage$/
*/
@@ -207,7 +260,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that current page PATH matches regular expression.
* Checks, that current page PATH matches regular expression
* Example: Then the url should match "superman is dead"
* Example: Then the uri should match "log in"
* Example: And the url should match "log in"
*
* @Then /^the (?i)url(?-i) should match (?P<pattern>"(?:[^"]|\\")*")$/
*/
@@ -217,7 +273,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that current page response status is equal to specified.
* Checks, that current page response status is equal to specified
* Example: Then the response status code should be 200
* Example: And the response status code should be 400
*
* @Then /^the response status code should be (?P<code>\d+)$/
*/
@@ -227,7 +285,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that current page response status is not equal to specified.
* Checks, that current page response status is not equal to specified
* Example: Then the response status code should not be 501
* Example: And the response status code should not be 404
*
* @Then /^the response status code should not be (?P<code>\d+)$/
*/
@@ -237,7 +297,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that page contains specified text.
* Checks, that page contains specified text
* Example: Then I should see "Who is the Batman?"
* Example: And I should see "Who is the Batman?"
*
* @Then /^(?:|I )should see "(?P<text>(?:[^"]|\\")*)"$/
*/
@@ -247,7 +309,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that page doesn't contain specified text.
* Checks, that page doesn't contain specified text
* Example: Then I should not see "Batman is Bruce Wayne"
* Example: And I should not see "Batman is Bruce Wayne"
*
* @Then /^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)"$/
*/
@@ -257,7 +321,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that page contains text matching specified pattern.
* Checks, that page contains text matching specified pattern
* Example: Then I should see text matching "Batman, the vigilante"
* Example: And I should not see "Batman, the vigilante"
*
* @Then /^(?:|I )should see text matching (?P<pattern>"(?:[^"]|\\")*")$/
*/
@@ -267,7 +333,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that page doesn't contain text matching specified pattern.
* Checks, that page doesn't contain text matching specified pattern
* Example: Then I should see text matching "Bruce Wayne, the vigilante"
* Example: And I should not see "Bruce Wayne, the vigilante"
*
* @Then /^(?:|I )should not see text matching (?P<pattern>"(?:[^"]|\\")*")$/
*/
@@ -277,7 +345,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that HTML response contains specified string.
* Checks, that HTML response contains specified string
* Example: Then the response should contain "Batman is the hero Gotham deserves."
* Example: And the response should contain "Batman is the hero Gotham deserves."
*
* @Then /^the response should contain "(?P<text>(?:[^"]|\\")*)"$/
*/
@@ -287,7 +357,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that HTML response doesn't contain specified string.
* Checks, that HTML response doesn't contain specified string
* Example: Then the response should not contain "Bruce Wayne is a billionaire, play-boy, vigilante."
* Example: And the response should not contain "Bruce Wayne is a billionaire, play-boy, vigilante."
*
* @Then /^the response should not contain "(?P<text>(?:[^"]|\\")*)"$/
*/
@@ -297,7 +369,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that element with specified CSS contains specified text.
* Checks, that element with specified CSS contains specified text
* Example: Then I should see "Batman" in the "heroes_list" element
* Example: And I should see "Batman" in the "heroes_list" element
*
* @Then /^(?:|I )should see "(?P<text>(?:[^"]|\\")*)" in the "(?P<element>[^"]*)" element$/
*/
@@ -307,7 +381,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that element with specified CSS doesn't contain specified text.
* Checks, that element with specified CSS doesn't contain specified text
* Example: Then I should not see "Bruce Wayne" in the "heroes_alter_egos" element
* Example: And I should not see "Bruce Wayne" in the "heroes_alter_egos" element
*
* @Then /^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)" in the "(?P<element>[^"]*)" element$/
*/
@@ -317,7 +393,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that element with specified CSS contains specified HTML.
* Checks, that element with specified CSS contains specified HTML
* Example: Then the "body" element should contain "style=\"color:black;\""
* Example: And the "body" element should contain "style=\"color:black;\""
*
* @Then /^the "(?P<element>[^"]*)" element should contain "(?P<value>(?:[^"]|\\")*)"$/
*/
@@ -327,7 +405,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that element with specified CSS doesn't contain specified HTML.
* Checks, that element with specified CSS doesn't contain specified HTML
* Example: Then the "body" element should not contain "style=\"color:black;\""
* Example: And the "body" element should not contain "style=\"color:black;\""
*
* @Then /^the "(?P<element>[^"]*)" element should not contain "(?P<value>(?:[^"]|\\")*)"$/
*/
@@ -337,7 +417,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that element with specified CSS exists on page.
* Checks, that element with specified CSS exists on page
* Example: Then I should see a "body" element
* Example: And I should see a "body" element
*
* @Then /^(?:|I )should see an? "(?P<element>[^"]*)" element$/
*/
@@ -347,7 +429,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that element with specified CSS doesn't exist on page.
* Checks, that element with specified CSS doesn't exist on page
* Example: Then I should not see a "canvas" element
* Example: And I should not see a "canvas" element
*
* @Then /^(?:|I )should not see an? "(?P<element>[^"]*)" element$/
*/
@@ -357,7 +441,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that form field with specified id|name|label|value has specified value.
* Checks, that form field with specified id|name|label|value has specified value
* Example: Then the "username" field should contain "bwayne"
* Example: And the "username" field should contain "bwayne"
*
* @Then /^the "(?P<field>(?:[^"]|\\")*)" field should contain "(?P<value>(?:[^"]|\\")*)"$/
*/
@@ -369,7 +455,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that form field with specified id|name|label|value doesn't have specified value.
* Checks, that form field with specified id|name|label|value doesn't have specified value
* Example: Then the "username" field should not contain "batman"
* Example: And the "username" field should not contain "batman"
*
* @Then /^the "(?P<field>(?:[^"]|\\")*)" field should not contain "(?P<value>(?:[^"]|\\")*)"$/
*/
@@ -381,7 +469,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that checkbox with specified in|name|label|value is checked.
* Checks, that checkbox with specified in|name|label|value is checked
* Example: Then the "remember_me" checkbox should be checked
* Example: And the "remember_me" checkbox is checked
*
* @Then /^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox should be checked$/
* @Then /^the checkbox "(?P<checkbox>(?:[^"]|\\")*)" (?:is|should be) checked$/
@@ -392,7 +482,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Checks, that checkbox with specified in|name|label|value is unchecked.
* Checks, that checkbox with specified in|name|label|value is unchecked
* Example: Then the "newsletter" checkbox should be unchecked
* Example: Then the "newsletter" checkbox should not be checked
* Example: And the "newsletter" checkbox is unchecked
*
* @Then /^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox should not be checked$/
* @Then /^the checkbox "(?P<checkbox>(?:[^"]|\\")*)" should (?:be unchecked|not be checked)$/
@@ -405,6 +498,8 @@ class MinkContext extends RawMinkContext implements TranslatableContext
/**
* Checks, that (?P<num>\d+) CSS elements exist on the page
* Example: Then I should see 5 "div" elements
* Example: And I should see 5 "div" elements
*
* @Then /^(?:|I )should see (?P<num>\d+) "(?P<element>[^"]*)" elements?$/
*/
@@ -415,6 +510,8 @@ class MinkContext extends RawMinkContext implements TranslatableContext
/**
* Prints current URL to console.
* Example: Then print current URL
* Example: And print current URL
*
* @Then /^print current URL$/
*/
@@ -424,7 +521,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Prints last response to console.
* Prints last response to console
* Example: Then print current response
* Example: And print current response
*
* @Then /^print last response$/
*/
@@ -437,7 +536,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Opens last response content in browser.
* Opens last response content in browser
* Example: Then show last response
* Example: And show last response
*
* @Then /^show last response$/
*/
@@ -453,7 +554,7 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Returns list of definition translation resources paths.
* Returns list of definition translation resources paths
*
* @return array
*/
@@ -463,7 +564,7 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Returns list of definition translation resources paths for this dictionary.
* Returns list of definition translation resources paths for this dictionary
*
* @return array
*/
@@ -473,7 +574,7 @@ class MinkContext extends RawMinkContext implements TranslatableContext
}
/**
* Returns fixed step argument (with \\" replaced back to ").
* Returns fixed step argument (with \\" replaced back to ")
*
* @param string $argument
*