Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature-Request] Use Mage:: in a Behat-Hook #91

Open
zuernBernhard opened this issue Aug 25, 2016 · 1 comment
Open

[Feature-Request] Use Mage:: in a Behat-Hook #91

zuernBernhard opened this issue Aug 25, 2016 · 1 comment

Comments

@zuernBernhard
Copy link

I have a behat test for the Customer-Registration in a Magento-Shop (1.8).

In order to rerun the test as often as I want
As a developer I want the Test to clear the generated user account in a scenario hook

Possible Solution:

/**
   * @param $event
   *
   * @BeforeScenario
   */
  public function before($event) {
    if ('Customer Register' == $event->getScenario()->getTitle()) {
      // Delete the TestCustomer if exists.
      $customer = Mage::getModel('customer/customer')->loadByEmail('email@dre.ss');
      $customer->delete();
    }
  }

BUT this does not work.

Then I move the code into a Stepdefinition it works. :(

@zuernBernhard
Copy link
Author

Here is the working step definition:

  /**
   * @Given I make sure the customer :mail does not exist in the :shop Shop
   */
  public function iMakeSureTheCustomerDoesNotExistInTheShop($mail, $site)
  {
    $websites = Mage::app()->getWebsites();
    foreach ($websites as $website) {
      $name = $website->getName();
      if ($site == $name) {
        Mage::register('isSecureArea', true); /* set secure admin area*/
        $customerModel = Mage::getModel('customer/customer');
        $customerModel->setWebsiteId($website->getId());
        $customer = $customerModel->loadByEmail($mail);
        $customer->delete();
        Mage::unregister('isSecureArea'); /* un set secure admin area*/
      }
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant