/**
  * Assert that the category is no longer available on the top menu bar
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogCategory $category
  * @param Browser $browser
  * @param CatalogCategoryView $categoryView
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogCategory $category, Browser $browser, CatalogCategoryView $categoryView)
 {
     $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($category->getName(), $categoryView->getTitleBlock()->getTitle(), 'Wrong page is displayed.');
     if (isset($category->getDataFieldConfig('category_products')['source'])) {
         $products = $category->getDataFieldConfig('category_products')['source']->getProducts();
         foreach ($products as $productFixture) {
             \PHPUnit_Framework_Assert::assertTrue($categoryView->getListProductBlock()->isProductVisible($productFixture->getName()), "Products '{$productFixture->getName()}' not find.");
         }
     }
 }
 /**
  * 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;
 }
Ejemplo n.º 3
0
 /**
  * Assert that the category cannot be accessed from the navigation bar in the frontend
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogCategory $category
  * @param Browser $browser
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogCategory $category, Browser $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 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);
 }
 /**
  * Assert that product is not visible in the assigned category
  *
  * @param CatalogCategoryView $catalogCategoryView
  * @param CmsIndex $cmsIndex
  * @param FixtureInterface $product
  * @param CatalogCategory|null $category
  * @return void
  */
 public function processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, FixtureInterface $product, CatalogCategory $category = null)
 {
     $categoryName = $category ? $category->getName() : $product->getCategoryIds()[0];
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
     $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
     while (!$isProductVisible && $catalogCategoryView->getBottomToolbar()->nextPage()) {
         $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
     }
     \PHPUnit_Framework_Assert::assertFalse($isProductVisible, 'Product is exist on category page.');
 }
 /**
  * Checking the product in the page of its price
  *
  * @param CatalogCategoryView $catalogCategoryView
  * @param CmsIndex $cmsIndex
  * @param FixtureInterface $product
  * @param CatalogCategory $category
  * @return void
  */
 public function processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, FixtureInterface $product, CatalogCategory $category)
 {
     // Open category view page and check visible product
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategoryByName($category->getName());
     $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
     while (!$isProductVisible && $catalogCategoryView->getToolbar()->nextPage()) {
         $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
     }
     \PHPUnit_Framework_Assert::assertTrue($isProductVisible, 'Product is absent on category page.');
     //Process price asserts
     $this->assertPrice($product, $catalogCategoryView);
 }
 /**
  * Assert that product is visible in the assigned category
  *
  * @param CatalogCategoryView $catalogCategoryView
  * @param CmsIndex $cmsIndex
  * @param FixtureInterface $product
  * @param CatalogCategory $category
  * @return void
  */
 public function processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, FixtureInterface $product, CatalogCategory $category)
 {
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategoryByName($category->getName());
     $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
     while (!$isProductVisible && $catalogCategoryView->getToolbar()->nextPage()) {
         $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
     }
     $isInStock = $product->getQuantityAndStockStatus();
     if ($product->getVisibility() === 'Search' || isset($isInStock['is_in_stock']) && $isInStock['is_in_stock'] === 'Out of Stock') {
         $isProductVisible = !$isProductVisible;
         $this->errorMessage = 'Product found in this category.';
         $this->successfulMessage = 'Asserts that the product could not be found in this category.';
     }
     \PHPUnit_Framework_Assert::assertTrue($isProductVisible, $this->errorMessage);
 }
 /**
  * Assert that product is visible in the assigned category
  *
  * @param CatalogCategoryView $catalogCategoryView
  * @param CmsIndex $cmsIndex
  * @param FixtureInterface $product
  * @param CatalogCategory|null $category
  * @return void
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, FixtureInterface $product, CatalogCategory $category = null)
 {
     $categoryName = $product->hasData('category_ids') ? $product->getCategoryIds()[0] : $category->getName();
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
     $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
     while (!$isProductVisible && $catalogCategoryView->getBottomToolbar()->nextPage()) {
         $isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
     }
     if ($product->getVisibility() === 'Search' || $this->getStockStatus($product) === 'Out of Stock') {
         $isProductVisible = !$isProductVisible;
         $this->errorMessage = 'Product found in this category.';
         $this->successfulMessage = 'Asserts that the product could not be found in this category.';
     }
     \PHPUnit_Framework_Assert::assertTrue($isProductVisible, $this->errorMessage);
 }
Ejemplo n.º 9
0
 /**
  * Select category
  *
  * @param FixtureInterface $fixture
  * @return void|null
  */
 protected function fillCategory(FixtureInterface $fixture)
 {
     // TODO should be removed after suggest widget implementation as typified element
     $categoryName = null;
     if (!empty($this->category)) {
         $categoryName = $this->category->getName();
     }
     if (empty($categoryName) && !$fixture instanceof InjectableFixture) {
         $categoryName = $fixture->getCategoryName();
     }
     if (empty($categoryName)) {
         return;
     }
     $category = $this->_rootElement->find(str_replace('%categoryName%', $categoryName, $this->categoryName), Locator::SELECTOR_XPATH);
     if (!$category->isVisible()) {
         $this->fillCategoryField($categoryName, 'category_ids-suggest', '//*[@id="attribute-category_ids-container"]');
     }
 }
Ejemplo n.º 10
0
 /**
  * Prepare category path
  *
  * @param CatalogCategory $category
  * @return array
  */
 protected function prepareFullCategoryPath(CatalogCategory $category)
 {
     $path = [];
     $parentCategory = $category->getDataFieldConfig('parent_id')['source']->getParentCategory();
     if ($parentCategory != null) {
         $path = $this->prepareFullCategoryPath($parentCategory);
     }
     return array_filter(array_merge($path, [$category->getPath(), $category->getName()]));
 }
 /**
  * Verifying that category present in Frontend with products
  *
  * @param CatalogCategory $category
  * @param array $products
  */
 protected function assertProductsOnCategory(CatalogCategory $category, array $products)
 {
     //Open created category on frontend
     $frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex();
     $categoryPage = Factory::getPageFactory()->getCatalogCategoryView();
     $frontendHomePage->open();
     $navigationMenu = $frontendHomePage->getTopmenu();
     $navigationMenu->selectCategoryByName($category->getName());
     $this->assertEquals($category->getName(), $frontendHomePage->getTitleBlock()->getTitle());
     $productListBlock = $categoryPage->getListProductBlock();
     /** @var Product $product */
     foreach ($products as $product) {
         $this->assertTrue($productListBlock->isProductVisible($product->getName()), 'Product is absent on category page.');
     }
 }
 /**
  * Test check create category rewrites
  *
  * @param UrlRewrite $urlRewrite
  * @param CatalogCategory $category
  * @return void
  */
 public function testCreateCategoryRewrite(UrlRewrite $urlRewrite, CatalogCategory $category)
 {
     //Steps
     $this->urlRewriteIndex->open();
     $this->urlRewriteIndex->getPageActionsBlock()->addNew();
     $this->urlRewriteEdit->getTreeBlock()->selectCategory($category->getName());
     $this->urlRewriteEdit->getFormBlock()->fill($urlRewrite);
     $this->urlRewriteEdit->getPageMainActions()->save();
 }