/**
  * 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 the category cannot be accessed from the navigation bar in the frontend
  *
  * @param CmsIndex $cmsIndex
  * @param Category $category
  * @param BrowserInterface $browser
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, Category $category, BrowserInterface $browser)
 {
     $cmsIndex->open();
     \PHPUnit_Framework_Assert::assertFalse($cmsIndex->getTopmenu()->isCategoryVisible($category->getName()), 'Category can be accessed from the navigation bar in the frontend.');
     $browser->open($_ENV['app_frontend_url'] . $category->getUrlKey() . '.html');
     \PHPUnit_Framework_Assert::assertEquals(self::NOT_FOUND_MESSAGE, $cmsIndex->getTitleBlock()->getTitle(), 'Wrong page is displayed.');
 }
 /**
  * Assert that product rating is not displayed on frontend on product review
  *
  * @param CatalogProductView $catalogProductView
  * @param CatalogProductSimple $product
  * @param Rating $productRating
  * @param BrowserInterface $browser
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, CatalogProductSimple $product, Rating $productRating, BrowserInterface $browser)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getReviewSummary()->getAddReviewLink()->click();
     $reviewForm = $catalogProductView->getReviewFormBlock();
     \PHPUnit_Framework_Assert::assertFalse($reviewForm->isVisibleRating($productRating), 'Product rating "' . $productRating->getRatingCode() . '" is displayed.');
 }
 /**
  * Open product on frontend and click Checkout with PayPal button.
  *
  * @return void
  */
 public function run()
 {
     $product = reset($this->products);
     $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $parentWindow = $this->catalogProductView->getViewBlock()->braintreePaypalCheckout();
     $this->catalogProductView->getBraintreePaypalBlock()->process($parentWindow);
 }
Ejemplo n.º 5
0
 /**
  * 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 created entity was found on search page
  *
  * @param UrlRewrite $initialRewrite
  * @param UrlRewrite $urlRewrite
  * @param BrowserInterface $browser
  * @param CatalogCategoryView $categoryView
  * @return void
  */
 public function processAssert(UrlRewrite $initialRewrite, UrlRewrite $urlRewrite, BrowserInterface $browser, CatalogCategoryView $categoryView)
 {
     $urlRequestPath = $urlRewrite->hasData('request_path') ? $urlRewrite->getRequestPath() : $initialRewrite->getRequestPath();
     $browser->open($_ENV['app_frontend_url'] . $urlRequestPath);
     $entity = $urlRewrite->getDataFieldConfig('target_path')['source']->getEntity()->getName();
     \PHPUnit_Framework_Assert::assertTrue($categoryView->getListProductBlock()->isProductVisible($entity), "Created entity '{$entity}' isn't found.");
 }
Ejemplo n.º 7
0
 /**
  * Assert that displayed price view for bundle product on product page equals passed from fixture.
  *
  * @param CatalogProductView $catalogProductView
  * @param BrowserInterface $browser
  * @param BundleProduct $product
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, BrowserInterface $browser, BundleProduct $product)
 {
     //Open product view page
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     //Process assertions
     $this->assertPrice($product, $catalogProductView);
 }
Ejemplo n.º 8
0
 /**
  * Assert that product is not displayed in up-sell section
  *
  * @param BrowserInterface $browser
  * @param CatalogProductSimple $product
  * @param InjectableFixture[] $relatedProducts
  * @param CatalogProductView $catalogProductView
  * @return void
  */
 public function processAssert(BrowserInterface $browser, CatalogProductSimple $product, array $relatedProducts, CatalogProductView $catalogProductView)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     foreach ($relatedProducts as $relatedProduct) {
         \PHPUnit_Framework_Assert::assertFalse($catalogProductView->getUpsellBlock()->isUpsellProductVisible($relatedProduct->getName()), 'Product \'' . $relatedProduct->getName() . '\' is exist in up-sells products.');
     }
 }
 /**
  * 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.');
 }
 /**
  * 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 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 whether there is an opportunity to compare products using given attribute.
  *
  * @param InjectableFixture $product
  * @param CatalogProductAttribute $attribute
  * @param BrowserInterface $browser
  * @param CatalogProductView $catalogProductView
  * @param CatalogProductCompare $catalogProductCompare
  * @return void
  */
 public function processAssert(InjectableFixture $product, CatalogProductAttribute $attribute, BrowserInterface $browser, CatalogProductView $catalogProductView, CatalogProductCompare $catalogProductCompare)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->clickAddToCompare();
     $catalogProductCompare->open();
     $label = $attribute->hasData('manage_frontend_label') ? $attribute->getManageFrontendLabel() : $attribute->getFrontendLabel();
     \PHPUnit_Framework_Assert::assertTrue($catalogProductCompare->getCompareProductsBlock()->isAttributeVisible($label), 'Attribute is absent on product compare page.');
 }
 /**
  * Check that product available by new URL on the front
  *
  * @param UrlRewrite $urlRewrite
  * @param CatalogProductView $catalogProductView
  * @param BrowserInterface $browser
  * @param InjectableFixture $product
  * @return void
  */
 public function processAssert(UrlRewrite $urlRewrite, CatalogProductView $catalogProductView, BrowserInterface $browser, InjectableFixture $product = null)
 {
     $browser->open($_ENV['app_frontend_url'] . $urlRewrite->getRequestPath());
     if ($product === null) {
         $product = $urlRewrite->getDataFieldConfig('target_path')['source']->getEntity();
     }
     \PHPUnit_Framework_Assert::assertEquals($catalogProductView->getTitleBlock()->getTitle(), $product->getName(), 'URL rewrite product redirect false.' . "\nExpected: " . $product->getName() . "\nActual: " . $catalogProductView->getTitleBlock()->getTitle());
 }
Ejemplo n.º 14
0
 /**
  * Assert that displayed product data on product page(front-end) equals passed from fixture:
  * 1. Product Name
  * 2. Price
  * 3. Special price
  * 4. SKU
  * 5. Description
  * 6. Short Description
  *
  * @param BrowserInterface $browser
  * @param CatalogProductView $catalogProductView
  * @param FixtureInterface $product
  * @return void
  */
 public function processAssert(BrowserInterface $browser, CatalogProductView $catalogProductView, FixtureInterface $product)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $this->product = $product;
     $this->productView = $catalogProductView->getViewBlock();
     $errors = $this->verify();
     \PHPUnit_Framework_Assert::assertEmpty($errors, "\nFound the following errors:\n" . implode(" \n", $errors));
 }
 /**
  * Assert check URL rewrite custom redirect
  *
  * @param UrlRewrite $urlRewrite
  * @param BrowserInterface $browser
  * @param CmsIndex $cmsIndex
  * @return void
  */
 public function processAssert(UrlRewrite $urlRewrite, BrowserInterface $browser, CmsIndex $cmsIndex)
 {
     $browser->open($_ENV['app_frontend_url'] . $urlRewrite->getRequestPath());
     $entity = $urlRewrite->getDataFieldConfig('target_path')['source']->getEntity();
     $title = $entity->hasData('name') ? $entity->getName() : $entity->getContentHeading();
     $pageTitle = $cmsIndex->getTitleBlock()->getTitle();
     \PHPUnit_Framework_Assert::assertEquals($pageTitle, $title, 'URL rewrite product redirect false.' . "\nExpected: " . $title . "\nActual: " . $pageTitle);
 }
Ejemplo n.º 16
0
 /**
  * Assert that displayed price for bundle items on shopping cart page equals to passed from fixture.
  *   Price for bundle items has two options:
  *   1. Fixed (price of bundle product)
  *   2. Dynamic (price of bundle item)
  *
  * @param CatalogProductView $catalogProductView
  * @param BundleProduct $product
  * @param CheckoutCart $checkoutCartView
  * @param BrowserInterface $browser
  * @param BundleProduct $originalProduct [optional]
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, BundleProduct $product, CheckoutCart $checkoutCartView, BrowserInterface $browser, BundleProduct $originalProduct = null)
 {
     $checkoutCartView->open()->getCartBlock()->clearShoppingCart();
     //Open product view page
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     //Process assertions
     $this->assertPrice($product, $catalogProductView, $checkoutCartView, $originalProduct);
 }
 /**
  * Assertion that tier prices are displayed correctly
  *
  * @param BrowserInterface $browser
  * @param CatalogProductView $catalogProductView
  * @param FixtureInterface $product
  * @return void
  */
 public function processAssert(BrowserInterface $browser, CatalogProductView $catalogProductView, FixtureInterface $product)
 {
     // TODO fix initialization url for frontend page
     //Open product view page
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     //Process assertions
     $this->assertPrice($product, $catalogProductView->getViewBlock());
 }
 /**
  * Assert that created CMS page with 'Status' - Disabled displays with '404 Not Found' message on Frontend.
  *
  * @param CmsPage $cms
  * @param FrontCmsIndex $frontCmsIndex
  * @param CmsPageIndex $cmsIndex
  * @param BrowserInterface $browser
  * @return void
  */
 public function processAssert(CmsPage $cms, FrontCmsIndex $frontCmsIndex, CmsPageIndex $cmsIndex, BrowserInterface $browser)
 {
     $cmsIndex->open();
     $filter = ['title' => $cms->getTitle()];
     $cmsIndex->getCmsPageGridBlock()->searchAndPreview($filter);
     $browser->selectWindow();
     \PHPUnit_Framework_Assert::assertEquals(self::NOT_FOUND_MESSAGE, $frontCmsIndex->getTitleBlock()->getTitle(), 'Wrong page is displayed.');
 }
 /**
  * Assert that product review Not available on product page
  *
  * @param CatalogProductView $catalogProductView
  * @param Review $reviewInitial
  * @param BrowserInterface $browser
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, Review $reviewInitial, BrowserInterface $browser)
 {
     /** @var CatalogProductSimple $product */
     $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $reviewBlock = $catalogProductView->getCustomerReviewBlock();
     $catalogProductView->getViewBlock()->selectTab('Reviews');
     \PHPUnit_Framework_Assert::assertFalse($reviewBlock->isVisibleReviewItem(), 'Error, product review is displayed.');
 }
 /**
  * Assert that product can be added to active gift registry from shopping cart.
  *
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param InjectableFixture $product
  * @param GiftRegistry $giftRegistry
  * @param GiftRegistryItems $giftRegistryItems
  * @param BrowserInterface $browser
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, InjectableFixture $product, GiftRegistry $giftRegistry, GiftRegistryItems $giftRegistryItems, BrowserInterface $browser)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     $catalogProductView->getMessagesBlock()->waitSuccessMessage();
     $checkoutCart->open();
     $checkoutCart->getGiftRegistryBlock()->addToGiftRegistry($giftRegistry);
     \PHPUnit_Framework_Assert::assertTrue($giftRegistryItems->getGiftRegistryItemsBlock()->isProductInGrid($product), "Product can not be added to active gift registry '{$giftRegistry->getTitle()}' from shopping cart.");
 }
Ejemplo n.º 21
0
 /**
  * Set category value.
  *
  * @param array|string $value
  * @return void
  */
 public function setValue($value)
 {
     // Align Category ids select element to the center of the browser for created categories
     if ($this->browser->find($this->pageFooter)->isVisible()) {
         $this->browser->find($this->pageFooter)->hover();
         $this->browser->find($this->advancedInventoryButton)->hover();
     }
     parent::setValue($value);
 }
 /**
  * Assert that deleted configurable attributes are absent on product page on frontend.
  *
  * @param CatalogProductAttribute[] $deletedProductAttributes
  * @param BrowserInterface $browser
  * @param CatalogProductView $catalogProductView
  * @param ConfigurableProduct $product
  * @return void
  */
 public function processAssert(array $deletedProductAttributes, BrowserInterface $browser, CatalogProductView $catalogProductView, ConfigurableProduct $product)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $pageOptions = $catalogProductView->getViewBlock()->getOptions($product)['configurable_options'];
     foreach ($deletedProductAttributes as $attribute) {
         $attributeLabel = $attribute->getFrontendLabel();
         \PHPUnit_Framework_Assert::assertFalse(isset($pageOptions[$attributeLabel]), "Configurable attribute '{$attributeLabel}' found on product page on frontend.");
     }
 }
 /**
  * Assert Sample block for downloadable product on front-end
  *
  * @param CatalogProductView $productView
  * @param DownloadableProduct $product
  * @param BrowserInterface $browser
  * @return void
  */
 public function processAssert(CatalogProductView $productView, DownloadableProduct $product, BrowserInterface $browser)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $fixtureSampleLinks = $this->prepareFixtureData($product);
     $pageOptions = $productView->getViewBlock()->getOptions($product);
     $pageSampleLinks = isset($pageOptions['downloadable_options']['downloadable_sample']) ? $this->preparePageData($pageOptions['downloadable_options']['downloadable_sample']) : [];
     $error = $this->verifyData($fixtureSampleLinks, $pageSampleLinks);
     \PHPUnit_Framework_Assert::assertEmpty($error, $error);
 }
 /**
  * Asserts that user has only related permissions.
  *
  * @param BrowserInterface $browser
  * @param Dashboard $dashboard
  * @param User $user
  * @param array $restrictedAccess
  * @param string $denyUrl
  * @return void
  */
 public function processAssert(BrowserInterface $browser, Dashboard $dashboard, User $user, array $restrictedAccess, $denyUrl)
 {
     $this->objectManager->create('Magento\\User\\Test\\TestStep\\LoginUserOnBackendStep', ['user' => $user])->run();
     $menuItems = $dashboard->getMenuBlock()->getTopMenuItems();
     \PHPUnit_Framework_Assert::assertEquals($menuItems, $restrictedAccess, 'Wrong display menu.');
     $browser->open($_ENV['app_backend_url'] . $denyUrl);
     $deniedMessage = $dashboard->getAccessDeniedBlock()->getTextFromAccessDeniedBlock();
     \PHPUnit_Framework_Assert::assertEquals(self::DENIED_ACCESS, $deniedMessage, 'Possible access to denied page.');
 }
 /**
  * Assertion that tier prices are displayed correctly
  *
  * @param BrowserInterface $browser
  * @param CatalogProductView $catalogProductView
  * @param FixtureInterface $product
  * @return void
  */
 public function processAssert(BrowserInterface $browser, CatalogProductView $catalogProductView, FixtureInterface $product)
 {
     //Open product view page
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $viewBlock = $catalogProductView->getBundleViewBlock();
     $viewBlock->clickCustomize();
     //Process assertions
     $this->assertPrice($product, $viewBlock);
 }
 /**
  * Assert that displayed assigned products on category page equals passed from fixture
  *
  * @param Category $category
  * @param CatalogCategoryView $categoryView
  * @param BrowserInterface $browser
  * @return void
  */
 public function processAssert(Category $category, CatalogCategoryView $categoryView, BrowserInterface $browser)
 {
     $categoryUrlKey = $category->hasData('url_key') ? strtolower($category->getUrlKey()) : trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-');
     $products = $category->getDataFieldConfig('category_products')['source']->getProducts();
     $browser->open($_ENV['app_frontend_url'] . $categoryUrlKey . '.html');
     foreach ($products as $productFixture) {
         \PHPUnit_Framework_Assert::assertTrue($categoryView->getListProductBlock()->getProductItem($productFixture)->isVisible(), "Products '{$productFixture->getName()}' not find.");
     }
 }
 /**
  * Assert that product is not displayed in up-sell section.
  *
  * @param BrowserInterface $browser
  * @param CatalogProductSimple $product
  * @param CatalogProductView $catalogProductView
  * @param InjectableFixture[]|null $promotedProducts
  * @return void
  */
 public function processAssert(BrowserInterface $browser, CatalogProductSimple $product, CatalogProductView $catalogProductView, array $promotedProducts = null)
 {
     if (!$promotedProducts) {
         $promotedProducts = $product->hasData('up_sell_products') ? $product->getDataFieldConfig('up_sell_products')['source']->getProducts() : [];
     }
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     foreach ($promotedProducts as $promotedProduct) {
         \PHPUnit_Framework_Assert::assertFalse($catalogProductView->getUpsellBlock()->getProductItem($promotedProduct)->isVisible(), 'Product \'' . $promotedProduct->getName() . '\' is exist in up-sells products.');
     }
 }
 /**
  * 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 that Compare Products block is presented on CMS pages.
  * Block contains information about compared products
  *
  * @param array $products
  * @param CmsIndex $cmsIndex
  * @param FixtureFactory $fixtureFactory
  * @param BrowserInterface $browser
  * @return void
  */
 public function processAssert(array $products, CmsIndex $cmsIndex, FixtureFactory $fixtureFactory, BrowserInterface $browser)
 {
     $newCmsPage = $fixtureFactory->createByCode('cmsPage', ['dataset' => '3_column_template']);
     $newCmsPage->persist();
     $browser->open($_ENV['app_frontend_url'] . $newCmsPage->getIdentifier());
     foreach ($products as &$product) {
         $product = $product->getName();
     }
     \PHPUnit_Framework_Assert::assertEquals($products, $cmsIndex->getCompareProductsBlock()->getProducts(), 'Compare product block contains NOT valid information about compared products.');
 }
 /**
  * Assert that newsletter preview opened in new window and template content correct
  *
  * @param BrowserInterface $browser
  * @param TemplatePreview $templatePreview
  * @param Template $newsletter
  * @return void
  */
 public function processAssert(BrowserInterface $browser, TemplatePreview $templatePreview, Template $newsletter)
 {
     $browser->selectWindow();
     $content = $templatePreview->getContent()->getPageContent();
     $browser->closeWindow();
     \PHPUnit_Framework_Assert::assertEquals($newsletter->getText(), $content, 'Template content not correct information.');
 }