/**
  * Check newsletter box and subscribe to newsletter
  *
  * @test
  */
 public function testCheckNewsletterboxAndSave()
 {
     /* @var $mail MagentoComponents_ImapMail */
     $mail = Menta_ComponentManager::get('MagentoComponents_ImapMail');
     $mail->deleteAllMailsMatching('Newsletter subscription success');
     /* @var $customerAccount MagentoComponents_Pages_CustomerAccount */
     $customerAccount = Menta_ComponentManager::get('MagentoComponents_Pages_CustomerAccount');
     $customerAccount->login();
     $customerAccount->openDashboard();
     $this->getHelperAssert()->assertElementPresent($customerAccount->getNewsletterEditPathInDashoboard());
     $this->getHelperCommon()->click($customerAccount->getNewsletterEditPathInDashoboard());
     $this->getHelperWait()->waitForElementPresent('//h1[' . Menta_Util_Div::containsText('Newsletter Subscription') . ']');
     if ($this->getHelperCommon()->isSelected("//input[@id='subscription']")) {
         $this->markTestSkipped('Subscribe to newsletter already selected!');
     }
     $this->getHelperAssert()->assertElementPresent("//input[@id='subscription']");
     $this->getHelperCommon()->click("//input[@id='subscription']");
     $this->getHelperCommon()->isSelected("//input[@id='subscription']");
     $this->getHelperCommon()->click('//form[@id="form-validate"]//button[@type="submit"]');
     /* @var $message MagentoComponents_Pages_Message */
     $message = Menta_ComponentManager::get('MagentoComponents_Pages_Message');
     $message->waitForSuccessMessagePresent('The subscription has been saved');
     $this->getHelperWait()->waitForTextPresent('The subscription has been saved.');
     $mail->checkNewsletterSignUpMail(array('firstname' => 'Test', 'lastname' => 'User'));
 }
 /**
  * Order simple product with different shipping address
  *
  * @test
  * @group adds_testdata
  */
 public function orderWithDifferentShippingAddress()
 {
     /* @var $cart MagentoComponents_Pages_Cart */
     $cart = Menta_ComponentManager::get('MagentoComponents_Pages_Cart');
     $cart->clearCart();
     $productSingleView = Menta_ComponentManager::get('MagentoComponents_Pages_ProductSingleView');
     /* @var $productSingleView MagentoComponents_Pages_ProductSingleView */
     $productSingleView->putProductsIntoCart($this->getConfiguration()->getValue('testing.simple.product.id'));
     $onePageCheckout = Menta_ComponentManager::get('MagentoComponents_Pages_OnePageCheckout');
     /* @var $onePageCheckout MagentoComponents_Pages_OnePageCheckout */
     $onePageCheckout->open();
     $onePageCheckout->setCheckoutMethod('register');
     $onePageCheckout->finishStep('checkoutMethod');
     $onePageCheckout->addAddress('uk', 'billing');
     $this->getHelperAssert()->assertElementPresent('billing:customer_password');
     $onePageCheckout->saveAccountForLaterUse();
     $onePageCheckout->toggleShipToDifferentAddress();
     /* @var $customerAccount MagentoComponents_Pages_CustomerAccount */
     $customerAccount = Menta_ComponentManager::get('MagentoComponents_Pages_CustomerAccount');
     $onePageCheckout->finishStep('billingAddress');
     $onePageCheckout->addAddress('uk', 'shipping');
     $onePageCheckout->finishStep('shippingAddress');
     $onePageCheckout->finishStep('shippingMethod');
     $onePageCheckout->selectPaymentMethodCheckmo();
     $onePageCheckout->finishStep('paymentMethod');
     $onePageCheckout->submitForm();
     $this->lastOrderId = $onePageCheckout->getOrderIdFromSuccessPage();
     $lastOrderNumber = $onePageCheckout->getOrderNumberFromSuccessPage();
     $this->getHelperCommon()->open('/sales/order/history/?limit=50');
     $viewOrderLinkPath = '//*[@id="my-orders-table"]/tbody/tr/td/span/a[contains(@href, "view/order_id/' . $this->lastOrderId . '")]';
     $this->getHelperCommon()->click($viewOrderLinkPath);
     $this->getHelperWait()->waitForElementPresent('//h1[ ' . Menta_Util_Div::containsText("Order #{$lastOrderNumber}") . ']');
     $this->getHelperAssert()->assertTextPresent($this->lastOrderId);
     $addressProvider = new MagentoComponents_Provider_Address();
     $shippingAddress = $addressProvider->getAddressField('shipping', 'uk');
     $billingAddress = $addressProvider->getAddressField('billing', 'uk');
     $this->getHelperAssert()->assertTextPresent($shippingAddress['firstname']);
     $this->getHelperAssert()->assertTextPresent($shippingAddress['lastname']);
     $this->getHelperAssert()->assertTextPresent($shippingAddress['street1']);
     if (isset($shippingAddress['region']) && $shippingAddress['region']) {
         $this->getHelperAssert()->assertTextPresent($shippingAddress['region']);
     }
     $this->getHelperAssert()->assertTextPresent($shippingAddress['country']);
     $this->getHelperAssert()->assertTextPresent($shippingAddress['phone']);
     $this->getHelperAssert()->assertTextPresent($billingAddress['firstname']);
     $this->getHelperAssert()->assertTextPresent($billingAddress['lastname']);
     $this->getHelperAssert()->assertTextPresent($billingAddress['street1']);
     if (isset($billingAddress['region']) && $billingAddress['region']) {
         $this->getHelperAssert()->assertTextPresent($billingAddress['region']);
     }
     $this->getHelperAssert()->assertTextPresent($billingAddress['country']);
     $this->getHelperAssert()->assertTextPresent($billingAddress['phone']);
     return $lastOrderNumber;
 }
 /**
  *
  * @return string
  */
 public function getTaxXpath()
 {
     return "//tfoot//td[" . Menta_Util_Div::containsText('Tax') . "]/following-sibling::td/span[" . Menta_Util_Div::contains('price') . "]";
 }
 /**
  * Logout
  */
 public function logout()
 {
     $helper = Menta_ComponentManager::get('MagentoComponents_Helper');
     /* @var $helper MagentoComponents_Helper */
     $this->getHelperCommon()->click($helper->getLogoutLinkPath());
     $this->getHelperWait()->waitForElementPresent("//h1[" . Menta_Util_Div::containsText($this->__('You are now logged out')) . "]");
     $this->getHelperAssert()->assertElementPresent("//h1[" . Menta_Util_Div::containsText($this->__('You are now logged out')) . "]");
 }