/** * Verify if we're on an expected page. Throw an exception if not. * @throws \Exception */ public function verifyPage() { $info = Helper::getPageInfo($this->getSession(), ['controller']); if ($info['controller'] === 'note') { return; } $message = ['You are not on the note!', 'Current URL: ' . $this->getSession()->getCurrentUrl()]; Helper::throwException($message); }
/** * @param string $language * @return bool * @throws \Exception */ public function verifyPage($language = '') { $info = Helper::getPageInfo($this->getSession(), ['controller', 'action']); if ($info['controller'] === 'checkout' && $info['action'] === 'cart') { return Helper::hasNamedLink($this, 'checkout', $language); } $message = ['You are not on the cart!', 'Current URL: ' . $this->getSession()->getCurrentUrl()]; Helper::throwException($message); return false; }
/** * @When /^I subscribe to the newsletter with "(?P<email>[^"]*)"$/ * @When /^I subscribe to the newsletter with "(?P<email>[^"]*)" :$/ */ public function iSubscribeToTheNewsletterWith($email, TableNode $additionalData = null) { $pageInfo = Helper::getPageInfo($this->getSession(), ['controller']); $pageName = ucfirst($pageInfo['controller']); $data = [['field' => 'newsletter', 'value' => $email]]; if ($pageName === 'Index') { $pageName = 'Homepage'; } elseif ($pageName === 'Newsletter' && $additionalData) { $data = array_merge($data, $additionalData->getHash()); } /** @var Homepage|\Shopware\Tests\Mink\Page\Emotion\Newsletter $page */ $page = $this->getPage($pageName); $page->subscribeNewsletter($data); }
/** * @Then /^the current payment method should be "([^"]*)"$/ */ public function theCurrentPaymentMethodShouldBe($paymentMethod) { $pageInfo = Helper::getPageInfo($this->getSession(), array('controller')); $pageName = ucfirst($pageInfo['controller']) === 'Checkout' ? 'CheckoutConfirm' : 'Account'; $this->getPage($pageName)->checkPaymentMethod($paymentMethod); }