diff --git a/doc/index.rst b/doc/index.rst index b335a29..2ffc56b 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -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`` 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`` - 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 - - getSession()->wait(5000, "$('.suggestions-results').children().length > 0"); - } - } - -5. Implementing ``Behat\MinkExtension\Context\MinkAwareContext`` with your context. +4. Implementing ``Behat\MinkExtension\Context\MinkAwareContext`` with your context. 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 diff --git a/src/Behat/MinkExtension/Context/Initializer/MinkAwareInitializer.php b/src/Behat/MinkExtension/Context/Initializer/MinkAwareInitializer.php index 94e5afc..bbb45ab 100644 --- a/src/Behat/MinkExtension/Context/Initializer/MinkAwareInitializer.php +++ b/src/Behat/MinkExtension/Context/Initializer/MinkAwareInitializer.php @@ -46,30 +46,11 @@ class MinkAwareInitializer implements ContextInitializer */ public function initializeContext(Context $context) { - if (!$context instanceof MinkAwareContext && !$this->usesMinkDictionary($context)) { + if (!$context instanceof MinkAwareContext) { return; } $context->setMink($this->mink); $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; - } } diff --git a/src/Behat/MinkExtension/Context/MinkDictionary.php b/src/Behat/MinkExtension/Context/MinkDictionary.php deleted file mode 100644 index 7a940d1..0000000 --- a/src/Behat/MinkExtension/Context/MinkDictionary.php +++ /dev/null @@ -1,580 +0,0 @@ - - * - * 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 - */ -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[^"]+)"$/ - * @When /^(?:|I )go to "(?P[^"]+)"$/ - */ - 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