Metadrop / behat-contexts

Behat contexts with additional steps
GNU General Public License v2.0
9 stars 19 forks source link

MINK - Require a class that extends MinkContext instead of Drupal\DrupalExtension\Context\MinkContext #137

Closed omarlopesino closed 2 years ago

omarlopesino commented 2 years ago

Problem

In the cases that it is needed to extend MinkContext (s.e.: trying to wrap a specific MinkContext step), there is an error saying that Drupal\DrupalExtension\Context\MinkContextdoes not exist. It happens because the specific Drupal extension's MinkContext class is required in some contexts:

But looking deeply in the code, the context doesn't need to be an instance of Drupal\DrupalExtension\Context\MinkContext, just an instance of \Behat\MinkExtension\Context\MinkContext.

Steps to reproduce

Change the behat.yml class of 'Drupal\DrupalExtension\Context\MinkContext' by a class that extends Drupal\DrupalExtension\Context\MinkContext. The error will appear just before beginning the first scenario

Solution

In the affected contexts, look for a context that is or extends \Behat\MinkExtension\Context\MinkContext. It will be safe enough knowing that there must only exist one instance of this class, as steps can't be duplicated among different contexts.

omarlopesino commented 2 years ago

I am testing whether these changes work correctly in a specific project. As soon as it works it will be merged into the master branch.

rsanzante commented 2 years ago

We may use this issue as an opportunity to avoid code duplication: the gatherContexts method is the same on the three modified Contexts. Could be a Trait? An intermediary Class between the Contexts and RawMinkContext? A patch to MinkAwareContext?

omarlopesino commented 2 years ago

It is possible to work on it the next time we have the same problem, or even open an issue for it.