/** * Assert that you will be redirected to url from dataset * * @param CmsIndex $cmsIndex * @param BrowserInterface $browser * @param CatalogSearchQuery $searchTerm * @return void */ public function processAssert(CmsIndex $cmsIndex, BrowserInterface $browser, CatalogSearchQuery $searchTerm) { $cmsIndex->open()->getSearchBlock()->search($searchTerm->getSynonymFor()); $windowUrl = $browser->getUrl(); $redirectUrl = $searchTerm->getRedirect(); \PHPUnit_Framework_Assert::assertEquals($windowUrl, $redirectUrl, 'Redirect by synonym was not executed.' . PHP_EOL . "Expected: " . $redirectUrl . PHP_EOL . "Actual: " . $windowUrl); }
/** * Assert that Secure Urls Enabled. * * @param BrowserInterface $browser * @param Dashboard $dashboard * @param CustomerAccountLogin $customerAccountLogin * @return void */ public function processAssert(BrowserInterface $browser, Dashboard $dashboard, CustomerAccountLogin $customerAccountLogin) { $dashboard->open(); \PHPUnit_Framework_Assert::assertTrue(strpos($browser->getUrl(), 'https://') !== false, 'Secure Url is not displayed on backend.'); $customerAccountLogin->open(); \PHPUnit_Framework_Assert::assertTrue(strpos($browser->getUrl(), 'https://') !== false, 'Secure Url is not displayed on frontend.'); }
/** * Assert that apache redirect works by opening category page and asserting index.php in its url. * * @param CatalogCategory $category * @param CmsIndex $homePage * @param BrowserInterface $browser */ public function processAssert(CatalogCategory $category, CmsIndex $homePage, BrowserInterface $browser) { $category->persist(); $homePage->open(); $homePage->getTopmenu()->selectCategory($category->getName()); \PHPUnit_Framework_Assert::assertTrue(strpos($browser->getUrl(), 'index.php') === false, 'Apache redirect for category does not work.'); }
/** * Assert that outside redirect was success * * @param UrlRewrite $urlRewrite * @param BrowserInterface $browser * @param UrlRewrite|null $initialRewrite [optional] * @return void */ public function processAssert(UrlRewrite $urlRewrite, BrowserInterface $browser, UrlRewrite $initialRewrite = null) { $urlRequestPath = $urlRewrite->hasData('request_path') ? $urlRewrite->getRequestPath() : $initialRewrite->getRequestPath(); $urlTargetPath = $urlRewrite->hasData('target_path') ? $urlRewrite->getTargetPath() : $initialRewrite->getTargetPath(); $browser->open($_ENV['app_frontend_url'] . $urlRequestPath); $browserUrl = $browser->getUrl(); \PHPUnit_Framework_Assert::assertEquals($browserUrl, $urlTargetPath, 'URL rewrite redirect false.' . "\nExpected: " . $urlTargetPath . "\nActual: " . $browserUrl); }
/** * Check that Shopping Cart is empty, opened page contains text "You have no items in your shopping cart. * Click here to continue shopping." where 'here' is link that leads to index page * * @param CheckoutCart $checkoutCart * @param BrowserInterface $browser * @return void */ public function processAssert(CheckoutCart $checkoutCart, BrowserInterface $browser) { $checkoutCart->open(); $cartEmptyBlock = $checkoutCart->getCartEmptyBlock(); \PHPUnit_Framework_Assert::assertEquals(self::TEXT_EMPTY_CART, $cartEmptyBlock->getText(), 'Wrong text on empty cart page.'); $cartEmptyBlock->clickLinkToMainPage(); \PHPUnit_Framework_Assert::assertEquals($_ENV['app_frontend_url'], $browser->getUrl(), 'Wrong link to main page on empty cart page.'); }
/** * Assert that created CMS Page URL Rewrite lead to appropriate page in frontend. * * @param UrlRewrite $urlRewrite * @param CmsPage $cmsPage * @param SystemVariableNew $systemVariableNew * @param BrowserInterface $browser * @return void */ public function processAssert(UrlRewrite $urlRewrite, CmsPage $cmsPage, SystemVariableNew $systemVariableNew, BrowserInterface $browser) { $browser->open($_ENV['app_frontend_url'] . $urlRewrite->getRequestPath()); if ($urlRewrite->hasData('store_id')) { $store = explode('/', $urlRewrite->getStoreId()); $systemVariableNew->getFormPageActions()->selectStoreView($store[2]); } $url = $urlRewrite->getRedirectType() == 'No' ? $urlRewrite->getRequestPath() : $cmsPage->getTitle(); \PHPUnit_Framework_Assert::assertEquals($_ENV['app_frontend_url'] . $url, $browser->getUrl(), 'URL rewrite CMS Page redirect false.'); }
/** * Assert category general information * * @param Category $category * @param array $categoryData * @return void */ protected function assertGeneralInformation(Category $category, array $categoryData) { $categoryUrl = $this->getCategoryUrl($category); \PHPUnit_Framework_Assert::assertEquals($categoryUrl, $this->browser->getUrl(), 'Wrong page URL.' . "\nExpected: " . $categoryUrl . "\nActual: " . $this->browser->getUrl()); if (isset($categoryData['name'])) { $title = $this->categoryViewPage->getTitleBlock()->getTitle(); \PHPUnit_Framework_Assert::assertEquals($categoryData['name'], $title, 'Wrong page title.' . "\nExpected: " . $categoryData['name'] . "\nActual: " . $title); } if (isset($categoryData['description'])) { $description = $this->categoryViewPage->getViewBlock()->getDescription(); \PHPUnit_Framework_Assert::assertEquals($categoryData['description'], $description, 'Wrong category description.' . "\nExpected: " . $categoryData['description'] . "\nActual: " . $description); } }
/** * Verify category Search Engine Optimization data: * # URL * # Meta Title * * @param array $categoryData * @return array */ protected function verifySearchEngineOptimization(array $categoryData) { $errorMessage = []; $categoryUrl = $this->getCategoryUrl($this->category); if ($categoryUrl != $this->browser->getUrl()) { $errorMessage[] = 'Wrong page URL.' . "\nExpected: " . $categoryUrl . "\nActual: " . $this->browser->getUrl(); } if (isset($categoryData['meta_title'])) { $actual = $this->categoryViewPage->getMetaInformation()->getTitle(); if ($categoryData['meta_title'] != $actual) { $errorMessage[] = 'Wrong page title.' . "\nExpected: " . $categoryData['meta_title'] . "\nActual: " . $actual; } } return $errorMessage; }
/** * Open Downloadable Link. * * @param OrderInjectable $order * @param int $downloads * @return void */ protected function openDownloadableLink(OrderInjectable $order, $downloads) { $customerLogin = $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $order->getDataFieldConfig('customer_id')['source']->getCustomer()]); $customerLogin->run(); $this->customerAccount->getAccountMenuBlock()->openMenuItem('My Downloadable Products'); $downloadableProductsUrl = $this->browser->getUrl(); foreach ($order->getEntityId()['products'] as $product) { foreach ($product->getDownloadableLinks()['downloadable']['link'] as $link) { for ($i = 0; $i < $downloads; $i++) { $this->browser->open($this->customerProducts->getMainBlock()->getLinkUrl($link['title'])); $this->browser->open($downloadableProductsUrl); } } } }
/** * Assert that after save a search term: * - it displays in the Search field at the top of the page if type set of characters passed from fixture * - after click 'Go' of Search field opens a results page if it was not specified Redirect URL * - after click 'Go' of Search field a customer search redirects to a specific page (passed from fixture) * if it was specified Redirect URL * * @param CmsIndex $cmsIndex * @param CatalogSearchQuery $searchTerm * @param BrowserInterface $browser * @return void */ public function processAssert(CmsIndex $cmsIndex, CatalogSearchQuery $searchTerm, BrowserInterface $browser) { $errors = []; $this->searchBlock = $cmsIndex->open()->getSearchBlock(); if ($searchTerm->hasData('display_in_terms') && $searchTerm->getDisplayInTerms() === 'Yes') { $errors = $this->checkSuggestSearch($searchTerm); } $this->searchBlock->search($searchTerm->getQueryText()); $windowUrl = $browser->getUrl(); $redirectUrl = $searchTerm->getRedirect(); if ($windowUrl !== $redirectUrl) { $errors[] = '- url window (' . $windowUrl . ') does not match the url redirect(' . $redirectUrl . ')'; } \PHPUnit_Framework_Assert::assertEmpty($errors, 'When checking on the frontend "Search terms" arose following errors:' . PHP_EOL . implode(PHP_EOL, $errors)); }
/** * Assert that you will be not redirected to url from dataset * * @param CmsIndex $cmsIndex * @param CatalogSearchQuery $searchTerm * @param BrowserInterface $browser * @return void */ public function processAssert(CmsIndex $cmsIndex, BrowserInterface $browser, CatalogSearchQuery $searchTerm) { $cmsIndex->open()->getSearchBlock()->search($searchTerm->getSynonymFor()); \PHPUnit_Framework_Assert::assertNotEquals($browser->getUrl(), $searchTerm->getRedirect(), 'Url in the browser corresponds to Url in fixture (redirect has been performed).' . PHP_EOL . 'Search term: "' . $searchTerm->getQueryText() . '"'); }
/** * Assert that old Category URL lead to appropriate Category in frontend * * @param Category $category * @param BrowserInterface $browser * @param Category $initialCategory * @return void */ public function processAssert(Category $category, BrowserInterface $browser, Category $initialCategory) { $browser->open($_ENV['app_frontend_url'] . $initialCategory->getUrlKey() . '.html'); \PHPUnit_Framework_Assert::assertEquals($browser->getUrl(), $_ENV['app_frontend_url'] . strtolower($category->getUrlKey()) . '.html', 'URL rewrite category redirect false.'); }
/** * Assert check URL rewrite category redirect * * @param UrlRewrite $urlRewrite * @param Category $category * @param BrowserInterface $browser * @return void */ public function processAssert(UrlRewrite $urlRewrite, Category $category, BrowserInterface $browser) { $browser->open($_ENV['app_frontend_url'] . $urlRewrite->getRequestPath()); $url = $urlRewrite->getRedirectType() == 'No' ? $urlRewrite->getRequestPath() : $category->getUrlKey() . '.html'; \PHPUnit_Framework_Assert::assertEquals($browser->getUrl(), $_ENV['app_frontend_url'] . $url, 'URL rewrite category redirect false.' . "\nExpected: " . $_ENV['app_frontend_url'] . $url . "\nActual: " . $browser->getUrl()); }