Merge pull request #212 from getsaucey/develop
Added examples in Step Definitions
This commit is contained in:
@@ -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: And I am on "/articles/isBatmanBruceWayne"
|
||||
* Example: When I go to "/articles/isBatmanBruceWayne"
|
||||
*
|
||||
* @Given /^(?:|I )am on "(?P<page>[^"]+)"$/
|
||||
* @When /^(?:|I )go to "(?P<page>[^"]+)"$/
|
||||
@@ -44,7 +50,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads current page.
|
||||
* Reloads current page
|
||||
* Example: When I reload the page
|
||||
* Example: And I reload the page
|
||||
*
|
||||
* @When /^(?:|I )reload the page$/
|
||||
*/
|
||||
@@ -54,7 +62,8 @@ class MinkContext extends RawMinkContext implements TranslatableContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves backward one page in history.
|
||||
* Moves backward one page in history
|
||||
* Example: When I move backward one page
|
||||
*
|
||||
* @When /^(?:|I )move backward one page$/
|
||||
*/
|
||||
@@ -65,6 +74,7 @@ class MinkContext extends RawMinkContext implements TranslatableContext
|
||||
|
||||
/**
|
||||
* Moves forward one page in history
|
||||
* Example: And I move forward one page
|
||||
*
|
||||
* @When /^(?:|I )move forward one page$/
|
||||
*/
|
||||
@@ -74,7 +84,9 @@ 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: When I press "Log In"
|
||||
* Example: And I press "Log In"
|
||||
*
|
||||
* @When /^(?:|I )press "(?P<button>(?:[^"]|\\")*)"$/
|
||||
*/
|
||||
@@ -85,7 +97,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicks link with specified id|title|alt|text.
|
||||
* Clicks link with specified id|title|alt|text
|
||||
* Example: When I follow "Log In"
|
||||
* Example: And I follow "Log In"
|
||||
*
|
||||
* @When /^(?:|I )follow "(?P<link>(?:[^"]|\\")*)"$/
|
||||
*/
|
||||
@@ -96,7 +110,9 @@ 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: 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 +126,13 @@ class MinkContext extends RawMinkContext implements TranslatableContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills in form fields with provided table.
|
||||
* Fills in form fields with provided table
|
||||
* 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 +144,9 @@ 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: 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 +158,9 @@ 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: 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 +172,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks checkbox with specified id|name|label|value.
|
||||
* Checks checkbox with specified id|name|label|value
|
||||
* Example: When I check "Pearl Necklace" from "itemsClaimed"
|
||||
* Example: And I check "Pearl Necklace" from "itemsClaimed"
|
||||
*
|
||||
* @When /^(?:|I )check "(?P<option>(?:[^"]|\\")*)"$/
|
||||
*/
|
||||
@@ -157,7 +185,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Unchecks checkbox with specified id|name|label|value.
|
||||
* Unchecks checkbox with specified id|name|label|value
|
||||
* Example: When I uncheck "Broadway Plays" from "hobbies"
|
||||
* Example: And I uncheck "Broadway Plays" from "hobbies"
|
||||
*
|
||||
* @When /^(?:|I )uncheck "(?P<option>(?:[^"]|\\")*)"$/
|
||||
*/
|
||||
@@ -168,7 +198,9 @@ 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: 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 +219,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 +232,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 +244,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 +257,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 +269,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 +281,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 +293,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 +305,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 +317,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 +329,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 +341,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 +353,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 +365,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 +377,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 +389,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 +401,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 +413,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 +425,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 +439,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 +453,21 @@ class MinkContext extends RawMinkContext implements TranslatableContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks, that checkbox with specified in|name|label|value is checked.
|
||||
* 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?$/
|
||||
*/
|
||||
public function assertNumElements($num, $element)
|
||||
{
|
||||
$this->assertSession()->elementsCount('css', $element, intval($num));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 +478,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)$/
|
||||
@@ -403,18 +492,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
|
||||
$this->assertSession()->checkboxNotChecked($this->fixStepArgument($checkbox));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks, that (?P<num>\d+) CSS elements exist on the page
|
||||
*
|
||||
* @Then /^(?:|I )should see (?P<num>\d+) "(?P<element>[^"]*)" elements?$/
|
||||
*/
|
||||
public function assertNumElements($num, $element)
|
||||
{
|
||||
$this->assertSession()->elementsCount('css', $element, intval($num));
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints current URL to console.
|
||||
* Example: Then print current URL
|
||||
* Example: And print current URL
|
||||
*
|
||||
* @Then /^print current URL$/
|
||||
*/
|
||||
@@ -424,7 +505,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 +520,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 +538,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 +548,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 +558,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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user