added example snippets in MinkExtenstion to be used with 'vendor/bin/behat -di' as definitions

This commit is contained in:
Sajjad Hossain
2015-04-05 22:32:16 -04:00
parent 9bff0ae65f
commit 353349551e

View File

@@ -26,6 +26,11 @@ class MinkContext extends RawMinkContext implements TranslatableContext
*
* @Given /^(?:|I )am on (?:|the )homepage$/
* @When /^(?:|I )go to (?:|the )homepage$/
*
* Example: Given I am on the homepage
* Example: And I am on the homepage
* Example: When I go to the homepage
*
*/
public function iAmOnHomepage()
{
@@ -37,6 +42,11 @@ class MinkContext extends RawMinkContext implements TranslatableContext
*
* @Given /^(?:|I )am on "(?P<page>[^"]+)"$/
* @When /^(?:|I )go to "(?P<page>[^"]+)"$/
*
* Example: Given I am on "/articles/isBatmanBruceWayne"
* Example: And I am on "/articles/isBatmanBruceWayne"
* Example: When I go to "/articles/isBatmanBruceWayne"
*
*/
public function visit($page)
{
@@ -47,6 +57,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Reloads current page.
*
* @When /^(?:|I )reload the page$/
*
* Example: And I relod the page
* Example: When I reload the page
*
*/
public function reload()
{
@@ -57,6 +71,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Moves backward one page in history.
*
* @When /^(?:|I )move backward one page$/
*
* Example: And I move backward one page
* Example: When I move backward one page
*
*/
public function back()
{
@@ -67,6 +85,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Moves forward one page in history
*
* @When /^(?:|I )move forward one page$/
*
* Example: And I move forward one page
* Example: When I move forward one page
*
*/
public function forward()
{
@@ -77,6 +99,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Presses button with specified id|name|title|alt|value.
*
* @When /^(?:|I )press "(?P<button>(?:[^"]|\\")*)"$/
*
* Example: And I press "Log In"
* Example: When I press "sign-in"
*
*/
public function pressButton($button)
{
@@ -88,6 +114,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Clicks link with specified id|title|alt|text.
*
* @When /^(?:|I )follow "(?P<link>(?:[^"]|\\")*)"$/
*
* Example: And I follow "Log In"
* Example: When I follow "sign-in"
*
*/
public function clickLink($link)
{
@@ -101,6 +131,14 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* @When /^(?:|I )fill in "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)"$/
* @When /^(?:|I )fill in "(?P<field>(?:[^"]|\\")*)" with:$/
* @When /^(?:|I )fill in "(?P<value>(?:[^"]|\\")*)" for "(?P<field>(?:[^"]|\\")*)"$/
*
* Example: And I fill in "username" with "bruceWayne"
* Example: And I fill in "username" with: bruceWayne
* Example: And I fill in "bruceWayne" for "username"
* Example: When I fill in "username" with "bruceWayne"
* Example: When I fill in "username" with: bruceWayne
* Example: When I fill in "bruceWayne" for "username"
*
*/
public function fillField($field, $value)
{
@@ -113,6 +151,16 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Fills in form fields with provided table.
*
* @When /^(?:|I )fill in the following:$/
*
* Example: And I fill in the following:
* | userId | 27 |
* | username | bruceWayne |
* | password | iLoveBats123 |
* Example: When I follow "sign-in"
* | userId | 27 |
* | username | bruceWayne |
* | password | iLoveBats123 |
*
*/
public function fillFields(TableNode $fields)
{
@@ -125,6 +173,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Selects option in select field with specified id|name|label|value.
*
* @When /^(?:|I )select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/
*
* Example: And I select "male" from "gender"
* Example: When I select "VISA" from "paymentType"
*
*/
public function selectOption($select, $option)
{
@@ -137,6 +189,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Selects additional option in select field with specified id|name|label|value.
*
* @When /^(?:|I )additionally select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/
*
* Example: And I additionally select "female" from "gender"
* Example: When I additionally select "AMEX" from "paymentType"
*
*/
public function additionallySelectOption($select, $option)
{
@@ -149,6 +205,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks checkbox with specified id|name|label|value.
*
* @When /^(?:|I )check "(?P<option>(?:[^"]|\\")*)"$/
*
* Example: And I check "Mac OS X" from "os"
* Example: When I check "Batman" from "heroes"
*
*/
public function checkOption($option)
{
@@ -160,6 +220,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Unchecks checkbox with specified id|name|label|value.
*
* @When /^(?:|I )uncheck "(?P<option>(?:[^"]|\\")*)"$/
*
* Example: And I uncheck "Mac OS X" from "os"
* Example: When I uncheck "Batman" from "heroes"
*
*/
public function uncheckOption($option)
{
@@ -171,6 +235,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Attaches file to field with specified id|name|label|value.
*
* @When /^(?:|I )attach the file "(?P<path>[^"]*)" to "(?P<field>(?:[^"]|\\")*)"$/
*
* Example: And I check "Mac OS X" from "os"
* Example: When I check "Batman" from "heroes"
*
*/
public function attachFileToField($field, $path)
{
@@ -190,6 +258,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that current page PATH is equal to specified.
*
* @Then /^(?:|I )should be on "(?P<page>[^"]+)"$/
*
* Example: And I should be on "/heroes/Batman"
* Example: Then I should be on "/heroes/Batman"
*
*/
public function assertPageAddress($page)
{
@@ -200,6 +272,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that current page is the homepage.
*
* @Then /^(?:|I )should be on (?:|the )homepage$/
*
* Example: And I should be on the homepage
* Example: Then I should be on the hompage
*
*/
public function assertHomepage()
{
@@ -210,6 +286,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that current page PATH matches regular expression.
*
* @Then /^the (?i)url(?-i) should match (?P<pattern>"(?:[^"]|\\")*")$/
*
* Example: And the url should match "/heroes/\w+"
* Example: Then the url should match "/heroes/\w+"
*
*/
public function assertUrlRegExp($pattern)
{
@@ -220,6 +300,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that current page response status is equal to specified.
*
* @Then /^the response status code should be (?P<code>\d+)$/
*
* Example: And the url should match "/heroes/\w+"
* Example: Then the url should match "/heroes/\w+"
*
*/
public function assertResponseStatus($code)
{
@@ -230,6 +314,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that current page response status is not equal to specified.
*
* @Then /^the response status code should not be (?P<code>\d+)$/
*
* Example: And the response status code should not be 404
* Example: Then the response status code should not be 404
*
*/
public function assertResponseStatusIsNot($code)
{
@@ -240,6 +328,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that page contains specified text.
*
* @Then /^(?:|I )should see "(?P<text>(?:[^"]|\\")*)"$/
*
* Example: And I should see "This just in, Bruce Wayne is not Batman"
* Example: Then I should see "This just in, Bruce Wayne is not Batman"
*
*/
public function assertPageContainsText($text)
{
@@ -250,6 +342,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that page doesn't contain specified text.
*
* @Then /^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)"$/
*
* Example: And I should not see "This just in, Bruce Wayne is Batman"
* Example: Then I should not see "This just in, Bruce Wayne is Batman"
*
*/
public function assertPageNotContainsText($text)
{
@@ -260,6 +356,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that page contains text matching specified pattern.
*
* @Then /^(?:|I )should see text matching (?P<pattern>"(?:[^"]|\\")*")$/
*
* Example: And I should not see "This just in, Bruce Wayne is Batman"
* Example: Then I should not see "This just in, Bruce Wayne is Batman"
*
*/
public function assertPageMatchesText($pattern)
{
@@ -270,6 +370,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that page doesn't contain text matching specified pattern.
*
* @Then /^(?:|I )should not see text matching (?P<pattern>"(?:[^"]|\\")*")$/
*
* Example: And I should not see text matching "Bruce Wayne is Batman"
* Example: Then I should not see text matching "Bruce Wayne is Batman"
*
*/
public function assertPageNotMatchesText($pattern)
{
@@ -280,6 +384,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that HTML response contains specified string.
*
* @Then /^the response should contain "(?P<text>(?:[^"]|\\")*)"$/
*
* Example: And the response should contain "<noscript>Sorry turn JavaScript on to view full experience</noscript>"
* Example: Then the response should contain "<noscript>Sorry turn JavaScript on to view full experience</noscript>"
*
*/
public function assertResponseContains($text)
{
@@ -290,6 +398,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that HTML response doesn't contain specified string.
*
* @Then /^the response should not contain "(?P<text>(?:[^"]|\\")*)"$/
*
* Example: And the response should not contain "v1.0.1"
* Example: Then the response should not contain "v1.0.1"
*
*/
public function assertResponseNotContains($text)
{
@@ -300,6 +412,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that element with specified CSS contains specified text.
*
* @Then /^(?:|I )should see "(?P<text>(?:[^"]|\\")*)" in the "(?P<element>[^"]*)" element$/
*
* Example: And I should see "Batman is dead?" in the "headline" element
* Example: Then I should see "Batman is dead?" in the "headline" element
*
*/
public function assertElementContainsText($element, $text)
{
@@ -310,6 +426,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that element with specified CSS doesn't contain specified text.
*
* @Then /^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)" in the "(?P<element>[^"]*)" element$/
*
* Example: And I should not see "Batman is alive?" in the "headline" element
* Example: Then I should not see "Batman is alive?" in the "headline" element
*
*/
public function assertElementNotContainsText($element, $text)
{
@@ -320,6 +440,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that element with specified CSS contains specified HTML.
*
* @Then /^the "(?P<element>[^"]*)" element should contain "(?P<value>(?:[^"]|\\")*)"$/
*
* Example: And the "nav" element should contain "profile"
* Example: Then the "nav" element should contain "profile"
*
*/
public function assertElementContains($element, $value)
{
@@ -330,6 +454,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that element with specified CSS doesn't contain specified HTML.
*
* @Then /^the "(?P<element>[^"]*)" element should not contain "(?P<value>(?:[^"]|\\")*)"$/
*
* Example: And the "nav" element should not contain "logged-in"
* Example: Then the "nav" element should not contain "logged-in"
*
*/
public function assertElementNotContains($element, $value)
{
@@ -340,6 +468,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that element with specified CSS exists on page.
*
* @Then /^(?:|I )should see an? "(?P<element>[^"]*)" element$/
*
* Example: And I should see a "canvas" element
* Example: Then I should see an "apples" element
*
*/
public function assertElementOnPage($element)
{
@@ -350,6 +482,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that element with specified CSS doesn't exist on page.
*
* @Then /^(?:|I )should not see an? "(?P<element>[^"]*)" element$/
*
* Example: And I should not see a "canvas" element
* Example: Then I should not see an "apples" element
*
*/
public function assertElementNotOnPage($element)
{
@@ -360,6 +496,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that form field with specified id|name|label|value has specified value.
*
* @Then /^the "(?P<field>(?:[^"]|\\")*)" field should contain "(?P<value>(?:[^"]|\\")*)"$/
*
* Example: And the "name" field should contain "Bruce Wayne"
* Example: Then the "name" field should contain "Bruce Wayne"
*
*/
public function assertFieldContains($field, $value)
{
@@ -372,6 +512,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that form field with specified id|name|label|value doesn't have specified value.
*
* @Then /^the "(?P<field>(?:[^"]|\\")*)" field should not contain "(?P<value>(?:[^"]|\\")*)"$/
*
* Example: And the "name" field should not contain "Bruce Wayne"
* Example: Then the "name" field should not contain "Bruce Wayne"
*
*/
public function assertFieldNotContains($field, $value)
{
@@ -385,6 +529,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
*
* @Then /^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox should be checked$/
* @Then /^the checkbox "(?P<checkbox>(?:[^"]|\\")*)" (?:is|should be) checked$/
*
* Example: And the "heroes" checkbox should be checked
* Example: Then the "heroes" checkbox is checked
*
*/
public function assertCheckboxChecked($checkbox)
{
@@ -397,6 +545,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* @Then /^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox should not be checked$/
* @Then /^the checkbox "(?P<checkbox>(?:[^"]|\\")*)" should (?:be unchecked|not be checked)$/
* @Then /^the checkbox "(?P<checkbox>(?:[^"]|\\")*)" is (?:unchecked|not checked)$/
*
* Example: And the "villains" checkbox should be unchecked
* Example: Then the "villains" checkbox is not checked
*
*/
public function assertCheckboxNotChecked($checkbox)
{
@@ -407,6 +559,10 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Checks, that (?P<num>\d+) CSS elements exist on the page
*
* @Then /^(?:|I )should see (?P<num>\d+) "(?P<element>[^"]*)" elements?$/
*
* Example: And I should see 5 "div" elements
* Example: Then I should see 5 "div" elements
*
*/
public function assertNumElements($num, $element)
{
@@ -417,6 +573,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Prints current URL to console.
*
* @Then /^print current URL$/
*
* Example: Then print current URL
*
*/
public function printCurrentUrl()
{
@@ -427,6 +586,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Prints last response to console.
*
* @Then /^print last response$/
*
* Example: Then print last response
*
*/
public function printLastResponse()
{
@@ -440,6 +602,9 @@ class MinkContext extends RawMinkContext implements TranslatableContext
* Opens last response content in browser.
*
* @Then /^show last response$/
*
* Example: Then show last responsecd
*
*/
public function showLastResponse()
{