本文整理汇总了PHP中Magento\Catalog\Test\Page\Category\CatalogCategoryView类的典型用法代码示例。如果您正苦于以下问题:PHP CatalogCategoryView类的具体用法?PHP CatalogCategoryView怎么用?PHP CatalogCategoryView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CatalogCategoryView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processAssert
/**
* 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.');
}
示例2: processAssert
/**
* Assert that displayed category data on category page equals to passed from fixture
*
* @param CatalogCategory $category
* @param CatalogCategory $initialCategory
* @param FixtureFactory $fixtureFactory
* @param CatalogCategoryView $categoryView
* @param Browser $browser
* @return void
*/
public function processAssert(CatalogCategory $category, CatalogCategory $initialCategory, FixtureFactory $fixtureFactory, CatalogCategoryView $categoryView, Browser $browser)
{
$product = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'default', 'data' => ['category_ids' => ['category' => $initialCategory]]]);
$categoryData = array_merge($initialCategory->getData(), $category->getData());
$product->persist();
$url = $_ENV['app_frontend_url'] . strtolower($category->getUrlKey()) . '.html';
$browser->open($url);
\PHPUnit_Framework_Assert::assertEquals($url, $browser->getUrl(), 'Wrong page URL.' . "\nExpected: " . $url . "\nActual: " . $browser->getUrl());
if (isset($categoryData['name'])) {
$title = $categoryView->getTitleBlock()->getTitle();
\PHPUnit_Framework_Assert::assertEquals($categoryData['name'], $title, 'Wrong page title.' . "\nExpected: " . $categoryData['name'] . "\nActual: " . $title);
}
if (isset($categoryData['description'])) {
$description = $categoryView->getViewBlock()->getDescription();
\PHPUnit_Framework_Assert::assertEquals($categoryData['description'], $description, 'Wrong category description.' . "\nExpected: " . $categoryData['description'] . "\nActual: " . $description);
}
if (isset($categoryData['default_sort_by'])) {
$sortBy = strtolower($categoryData['default_sort_by']);
$sortType = $categoryView->getTopToolbar()->getSelectSortType();
\PHPUnit_Framework_Assert::assertEquals($sortBy, $sortType, 'Wrong sorting type.' . "\nExpected: " . $sortBy . "\nActual: " . $sortType);
}
if (isset($categoryData['available_sort_by'])) {
$availableSortType = array_filter($categoryData['available_sort_by'], function (&$value) {
return $value !== '-' && ucfirst($value);
});
if ($availableSortType) {
$availableSortType = array_values($availableSortType);
$availableSortTypeOnPage = $categoryView->getTopToolbar()->getSortType();
\PHPUnit_Framework_Assert::assertEquals($availableSortType, $availableSortTypeOnPage, 'Wrong available sorting type.' . "\nExpected: " . implode(PHP_EOL, $availableSortType) . "\nActual: " . implode(PHP_EOL, $availableSortTypeOnPage));
}
}
}
示例3: processAssert
/**
* 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.');
}
示例4: processAssert
/**
* Assert that created entity was found on search page
*
* @param UrlRewrite $initialRewrite
* @param UrlRewrite $urlRewrite
* @param Browser $browser
* @param CatalogCategoryView $categoryView
* @return void
*/
public function processAssert(UrlRewrite $initialRewrite, UrlRewrite $urlRewrite, Browser $browser, CatalogCategoryView $categoryView)
{
$urlRequestPath = $urlRewrite->hasData('request_path') ? $urlRewrite->getRequestPath() : $initialRewrite->getRequestPath();
$browser->open($_ENV['app_frontend_url'] . $urlRequestPath);
$entity = $initialRewrite->getDataFieldConfig('id_path')['source']->getEntity()->getName();
\PHPUnit_Framework_Assert::assertTrue($categoryView->getListProductBlock()->isProductVisible($entity), "Created entity '{$entity}' isn't found.");
}
示例5: processAssert
/**
* Assert that displayed assigned products on category page equals passed from fixture
*
* @param CatalogCategory $category
* @param CatalogCategoryView $categoryView
* @param Browser $browser
* @return void
*/
public function processAssert(CatalogCategory $category, CatalogCategoryView $categoryView, Browser $browser)
{
$browser->open($_ENV['app_frontend_url'] . strtolower($category->getUrlKey()) . '.html');
$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.");
}
}
示例6: processAssert
/**
* Assert that displayed breadcrumbs on category page equals to passed from fixture.
*
* @param BrowserInterface $browser
* @param Category $category
* @param CatalogCategoryView $catalogCategoryView
* @return void
*/
public function processAssert(BrowserInterface $browser, Category $category, CatalogCategoryView $catalogCategoryView)
{
$this->browser = $browser;
$this->openCategory($category);
$breadcrumbs = $this->getBreadcrumbs($category);
$pageBreadcrumbs = $catalogCategoryView->getBreadcrumbs()->getText();
\PHPUnit_Framework_Assert::assertEquals($breadcrumbs, $pageBreadcrumbs, 'Wrong breadcrumbs of category page.' . "\nExpected: " . $breadcrumbs . "\nActual: " . $pageBreadcrumbs);
}
示例7: processAssert
/**
* 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.');
}
示例8: processAssert
/**
* 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.');
}
示例9: assertPrice
/**
* Verify product price on category view page.
*
* @param FixtureInterface $product
* @param CatalogCategoryView $catalogCategoryView
* @return void
*/
protected function assertPrice(FixtureInterface $product, CatalogCategoryView $catalogCategoryView)
{
$priceBlock = $catalogCategoryView->getListProductBlock()->getProductItem($product)->getPriceBlock();
\PHPUnit_Framework_Assert::assertEquals(number_format($product->getPrice(), 2, '.', ''), $priceBlock->isOldPriceVisible() ? $priceBlock->getOldPrice() : $priceBlock->getPrice(), 'Product regular price on category page is not correct.');
if ($product->hasData('special_price')) {
\PHPUnit_Framework_Assert::assertEquals(number_format($product->getSpecialPrice(), 2, '.', ''), $priceBlock->getSpecialPrice(), 'Product special price on category page is not correct.');
}
}
示例10: processAssert
/**
* 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.");
}
}
示例11: processAssert
/**
* 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.');
}
示例12: processAssert
/**
* 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");
}
}
示例13: processAssert
/**
* Assert that product is displayed in cross-sell section
*
* @param CatalogProductSimple $product1
* @param CatalogProductSimple $product2
* @param CmsIndex $cmsIndex
* @param CatalogCategoryView $catalogCategoryView
* @param CatalogProductView $catalogProductView
* @param CheckoutCart $checkoutCart
* @return void
*/
public function processAssert(CatalogProductSimple $product1, CatalogProductSimple $product2, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart)
{
$categoryName = $product1->getCategoryIds()[0];
$checkoutCart->open();
$checkoutCart->getCartBlock()->clearShoppingCart();
$cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
$catalogCategoryView->getListProductBlock()->openProductViewPage($product1->getName());
$catalogProductView->getViewBlock()->addToCart($product1);
\PHPUnit_Framework_Assert::assertTrue($checkoutCart->getCrosssellBlock()->verifyProductCrosssell($product2), 'Product \'' . $product2->getName() . '\' is absent in cross-sell section.');
}
示例14: assertPrice
/**
* Verify product price on category view page
*
* @param CatalogProductBundle $bundle
* @param CatalogCategoryView $catalogCategoryView
* @return void
*/
protected function assertPrice(CatalogProductBundle $bundle, CatalogCategoryView $catalogCategoryView)
{
$priceData = $bundle->getDataFieldConfig('price')['source']->getPreset();
//Price from/to verification
$priceBlock = $catalogCategoryView->getListProductBlock()->getProductPriceBlock($bundle->getName());
$priceLow = $bundle->getPriceView() == 'Price Range' ? $priceBlock->getPriceFrom() : $priceBlock->getRegularPrice();
\PHPUnit_Framework_Assert::assertEquals($priceData['price_from'], $priceLow, 'Bundle price From on category page is not correct.');
if ($bundle->getPriceView() == 'Price Range') {
\PHPUnit_Framework_Assert::assertEquals($priceData['price_to'], $priceBlock->getPriceTo(), 'Bundle price To on category page is not correct.');
}
}
示例15: processAssert
/**
* Assert that product is not visible in the assigned category
*
* @param CatalogCategoryView $catalogCategoryView
* @param CmsIndex $cmsIndex
* @param FixtureInterface $product
* @param Category|null $category
* @return void
*/
public function processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, FixtureInterface $product, Category $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.');
}