/**
  * 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);
 }
コード例 #2
0
 /**
  * Create Customer account on Storefront.
  *
  * @param Customer $customer
  * @return void
  */
 public function test(Customer $customer)
 {
     // Steps
     $this->cmsIndex->open();
     $this->cmsIndex->getLinksBlock()->openLink('Create an Account');
     $this->customerAccountCreate->getRegisterForm()->registerCustomer($customer);
 }
コード例 #3
0
 /**
  * Create Customer account on frontend
  *
  * @param CustomerInjectable $customer
  */
 public function testCreateCustomer(CustomerInjectable $customer)
 {
     //Steps
     $this->cmsIndex->open();
     $this->cmsIndex->getLinksBlock()->openLink('Register');
     $this->customerAccountCreate->getRegisterForm()->registerCustomer($customer);
 }
 /**
  * Check that block Recently Viewed contains product on category page
  *
  * @param CatalogProductSimple $productSimple
  * @param Category $category
  * @return void
  */
 protected function checkRecentlyViewedBlockOnCategory(CatalogProductSimple $productSimple, Category $category)
 {
     $this->cmsIndex->open();
     $this->cmsIndex->getTopmenu()->selectCategoryByName($category->getName());
     $products = $this->catalogCategoryView->getViewBlock()->getProductsFromRecentlyViewedBlock();
     \PHPUnit_Framework_Assert::assertTrue(in_array($productSimple->getName(), $products), 'Product' . $productSimple->getName() . ' is absent on Recently Viewed block on Category page.');
 }
コード例 #5
0
 /**
  * Login customer and open Order page.
  *
  * @param Customer $customer
  * @return void
  */
 protected function loginCustomerAndOpenOrderPage(Customer $customer)
 {
     $this->cmsIndex->open();
     $loginCustomerOnFrontendStep = $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer]);
     $loginCustomerOnFrontendStep->run();
     $this->cmsIndex->getLinksBlock()->openLink('My Account');
     $this->customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Orders');
 }
コード例 #6
0
 /**
  * Logout customer
  *
  * @return void
  */
 public function run()
 {
     $this->cmsIndex->open();
     $this->cmsIndex->getCmsPageBlock()->waitPageInit();
     if ($this->cmsIndex->getLinksBlock()->isLinkVisible("Log Out")) {
         $this->cmsIndex->getLinksBlock()->openLink("Log Out");
         $this->cmsIndex->getCmsPageBlock()->waitUntilTextIsVisible('Home Page');
     }
 }
 /**
  * Create Existing Customer account on frontend.
  *
  * @param Customer $customer
  * @return void
  */
 public function testCreateExistingCustomer(Customer $customer)
 {
     // Precondition
     $existingCustomer = clone $customer;
     $customer->persist();
     // Steps
     $this->cmsIndex->open();
     $this->cmsIndex->getLinksBlock()->openLink('Create an Account');
     $this->customerAccountCreate->getRegisterForm()->registerCustomer($existingCustomer);
 }
コード例 #8
0
 /**
  * Run edit search term test
  *
  * @param CatalogSearchQuery $searchTerm
  * @return void
  */
 public function test(CatalogSearchQuery $searchTerm)
 {
     // Preconditions
     $searchText = $searchTerm->getQueryText();
     // Steps
     $this->cmsIndex->open()->getSearchBlock()->search($searchText);
     $this->indexPage->open()->getGrid()->searchAndOpen(['search_query' => $searchText]);
     $this->editPage->getForm()->fill($searchTerm);
     $this->editPage->getFormPageActions()->save();
 }
コード例 #9
0
 /**
  * Search Terms Report.
  *
  * @param string $product
  * @param int $countProducts
  * @param int $countSearch
  * @return array
  */
 public function test($product, $countProducts, $countSearch)
 {
     // Preconditions
     $productName = $this->createProducts($product, $countProducts);
     // Steps
     $this->cmsIndex->open();
     $this->searchProducts($productName, $countSearch);
     $this->searchIndex->open();
     return ['productName' => $productName];
 }
コード例 #10
0
 /**
  * Login customer.
  *
  * @return void
  */
 public function run()
 {
     $this->cmsIndex->open();
     $this->cmsIndex->getCmsPageBlock()->waitPageInit();
     if ($this->cmsIndex->getLinksBlock()->isLinkVisible("Log Out")) {
         $this->cmsIndex->getLinksBlock()->openLink("Log Out");
         $this->cmsIndex->getCmsPageBlock()->waitUntilTextIsVisible('Home Page');
     }
     $this->cmsIndex->getLinksBlock()->openLink("Log In");
     $this->customerAccountLogin->getLoginBlock()->login($this->customer);
 }
コード例 #11
0
 /**
  * Runs Delete Customer Address test.
  *
  * @param Customer $customer
  * @return array
  */
 public function test(Customer $customer)
 {
     $this->markTestIncomplete('Bug: MAGETWO-34634');
     // Precondition:
     $customer->persist();
     $addressToDelete = $customer->getDataFieldConfig('address')['source']->getAddresses()[1];
     // Steps:
     $this->cmsIndex->open();
     $this->cmsIndex->getLinksBlock()->openLink("Log In");
     $this->customerAccountLogin->getLoginBlock()->login($customer);
     $this->customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book');
     $this->customerAccountIndex->getAdditionalAddressBlock()->deleteAdditionalAddress($addressToDelete);
     return ['deletedAddress' => $addressToDelete];
 }
コード例 #12
0
 /**
  * "Add to cart" button is display on Product page
  *
  * @return void
  */
 protected function addToCardPresentOnProduct()
 {
     $this->cmsIndex->open();
     $this->cmsIndex->getTopmenu()->selectCategoryByName($this->product->getCategoryIds()[0]);
     $this->catalogCategoryView->getListProductBlock()->openProductViewPage($this->product->getName());
     \PHPUnit_Framework_Assert::assertTrue($this->catalogProductView->getViewBlock()->checkAddToCardButton(), "Button 'Add to Card' is absent on Product page.");
 }
コード例 #13
0
 /**
  * Assert that apache redirect works by opening category page and asserting index.php in its url
  *
  * @param Category $category
  * @param CmsIndex $homePage
  * @param BrowserInterface $browser
  */
 public function processAssert(Category $category, CmsIndex $homePage, BrowserInterface $browser)
 {
     $category->persist();
     $homePage->open();
     $homePage->getTopmenu()->selectCategoryByName($category->getName());
     \PHPUnit_Framework_Assert::assertTrue(strpos($browser->getUrl(), 'index.php') === false, 'Apache redirect for category does not work.');
 }
 /**
  * Verify product displaying on frontend
  *
  * @param FixtureInterface $product
  * @return array
  */
 protected function isNotDisplayingOnFrontendAssert(FixtureInterface $product)
 {
     $errors = [];
     // Check the product page is not available
     // TODO fix initialization url for frontend page
     $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $titleBlock = $this->catalogProductView->getTitleBlock();
     if ($titleBlock->getTitle() !== self::NOT_FOUND_MESSAGE) {
         $errors[] = '- the headline on the page does not match, the text should be -> "' . self::NOT_FOUND_MESSAGE . '".';
     }
     $this->cmsIndex->open();
     $this->cmsIndex->getSearchBlock()->search($product->getSku());
     if ($this->catalogSearchResult->getListProductBlock()->isProductVisible($product->getName())) {
         $errors[] = '- successful product search.';
     }
     $categoryName = $product->hasData('category_ids') ? $product->getCategoryIds()[0] : $this->category->getName();
     $this->cmsIndex->open();
     $this->cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
     $isProductVisible = $this->catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
     while (!$isProductVisible && $this->catalogCategoryView->getBottomToolbar()->nextPage()) {
         $isProductVisible = $this->catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
     }
     if ($isProductVisible) {
         $errors[] = "- product with name '{$product->getName()}' is found in this category.";
     }
     return $errors;
 }
コード例 #15
0
 /**
  * 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.');
 }
コード例 #16
0
 /**
  * Check whether the attribute filter is displayed on the frontend in Layered navigation.
  *
  * @param CatalogCategoryView $catalogCategoryView
  * @param InjectableFixture $product
  * @param CatalogProductAttribute $attribute
  * @param CmsIndex $cmsIndex
  * @param FixtureFactory $fixtureFactory
  * @return void
  */
 public function processAssert(CatalogCategoryView $catalogCategoryView, InjectableFixture $product, CatalogProductAttribute $attribute, CmsIndex $cmsIndex, FixtureFactory $fixtureFactory)
 {
     $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'product_with_category_with_anchor', 'data' => ['category_ids' => ['presets' => null, 'category' => $product->getDataFieldConfig('category_ids')['source']->getCategories()[0]]]])->persist();
     $cmsIndex->open()->getTopmenu()->selectCategoryByName($product->getCategoryIds()[0]);
     $label = $attribute->hasData('manage_frontend_label') ? $attribute->getManageFrontendLabel() : $attribute->getFrontendLabel();
     \PHPUnit_Framework_Assert::assertTrue(in_array($label, $catalogCategoryView->getLayeredNavigationBlock()->getFilters()), 'Attribute is absent in layered navigation on category page.');
 }
コード例 #17
0
 /**
  * Assert that video is displayed on category page on Store front.
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param InjectableFixture $initialProduct
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, InjectableFixture $initialProduct)
 {
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategoryByName($initialProduct->getCategoryIds()[0]);
     $src = $catalogCategoryView->getListProductBlock()->getProductItem($initialProduct)->getBaseImageSource();
     \PHPUnit_Framework_Assert::assertFalse(strpos($src, '/placeholder/') !== false, 'Video preview image is not displayed on category view when it should.');
 }
コード例 #18
0
 /**
  * Assert that product is not displayed in up-sell section
  *
  * @param CatalogProductSimple $product1
  * @param CatalogProductSimple $product2
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CatalogProductView $catalogProductView
  * @return void
  */
 public function processAssert(CatalogProductSimple $product1, CatalogProductSimple $product2, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView)
 {
     $categoryName = $product1->getCategoryIds()[0]['name'];
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
     $catalogCategoryView->getListProductBlock()->openProductViewPage($product1->getName());
     \PHPUnit_Framework_Assert::assertFalse($catalogProductView->getUpsellBlock()->isUpsellProductVisible($product2->getName()), 'Product \'' . $product2->getName() . '\' is exist in up-sells products.');
 }
コード例 #19
0
 /**
  * Assert configurable product, corresponds to the category page
  *
  * @param CatalogCategoryView $catalogCategoryView
  * @param CmsIndex $cmsIndex
  * @param CatalogProductConfigurable $configurable
  * @param CatalogCategory $category
  * @return void
  */
 public function processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, CatalogProductConfigurable $configurable, CatalogCategory $category)
 {
     //Open category view page
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategoryByName($category->getName());
     //process asserts
     $this->assertPrice($configurable, $catalogCategoryView);
 }
コード例 #20
0
 /**
  * Run test creation for advanced search entity.
  *
  * @param CatalogProductSimple $productSearch
  * @param CmsIndex $cmsIndex
  * @param AdvancedSearch $searchPage
  * @return void
  */
 public function test(CatalogProductSimple $productSearch, CmsIndex $cmsIndex, AdvancedSearch $searchPage)
 {
     $cmsIndex->open();
     $cmsIndex->getFooterBlock()->openAdvancedSearch();
     $searchForm = $searchPage->getForm();
     $searchForm->fill($productSearch);
     $searchForm->submit();
 }
 /**
  * Assert product is present on mini shopping cart
  *
  * @param CmsIndex $cmsIndex
  * @param array $products
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, array $products)
 {
     $cmsIndex->open();
     foreach ($products as $product) {
         $cmsIndex->getCartSidebarBlock()->openMiniCart();
         \PHPUnit_Framework_Assert::assertTrue($cmsIndex->getCartSidebarBlock()->getCartItem($product)->isVisible(), 'Product ' . $product->getName() . ' is absent in Mini Shopping Cart.');
     }
 }
 /**
  * Login customer
  *
  * @param CustomerInjectable $customer
  * @return void
  */
 protected function loginCustomer(CustomerInjectable $customer)
 {
     $this->cmsIndex->open();
     if (!$this->cmsIndex->getLinksBlock()->isLinkVisible('Log Out')) {
         $this->cmsIndex->getLinksBlock()->openLink('Log In');
         $this->customerAccountLogin->getLoginBlock()->login($customer);
     }
 }
コード例 #23
0
 /**
  * Run test creation for advanced search entity
  *
  * @param array $products
  * @param CatalogProductSimple $productSearch
  * @param CmsIndex $cmsIndex
  * @param AdvancedSearch $searchPage
  * @return void
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function testSearch(array $products, CatalogProductSimple $productSearch, CmsIndex $cmsIndex, AdvancedSearch $searchPage)
 {
     $cmsIndex->open();
     $cmsIndex->getSearchBlock()->clickAdvancedSearchButton();
     $searchForm = $searchPage->getForm();
     $searchForm->fill($productSearch);
     $searchForm->submit();
 }
コード例 #24
0
 /**
  * Assert that product is displayed in related products section
  *
  * @param CatalogProductSimple $product1
  * @param CatalogProductSimple $product2
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CatalogProductView $catalogProductView
  * @return void
  */
 public function processAssert(CatalogProductSimple $product1, CatalogProductSimple $product2, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView)
 {
     $categoryName = $product1->getCategoryIds()[0];
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
     $catalogCategoryView->getListProductBlock()->openProductViewPage($product1->getName());
     \PHPUnit_Framework_Assert::assertTrue($catalogProductView->getRelatedProductBlock()->isRelatedProductVisible($product2->getName()), 'Product \'' . $product2->getName() . '\' is absent in related products.');
 }
コード例 #25
0
 /**
  * Assert that created store view available on frontend (store view selector on page top)
  *
  * @param Store $store
  * @param CmsIndex $cmsIndex
  * @return void
  */
 public function processAssert(Store $store, CmsIndex $cmsIndex)
 {
     $cmsIndex->open();
     if ($cmsIndex->getFooterBlock()->isStoreGroupSwitcherVisible() && $cmsIndex->getFooterBlock()->isStoreGroupVisible($store)) {
         $cmsIndex->getFooterBlock()->selectStoreGroup($store);
     }
     $isStoreViewVisible = !$cmsIndex->getStoreSwitcherBlock()->isStoreViewDropdownVisible() ? true : $cmsIndex->getStoreSwitcherBlock()->isStoreViewVisible($store);
     \PHPUnit_Framework_Assert::assertTrue($isStoreViewVisible, "Store view is not visible in dropdown on CmsIndex page");
 }
コード例 #26
0
 /**
  * Assert that created CMS block displayed on frontend category page (in order to assign block to category:
  * go to category page> Display settings> CMS Block).
  *
  * @param CmsIndex $cmsIndex
  * @param CmsBlock $cmsBlock
  * @param CatalogCategoryView $catalogCategoryView
  * @param FixtureFactory $fixtureFactory
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CmsBlock $cmsBlock, CatalogCategoryView $catalogCategoryView, FixtureFactory $fixtureFactory)
 {
     $category = $fixtureFactory->createByCode('category', ['dataset' => 'default_subcategory', 'data' => ['display_mode' => 'Static block and products', 'landing_page' => $cmsBlock->getTitle()]]);
     $category->persist();
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategoryByName($category->getName());
     $categoryViewContent = $catalogCategoryView->getViewBlock()->getContent();
     \PHPUnit_Framework_Assert::assertEquals($cmsBlock->getContent(), $categoryViewContent, 'Wrong block content on category is displayed.');
 }
 /**
  * Assert that Catalog Price Rule is not applied for product(s) in Catalog.
  *
  * @param CmsIndex $cmsIndexPage
  * @param CatalogCategoryView $catalogCategoryViewPage
  * @param array $products
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndexPage, CatalogCategoryView $catalogCategoryViewPage, array $products)
 {
     $cmsIndexPage->open();
     foreach ($products as $product) {
         $categoryName = $product->getCategoryIds()[0];
         $cmsIndexPage->getTopmenu()->selectCategoryByName($categoryName);
         $priceBlock = $catalogCategoryViewPage->getListProductBlock()->getProductItem($product)->getPriceBlock();
         \PHPUnit_Framework_Assert::assertFalse($priceBlock->isSpecialPriceVisible(), "Catalog price rule is applied!\n");
     }
 }
コード例 #28
0
 /**
  * Assert that after applying changes, currency symbol changed on Product Details Page.
  *
  * @param CatalogProductSimple $product
  * @param BrowserInterface $browser
  * @param CmsIndex $cmsIndex
  * @param CatalogProductView $catalogProductView
  * @param CurrencySymbolEntity $currencySymbol
  * @return void
  */
 public function processAssert(CatalogProductSimple $product, BrowserInterface $browser, CmsIndex $cmsIndex, CatalogProductView $catalogProductView, CurrencySymbolEntity $currencySymbol)
 {
     $cmsIndex->open();
     $cmsIndex->getCurrencyBlock()->switchCurrency($currencySymbol);
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $price = $catalogProductView->getViewBlock()->getPriceBlock()->getPrice();
     preg_match('`(.*?)\\d`', $price, $matches);
     $symbolOnPage = isset($matches[1]) ? $matches[1] : null;
     \PHPUnit_Framework_Assert::assertEquals($currencySymbol->getCustomCurrencySymbol(), $symbolOnPage, 'Wrong Currency Symbol is displayed on Product page.');
 }
コード例 #29
0
 /**
  * Assert that created widget is absent on frontend on Home page
  *
  * @param CmsIndex $cmsIndex
  * @param Widget $widget
  * @param AdminCache $adminCache
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, Widget $widget, AdminCache $adminCache)
 {
     // Flush cache
     $adminCache->open();
     $adminCache->getActionsBlock()->flushMagentoCache();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     $cmsIndex->open();
     $widgetText = $widget->getParameters()['anchor_text'];
     \PHPUnit_Framework_Assert::assertFalse($cmsIndex->getWidgetView()->isWidgetVisible($widget, $widgetText), 'Widget is present on Home page.');
 }
コード例 #30
0
 /**
  * Assert that after applying changes, currency symbol changed on Catalog page
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CatalogProductSimple $product
  * @param CurrencySymbolEntity $currencySymbol
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductSimple $product, CurrencySymbolEntity $currencySymbol)
 {
     $categoryName = $product->getCategoryIds()[0];
     $cmsIndex->open();
     $cmsIndex->getCurrencyBlock()->switchCurrency($currencySymbol);
     $cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
     $price = $catalogCategoryView->getListProductBlock()->getProductItem($product)->getPriceBlock()->getPrice('');
     preg_match('`(.*?)\\d`', $price, $matches);
     $symbolOnPage = isset($matches[1]) ? $matches[1] : null;
     \PHPUnit_Framework_Assert::assertEquals($currencySymbol->getCustomCurrencySymbol(), $symbolOnPage, 'Wrong Currency Symbol is displayed on Category page.');
 }