Skip to content

Renaming Step iAmOn ( it is already defined in MinkContext) #35

@ctasca

Description

@ctasca

This exception is thrown when trying to use MinkContext in a subclass of MagentoContext.

In this scenario:

behat.yml

default:
    formatter:
        name: pretty
    context:
        class: MyMagentoContext
        parameters:
             base_url:   http://example.dev
    extensions:
        MageTest\MagentoExtension\Extension:
            base_url: "http://example.dev"
        Behat\MinkExtension\Extension:
            base_url: http://example.dev
            goutte:
                server_parameters:
                    HTTP_HOST: %behat.mink.base_url%
            sahi: ~
customer:
    context:
        class: CustomerUserContext
        parameters:
             base_url:   http://example.dev

admin:
    context:
        class: AdminUserContext
        parameters:
             base_url:   http://example.dev

module:
    context:
        class: ModuleContext
        parameters:
             base_url:   http://example.dev

WHERE MyMagentoContext is in composer autoload and have following constructor:

class MyMagentoContext extends MagentoContext
{
    private $output;

    public function __construct(array $parameters)
    {
        $this->useContext('mink', new MinkContext);
    }

and AdminUserContext is defined as follow

use Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\TableNode;
use MageTest\MagentoExtension\Context\MagentoContext;

class AdminUserContext extends MyMagentoContext
{
    /**
     * @Given /^I am on the dashboard after logging in with "([^"]*)" and "([^"]*)"$/
     */
    public function iAmOnTheDashboardAfterLoggingInWithAnd($username, $password)
    {
        $this->getSession()->visit($this->getMinkParameter('base_url') . '/admin');
        $this->getSession()->getPage()->fillField('username', $username);
        $this->getSession()->getPage()->fillField('login', $password);
        $this->getSession()->getPage()->pressButton('Login');
        $this->iCloseMessagePopUp();
    }


    /**
     * @Given /^I close message pop up$/
     */
    public function iCloseMessagePopUp()
    {
        $this->getSession()->wait(2000);
        $function = <<<JS
(function(){
    closeMessagePopup();
})()
JS;
        return $this->getSession()->getDriver()->evaluateScript($function);
    }
}

WHEN I run command

bin/behat features/admin --profile admin

I get

  [Behat\Behat\Exception\RedundantException]
  Step "/^(?:|I )am on "(?P<page>[^"]+)"$/" is already defined in AdminUserContext::iAmOn()

  AdminUserContext::iAmOn()
  Behat\MinkExtension\Context\MinkContext::visit()

To make it all working I need to remove iAmOn from MagentoContext class. Maybe it should be renamed?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions