Merge pull request #122 from stof/remove_dictionary
Removed the MinkDictionary
This commit is contained in:
@@ -124,32 +124,7 @@ After installing extension, there would be 6 usage options available for you:
|
|||||||
It will cause ``RedundantException``. So, you can inherit from ``MinkContext``
|
It will cause ``RedundantException``. So, you can inherit from ``MinkContext``
|
||||||
only with one of your context/subcontext classes.
|
only with one of your context/subcontext classes.
|
||||||
|
|
||||||
4. If you're on the php 5.4+, you can simply use ``Behat\MinkExtension\Context\MinkDictionary``
|
4. Implementing ``Behat\MinkExtension\Context\MinkAwareContext`` with your context.
|
||||||
trait inside your ``FeatureContext``. This trait will provide all the needed methods,
|
|
||||||
hooks and definitions for you to start. You can use this trait **only once** inside
|
|
||||||
your feature context tree, and it cannot be used at the same time than the ``MinkContext``.
|
|
||||||
|
|
||||||
.. code-block:: php
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
use Behat\Behat\Context\BehatContext;
|
|
||||||
use Behat\MinkExtension\Context\MinkDictionary;
|
|
||||||
|
|
||||||
class FeatureContext extends BehatContext
|
|
||||||
{
|
|
||||||
use MinkDictionary;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Then /^I wait for the suggestion box to appear$/
|
|
||||||
*/
|
|
||||||
public function iWaitForTheSuggestionBoxToAppear()
|
|
||||||
{
|
|
||||||
$this->getSession()->wait(5000, "$('.suggestions-results').children().length > 0");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
5. Implementing ``Behat\MinkExtension\Context\MinkAwareContext`` with your context.
|
|
||||||
|
|
||||||
There's common things these methods. In each of those, target context will implement
|
There's common things these methods. In each of those, target context will implement
|
||||||
``setMink(Mink $mink)`` and ``setMinkParameters(array $parameters)`` methods. Those methods would
|
``setMink(Mink $mink)`` and ``setMinkParameters(array $parameters)`` methods. Those methods would
|
||||||
|
|||||||
@@ -46,30 +46,11 @@ class MinkAwareInitializer implements ContextInitializer
|
|||||||
*/
|
*/
|
||||||
public function initializeContext(Context $context)
|
public function initializeContext(Context $context)
|
||||||
{
|
{
|
||||||
if (!$context instanceof MinkAwareContext && !$this->usesMinkDictionary($context)) {
|
if (!$context instanceof MinkAwareContext) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$context->setMink($this->mink);
|
$context->setMink($this->mink);
|
||||||
$context->setMinkParameters($this->parameters);
|
$context->setMinkParameters($this->parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the context uses the MinkDictionary trait.
|
|
||||||
*
|
|
||||||
* @param Context $context
|
|
||||||
*
|
|
||||||
* @return Boolean
|
|
||||||
*/
|
|
||||||
private function usesMinkDictionary(Context $context)
|
|
||||||
{
|
|
||||||
$refl = new \ReflectionObject($context);
|
|
||||||
if (method_exists($refl, 'getTraitNames')) {
|
|
||||||
if (in_array('Behat\\MinkExtension\\Context\\MinkDictionary', $refl->getTraitNames())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,580 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Behat MinkExtension.
|
|
||||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Behat\MinkExtension\Context;
|
|
||||||
|
|
||||||
use Behat\Gherkin\Node\TableNode;
|
|
||||||
use Behat\Mink\Mink;
|
|
||||||
use Behat\Mink\Session;
|
|
||||||
use Behat\Mink\WebAssert;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mink steps dictionary for Behat BDD tool.
|
|
||||||
*
|
|
||||||
* @author Konstantin Kudryashov <ever.zet@gmail.com>
|
|
||||||
*/
|
|
||||||
trait MinkDictionary
|
|
||||||
{
|
|
||||||
private $mink;
|
|
||||||
private $minkParameters;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets Mink instance.
|
|
||||||
*
|
|
||||||
* @param Mink $mink Mink session manager
|
|
||||||
*/
|
|
||||||
public function setMink(Mink $mink)
|
|
||||||
{
|
|
||||||
$this->mink = $mink;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns Mink instance.
|
|
||||||
*
|
|
||||||
* @return Mink
|
|
||||||
*/
|
|
||||||
public function getMink()
|
|
||||||
{
|
|
||||||
return $this->mink;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the parameters provided for Mink.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getMinkParameters()
|
|
||||||
{
|
|
||||||
return $this->minkParameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets parameters provided for Mink.
|
|
||||||
*
|
|
||||||
* @param array $parameters
|
|
||||||
*/
|
|
||||||
public function setMinkParameters(array $parameters)
|
|
||||||
{
|
|
||||||
$this->minkParameters = $parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns specific mink parameter.
|
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getMinkParameter($name)
|
|
||||||
{
|
|
||||||
return isset($this->minkParameters[$name]) ? $this->minkParameters[$name] : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies the given parameter to the Mink configuration. Consider that all parameters get reset for each
|
|
||||||
* feature context.
|
|
||||||
*
|
|
||||||
* @param string $name The key of the parameter
|
|
||||||
* @param string $value The value of the parameter
|
|
||||||
*/
|
|
||||||
public function setMinkParameter($name, $value)
|
|
||||||
{
|
|
||||||
$this->minkParameters[$name] = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns Mink session.
|
|
||||||
*
|
|
||||||
* @param string|null $name name of the session OR active session will be used
|
|
||||||
*
|
|
||||||
* @return Session
|
|
||||||
*/
|
|
||||||
public function getSession($name = null)
|
|
||||||
{
|
|
||||||
return $this->getMink()->getSession($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns Mink session assertion tool.
|
|
||||||
*
|
|
||||||
* @param string|null $name name of the session OR active session will be used
|
|
||||||
*
|
|
||||||
* @return WebAssert
|
|
||||||
*/
|
|
||||||
public function assertSession($name = null)
|
|
||||||
{
|
|
||||||
return $this->getMink()->assertSession($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Opens homepage.
|
|
||||||
*
|
|
||||||
* @Given /^(?:|I )am on (?:|the )homepage$/
|
|
||||||
* @When /^(?:|I )go to (?:|the )homepage$/
|
|
||||||
*/
|
|
||||||
public function iAmOnHomepage()
|
|
||||||
{
|
|
||||||
$this->getSession()->visit($this->locatePath('/'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Opens specified page.
|
|
||||||
*
|
|
||||||
* @Given /^(?:|I )am on "(?P<page>[^"]+)"$/
|
|
||||||
* @When /^(?:|I )go to "(?P<page>[^"]+)"$/
|
|
||||||
*/
|
|
||||||
public function visit($page)
|
|
||||||
{
|
|
||||||
$this->getSession()->visit($this->locatePath($page));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reloads current page.
|
|
||||||
*
|
|
||||||
* @When /^(?:|I )reload the page$/
|
|
||||||
*/
|
|
||||||
public function reload()
|
|
||||||
{
|
|
||||||
$this->getSession()->reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Moves backward one page in history.
|
|
||||||
*
|
|
||||||
* @When /^(?:|I )move backward one page$/
|
|
||||||
*/
|
|
||||||
public function back()
|
|
||||||
{
|
|
||||||
$this->getSession()->back();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Moves forward one page in history
|
|
||||||
*
|
|
||||||
* @When /^(?:|I )move forward one page$/
|
|
||||||
*/
|
|
||||||
public function forward()
|
|
||||||
{
|
|
||||||
$this->getSession()->forward();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Presses button with specified id|name|title|alt|value.
|
|
||||||
*
|
|
||||||
* @When /^(?:|I )press "(?P<button>(?:[^"]|\\")*)"$/
|
|
||||||
*/
|
|
||||||
public function pressButton($button)
|
|
||||||
{
|
|
||||||
$button = $this->fixStepArgument($button);
|
|
||||||
$this->getSession()->getPage()->pressButton($button);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clicks link with specified id|title|alt|text.
|
|
||||||
*
|
|
||||||
* @When /^(?:|I )follow "(?P<link>(?:[^"]|\\")*)"$/
|
|
||||||
*/
|
|
||||||
public function clickLink($link)
|
|
||||||
{
|
|
||||||
$link = $this->fixStepArgument($link);
|
|
||||||
$this->getSession()->getPage()->clickLink($link);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fills in form field with specified id|name|label|value.
|
|
||||||
*
|
|
||||||
* @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>(?:[^"]|\\")*)"$/
|
|
||||||
*/
|
|
||||||
public function fillField($field, $value)
|
|
||||||
{
|
|
||||||
$field = $this->fixStepArgument($field);
|
|
||||||
$value = $this->fixStepArgument($value);
|
|
||||||
$this->getSession()->getPage()->fillField($field, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fills in form fields with provided table.
|
|
||||||
*
|
|
||||||
* @When /^(?:|I )fill in the following:$/
|
|
||||||
*/
|
|
||||||
public function fillFields(TableNode $fields)
|
|
||||||
{
|
|
||||||
foreach ($fields->getRowsHash() as $field => $value) {
|
|
||||||
$this->fillField($field, $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Selects option in select field with specified id|name|label|value.
|
|
||||||
*
|
|
||||||
* @When /^(?:|I )select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/
|
|
||||||
*/
|
|
||||||
public function selectOption($select, $option)
|
|
||||||
{
|
|
||||||
$select = $this->fixStepArgument($select);
|
|
||||||
$option = $this->fixStepArgument($option);
|
|
||||||
$this->getSession()->getPage()->selectFieldOption($select, $option);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Selects additional option in select field with specified id|name|label|value.
|
|
||||||
*
|
|
||||||
* @When /^(?:|I )additionally select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/
|
|
||||||
*/
|
|
||||||
public function additionallySelectOption($select, $option)
|
|
||||||
{
|
|
||||||
$select = $this->fixStepArgument($select);
|
|
||||||
$option = $this->fixStepArgument($option);
|
|
||||||
$this->getSession()->getPage()->selectFieldOption($select, $option, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks checkbox with specified id|name|label|value.
|
|
||||||
*
|
|
||||||
* @When /^(?:|I )check "(?P<option>(?:[^"]|\\")*)"$/
|
|
||||||
*/
|
|
||||||
public function checkOption($option)
|
|
||||||
{
|
|
||||||
$option = $this->fixStepArgument($option);
|
|
||||||
$this->getSession()->getPage()->checkField($option);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unchecks checkbox with specified id|name|label|value.
|
|
||||||
*
|
|
||||||
* @When /^(?:|I )uncheck "(?P<option>(?:[^"]|\\")*)"$/
|
|
||||||
*/
|
|
||||||
public function uncheckOption($option)
|
|
||||||
{
|
|
||||||
$option = $this->fixStepArgument($option);
|
|
||||||
$this->getSession()->getPage()->uncheckField($option);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attaches file to field with specified id|name|label|value.
|
|
||||||
*
|
|
||||||
* @When /^(?:|I )attach the file "(?P<path>[^"]*)" to "(?P<field>(?:[^"]|\\")*)"$/
|
|
||||||
*/
|
|
||||||
public function attachFileToField($field, $path)
|
|
||||||
{
|
|
||||||
$field = $this->fixStepArgument($field);
|
|
||||||
|
|
||||||
if ($this->getMinkParameter('files_path')) {
|
|
||||||
$path = rtrim($this->getMinkParameter('files_path'), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$path;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->getSession()->getPage()->attachFileToField($field, $path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that current page PATH is equal to specified.
|
|
||||||
*
|
|
||||||
* @Then /^(?:|I )should be on "(?P<page>[^"]+)"$/
|
|
||||||
*/
|
|
||||||
public function assertPageAddress($page)
|
|
||||||
{
|
|
||||||
$this->assertSession()->addressEquals($this->locatePath($page));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that current page is the homepage.
|
|
||||||
*
|
|
||||||
* @Then /^(?:|I )should be on (?:|the )homepage$/
|
|
||||||
*/
|
|
||||||
public function assertHomepage()
|
|
||||||
{
|
|
||||||
$this->assertSession()->addressEquals($this->locatePath('/'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that current page PATH matches regular expression.
|
|
||||||
*
|
|
||||||
* @Then /^the (?i)url(?-i) should match (?P<pattern>"([^"]|\\")*")$/
|
|
||||||
*/
|
|
||||||
public function assertUrlRegExp($pattern)
|
|
||||||
{
|
|
||||||
$this->assertSession()->addressMatches($this->fixStepArgument($pattern));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that current page response status is equal to specified.
|
|
||||||
*
|
|
||||||
* @Then /^the response status code should be (?P<code>\d+)$/
|
|
||||||
*/
|
|
||||||
public function assertResponseStatus($code)
|
|
||||||
{
|
|
||||||
$this->assertSession()->statusCodeEquals($code);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that current page response status is not equal to specified.
|
|
||||||
*
|
|
||||||
* @Then /^the response status code should not be (?P<code>\d+)$/
|
|
||||||
*/
|
|
||||||
public function assertResponseStatusIsNot($code)
|
|
||||||
{
|
|
||||||
$this->assertSession()->statusCodeNotEquals($code);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that page contains specified text.
|
|
||||||
*
|
|
||||||
* @Then /^(?:|I )should see "(?P<text>(?:[^"]|\\")*)"$/
|
|
||||||
*/
|
|
||||||
public function assertPageContainsText($text)
|
|
||||||
{
|
|
||||||
$this->assertSession()->pageTextContains($this->fixStepArgument($text));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that page doesn't contain specified text.
|
|
||||||
*
|
|
||||||
* @Then /^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)"$/
|
|
||||||
*/
|
|
||||||
public function assertPageNotContainsText($text)
|
|
||||||
{
|
|
||||||
$this->assertSession()->pageTextNotContains($this->fixStepArgument($text));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that page contains text matching specified pattern.
|
|
||||||
*
|
|
||||||
* @Then /^(?:|I )should see text matching (?P<pattern>"(?:[^"]|\\")*")$/
|
|
||||||
*/
|
|
||||||
public function assertPageMatchesText($pattern)
|
|
||||||
{
|
|
||||||
$this->assertSession()->pageTextMatches($this->fixStepArgument($pattern));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that page doesn't contain text matching specified pattern.
|
|
||||||
*
|
|
||||||
* @Then /^(?:|I )should not see text matching (?P<pattern>"(?:[^"]|\\")*")$/
|
|
||||||
*/
|
|
||||||
public function assertPageNotMatchesText($pattern)
|
|
||||||
{
|
|
||||||
$this->assertSession()->pageTextNotMatches($this->fixStepArgument($pattern));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that HTML response contains specified string.
|
|
||||||
*
|
|
||||||
* @Then /^the response should contain "(?P<text>(?:[^"]|\\")*)"$/
|
|
||||||
*/
|
|
||||||
public function assertResponseContains($text)
|
|
||||||
{
|
|
||||||
$this->assertSession()->responseContains($this->fixStepArgument($text));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that HTML response doesn't contain specified string.
|
|
||||||
*
|
|
||||||
* @Then /^the response should not contain "(?P<text>(?:[^"]|\\")*)"$/
|
|
||||||
*/
|
|
||||||
public function assertResponseNotContains($text)
|
|
||||||
{
|
|
||||||
$this->assertSession()->responseNotContains($this->fixStepArgument($text));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that element with specified CSS contains specified text.
|
|
||||||
*
|
|
||||||
* @Then /^(?:|I )should see "(?P<text>(?:[^"]|\\")*)" in the "(?P<element>[^"]*)" element$/
|
|
||||||
*/
|
|
||||||
public function assertElementContainsText($element, $text)
|
|
||||||
{
|
|
||||||
$this->assertSession()->elementTextContains('css', $element, $this->fixStepArgument($text));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that element with specified CSS doesn't contain specified text.
|
|
||||||
*
|
|
||||||
* @Then /^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)" in the "(?P<element>[^"]*)" element$/
|
|
||||||
*/
|
|
||||||
public function assertElementNotContainsText($element, $text)
|
|
||||||
{
|
|
||||||
$this->assertSession()->elementTextNotContains('css', $element, $this->fixStepArgument($text));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that element with specified CSS contains specified HTML.
|
|
||||||
*
|
|
||||||
* @Then /^the "(?P<element>[^"]*)" element should contain "(?P<value>(?:[^"]|\\")*)"$/
|
|
||||||
*/
|
|
||||||
public function assertElementContains($element, $value)
|
|
||||||
{
|
|
||||||
$this->assertSession()->elementContains('css', $element, $this->fixStepArgument($value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that element with specified CSS doesn't contain specified HTML.
|
|
||||||
*
|
|
||||||
* @Then /^the "(?P<element>[^"]*)" element should not contain "(?P<value>(?:[^"]|\\")*)"$/
|
|
||||||
*/
|
|
||||||
public function assertElementNotContains($element, $value)
|
|
||||||
{
|
|
||||||
$this->assertSession()->elementNotContains('css', $element, $this->fixStepArgument($value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that element with specified CSS exists on page.
|
|
||||||
*
|
|
||||||
* @Then /^(?:|I )should see an? "(?P<element>[^"]*)" element$/
|
|
||||||
*/
|
|
||||||
public function assertElementOnPage($element)
|
|
||||||
{
|
|
||||||
$this->assertSession()->elementExists('css', $element);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that element with specified CSS doesn't exist on page.
|
|
||||||
*
|
|
||||||
* @Then /^(?:|I )should not see an? "(?P<element>[^"]*)" element$/
|
|
||||||
*/
|
|
||||||
public function assertElementNotOnPage($element)
|
|
||||||
{
|
|
||||||
$this->assertSession()->elementNotExists('css', $element);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that form field with specified id|name|label|value has specified value.
|
|
||||||
*
|
|
||||||
* @Then /^the "(?P<field>(?:[^"]|\\")*)" field should contain "(?P<value>(?:[^"]|\\")*)"$/
|
|
||||||
*/
|
|
||||||
public function assertFieldContains($field, $value)
|
|
||||||
{
|
|
||||||
$field = $this->fixStepArgument($field);
|
|
||||||
$value = $this->fixStepArgument($value);
|
|
||||||
$this->assertSession()->fieldValueEquals($field, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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>(?:[^"]|\\")*)"$/
|
|
||||||
*/
|
|
||||||
public function assertFieldNotContains($field, $value)
|
|
||||||
{
|
|
||||||
$field = $this->fixStepArgument($field);
|
|
||||||
$value = $this->fixStepArgument($value);
|
|
||||||
$this->assertSession()->fieldValueNotEquals($field, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that checkbox with specified in|name|label|value is checked.
|
|
||||||
*
|
|
||||||
* @Then /^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox should be checked$/
|
|
||||||
* @Then /^the checkbox "(?P<checkbox>(?:[^"]|\\")*)" (?:is|should be) checked$/
|
|
||||||
*/
|
|
||||||
public function assertCheckboxChecked($checkbox)
|
|
||||||
{
|
|
||||||
$this->assertSession()->checkboxChecked($this->fixStepArgument($checkbox));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks, that checkbox with specified in|name|label|value is unchecked.
|
|
||||||
*
|
|
||||||
* @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)$/
|
|
||||||
*/
|
|
||||||
public function assertCheckboxNotChecked($checkbox)
|
|
||||||
{
|
|
||||||
$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.
|
|
||||||
*
|
|
||||||
* @Then /^print current URL$/
|
|
||||||
*/
|
|
||||||
public function printCurrentUrl()
|
|
||||||
{
|
|
||||||
$this->printDebug($this->getSession()->getCurrentUrl());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prints last response to console.
|
|
||||||
*
|
|
||||||
* @Then /^print last response$/
|
|
||||||
*/
|
|
||||||
public function printLastResponse()
|
|
||||||
{
|
|
||||||
$this->printDebug(
|
|
||||||
$this->getSession()->getCurrentUrl()."\n\n".
|
|
||||||
$this->getSession()->getPage()->getContent()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Opens last response content in browser.
|
|
||||||
*
|
|
||||||
* @Then /^show last response$/
|
|
||||||
*/
|
|
||||||
public function showLastResponse()
|
|
||||||
{
|
|
||||||
if (null === $this->getMinkParameter('show_cmd')) {
|
|
||||||
throw new \RuntimeException('Set "show_cmd" parameter in behat.yml to be able to open page in browser (ex.: "show_cmd: firefox %s")');
|
|
||||||
}
|
|
||||||
|
|
||||||
$filename = rtrim($this->getMinkParameter('show_tmp_dir'), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.uniqid().'.html';
|
|
||||||
file_put_contents($filename, $this->getSession()->getPage()->getContent());
|
|
||||||
system(sprintf($this->getMinkParameter('show_cmd'), escapeshellarg($filename)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns list of definition translation resources paths for this dictionary.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public static function getMinkTranslationResources()
|
|
||||||
{
|
|
||||||
return glob(__DIR__.'/../../../../i18n/*.xliff');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Locates url, based on provided path.
|
|
||||||
* Override to provide custom routing mechanism.
|
|
||||||
*
|
|
||||||
* @param string $path
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function locatePath($path)
|
|
||||||
{
|
|
||||||
$startUrl = rtrim($this->getMinkParameter('base_url'), '/') . '/';
|
|
||||||
|
|
||||||
return 0 !== strpos($path, 'http') ? $startUrl . ltrim($path, '/') : $path;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns fixed step argument (with \\" replaced back to ").
|
|
||||||
*
|
|
||||||
* @param string $argument
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function fixStepArgument($argument)
|
|
||||||
{
|
|
||||||
return str_replace('\\"', '"', $argument);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user