本文整理汇总了PHP中Magento\Catalog\Test\Page\Product\CatalogProductView类的典型用法代码示例。如果您正苦于以下问题:PHP CatalogProductView类的具体用法?PHP CatalogProductView怎么用?PHP CatalogProductView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CatalogProductView类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: processAssert
/**
* Assert Link block for downloadable product on front-end
*
* @param CatalogProductView $downloadableProductView
* @param CatalogProductDownloadable $product
* @param Browser $browser
* @return void
*/
public function processAssert(CatalogProductView $downloadableProductView, CatalogProductDownloadable $product, Browser $browser)
{
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$linksBlock = $downloadableProductView->getDownloadableViewBlock()->getDownloadableLinksBlock();
$fields = $product->getData();
// Title for for Link block
\PHPUnit_Framework_Assert::assertEquals($linksBlock->getTitleForLinkBlock(), $fields['downloadable_links']['title'], 'Title for for Link block for downloadable product on front-end is not correct.');
$this->sortDownloadableArray($fields['downloadable_links']['downloadable']['link']);
foreach ($fields['downloadable_links']['downloadable']['link'] as $index => $link) {
$index++;
// Titles for each links
// Links are displaying according to Sort Order
\PHPUnit_Framework_Assert::assertEquals($linksBlock->getItemTitle($index), $link['title'], 'Link item ' . $index . ' with title "' . $link['title'] . '" is not visible.');
// If Links can be Purchase Separately, check-nob is presented near each link
// If Links CANNOT be Purchase Separately, check-nob is not presented near each link
if ($fields['downloadable_links']['links_purchased_separately'] == "Yes") {
\PHPUnit_Framework_Assert::assertTrue($linksBlock->isVisibleItemCheckbox($index), 'Item ' . $index . ' link block CANNOT be Purchase Separately.');
// Price is equals passed according to fixture
$link['price'] = sprintf('$%1.2f', $link['price']);
\PHPUnit_Framework_Assert::assertEquals($linksBlock->getItemPrice($index), $link['price'], 'Link item ' . $index . ' price is not visible.');
} elseif ($fields['downloadable_links']['links_purchased_separately'] == "No") {
\PHPUnit_Framework_Assert::assertFalse($linksBlock->isVisibleItemCheckbox($index), 'Item ' . $index . ' link block can be Purchase Separately.');
}
}
}
开发者ID:aiesh,项目名称:magento2,代码行数:33,代码来源:AssertDownloadableLinksData.php
示例2: processAssert
/**
* 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.');
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:16,代码来源:AssertProductRatingNotInProductPage.php
示例3: assertPrice
/**
* Assert prices on the product view page and shopping cart page.
*
* @param BundleProduct $product
* @param CatalogProductView $catalogProductView
* @param CheckoutCart $checkoutCartView
* @param BundleProduct $originalProduct [optional]
* @return void
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function assertPrice(BundleProduct $product, CatalogProductView $catalogProductView, CheckoutCart $checkoutCartView, BundleProduct $originalProduct = null)
{
$customerGroup = 'NOT LOGGED IN';
$bundleData = $product->getData();
$this->productPriceType = $originalProduct !== null ? $originalProduct->getPriceType() : $product->getPriceType();
$catalogProductView->getViewBlock()->addToCart($product);
$catalogProductView->getMessagesBlock()->waitSuccessMessage();
$checkoutCartView->open();
$cartItem = $checkoutCartView->getCartBlock()->getCartItem($product);
$specialPrice = 0;
if (isset($bundleData['group_price'])) {
$specialPrice = $bundleData['group_price'][array_search($customerGroup, $bundleData['group_price'])]['price'] / 100;
}
$optionPrice = [];
$fillData = $product->getCheckoutData();
foreach ($fillData['options']['bundle_options'] as $key => $data) {
$subProductPrice = 0;
foreach ($bundleData['bundle_selections']['products'][$key] as $productKey => $itemProduct) {
if (strpos($itemProduct->getName(), $data['value']['name']) !== false) {
$data['value']['key'] = $productKey;
$subProductPrice = $itemProduct->getPrice();
}
}
$optionPrice[$key]['price'] = $this->productPriceType == 'Fixed' ? number_format($bundleData['bundle_selections']['bundle_options'][$key]['assigned_products'][$data['value']['key']]['data']['selection_price_value'], 2) : number_format($subProductPrice, 2);
}
foreach ($optionPrice as $index => $item) {
$item['price'] -= $item['price'] * $specialPrice;
\PHPUnit_Framework_Assert::assertEquals(number_format($item['price'], 2), $cartItem->getPriceBundleOptions($index + 1), 'Bundle item ' . ($index + 1) . ' options on frontend don\'t equal to fixture.');
}
$sumOptionsPrice = $product->getDataFieldConfig('price')['source']->getPriceData()['cart_price'];
$subTotal = number_format($cartItem->getPrice(), 2);
\PHPUnit_Framework_Assert::assertEquals($sumOptionsPrice, $subTotal, 'Bundle unit price on frontend doesn\'t equal to fixture.');
}
开发者ID:nja78,项目名称:magento2,代码行数:44,代码来源:AssertBundlePriceType.php
示例4: processAssert
/**
* Assert that In Stock status is displayed on product page
*
* @param CatalogProductView $catalogProductView
* @param FixtureInterface $product
* @return void
*/
public function processAssert(CatalogProductView $catalogProductView, FixtureInterface $product)
{
// TODO fix initialization url for frontend page
$catalogProductView->init($product);
$catalogProductView->open();
\PHPUnit_Framework_Assert::assertEquals(self::STOCK_AVAILABILITY, $catalogProductView->getViewBlock()->stockAvailability(), 'Control \'' . self::STOCK_AVAILABILITY . '\' is not visible.');
}
开发者ID:Atlis,项目名称:docker-magento2,代码行数:14,代码来源:AssertProductInStock.php
示例5: processAssert
/**
* 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));
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:22,代码来源:AssertProductPage.php
示例6: processAssert
/**
* 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());
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:17,代码来源:AssertUrlRewriteProductRedirect.php
示例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.');
}
开发者ID:aiesh,项目名称:magento2,代码行数:18,代码来源:AssertRelatedProductsSection.php
示例8: processAssert
/**
* 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());
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:AssertProductTierPriceOnProductPage.php
示例9: processAssert
/**
* Assert that product rating is not displayed on frontend on product review
*
* @param CatalogProductView $catalogProductView
* @param CatalogProductSimple $product
* @param Rating $productRating
* @param Browser $browser
* @param ReviewInjectable $review
* @return void
*/
public function processAssert(CatalogProductView $catalogProductView, CatalogProductSimple $product, Rating $productRating, Browser $browser, ReviewInjectable $review = null)
{
$product = $review === null ? $product : $review->getDataFieldConfig('entity_id')['source']->getEntity();
$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.');
}
开发者ID:aiesh,项目名称:magento2,代码行数:18,代码来源:AssertProductRatingNotInProductPage.php
示例10: processAssert
/**
* Assert that product rating is not displayed on frontend on product review
*
* @param CatalogProductView $catalogProductView
* @param CatalogProductSimple $product
* @param Rating $productRating
* @return void
*/
public function processAssert(CatalogProductView $catalogProductView, CatalogProductSimple $product, Rating $productRating)
{
$catalogProductView->init($product);
$catalogProductView->open();
$catalogProductView->getReviewSummaryBlock()->getAddReviewLink()->click();
$reviewForm = $catalogProductView->getReviewFormBlock();
\PHPUnit_Framework_Assert::assertFalse($reviewForm->isVisibleRating($productRating), 'Product rating "' . $productRating->getRatingCode() . '" is displayed.');
}
开发者ID:Atlis,项目名称:docker-magento2,代码行数:16,代码来源:AssertProductRatingNotInProductPage.php
示例11: processAssert
/**
* Assertion that the product is correctly displayed in cart
*
* @param Browser $browser
* @param CatalogProductView $catalogProductView
* @param CheckoutCart $checkoutCart
* @param ConfigurableProductInjectable $product
* @return void
*/
public function processAssert(Browser $browser, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, ConfigurableProductInjectable $product)
{
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$catalogProductView->getViewBlock()->addToCart($product);
$checkoutData = $product->getCheckoutData();
$price = $checkoutCart->getCartBlock()->getCartItem($product)->getPrice();
\PHPUnit_Framework_Assert::assertEquals($checkoutData['cartItem']['price'], $price, 'Product price in shopping cart is not correct.');
}
开发者ID:zhangjiachao,项目名称:magento2,代码行数:17,代码来源:AssertConfigurableProductInCart.php
示例12: assertPrice
/**
* Verify product special price on product view page
*
* @param CatalogProductView $catalogProductView
* @param FixtureInterface $product
* @param string $block [optional]
* @return void
*/
public function assertPrice(FixtureInterface $product, CatalogProductView $catalogProductView, $block = '')
{
$fields = $product->getData();
$specialPrice = $catalogProductView->getViewBlock()->getPriceBlock()->getSpecialPrice();
if (isset($fields['special_price'])) {
\PHPUnit_Framework_Assert::assertEquals(number_format($fields['special_price'], 2), $specialPrice, $this->errorMessage);
}
}
开发者ID:zhangjiachao,项目名称:magento2,代码行数:16,代码来源:AssertProductSpecialPriceOnProductPage.php
示例13: 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.');
}
开发者ID:Atlis,项目名称:docker-magento2,代码行数:18,代码来源:AssertNoUpSellsProductsSection.php
示例14: processAssert
/**
* 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
*/
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(in_array($label, $catalogProductCompare->getCompareProductsBlock()->getComparableAttributes()), 'Attribute is absent on product compare page.');
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:AssertProductAttributeIsComparable.php
示例15: processAssert
/**
* Assert that product rating is displayed on product review(frontend)
*
* @param CatalogProductView $catalogProductView
* @param CatalogProductSimple $product
* @param ReviewInjectable|null $review [optional]
* @param Rating|null $productRating [optional]
* @return void
*/
public function processAssert(CatalogProductView $catalogProductView, CatalogProductSimple $product, ReviewInjectable $review = null, Rating $productRating = null)
{
$catalogProductView->init($product);
$catalogProductView->open();
$catalogProductView->getReviewSummaryBlock()->getAddReviewLink()->click();
$rating = $productRating ? $productRating : $review->getDataFieldConfig('ratings')['source']->getRatings()[0];
$reviewForm = $catalogProductView->getReviewFormBlock();
\PHPUnit_Framework_Assert::assertTrue($reviewForm->isVisibleRating($rating), 'Product rating "' . $rating->getRatingCode() . '" is not displayed.');
}
开发者ID:Atlis,项目名称:docker-magento2,代码行数:18,代码来源:AssertProductRatingInProductPage.php
示例16: processAssert
/**
* Assert that default qty for sub products in grouped product displays according to dataset on product page.
*
* @param CatalogProductView $groupedProductView
* @param CatalogProductGrouped $product
* @param Browser $browser
* @return void
*/
public function processAssert(CatalogProductView $groupedProductView, CatalogProductGrouped $product, Browser $browser)
{
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$groupedBlock = $groupedProductView->getGroupedViewBlock()->getGroupedProductBlock();
$groupedProduct = $product->getData();
foreach ($groupedProduct['associated']['assigned_products'] as $item) {
\PHPUnit_Framework_Assert::assertEquals($groupedBlock->getQty($item['id']), $item['qty'], 'Default qty for sub product "' . $item['name'] . '" in grouped product according to dataset.');
}
}
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:AssertGroupedProductsDefaultQty.php
示例17: processAssert
/**
* Assert that product review Not available on product page
*
* @param CatalogProductView $catalogProductView
* @param ReviewInjectable $reviewInitial
* @param Browser $browser
* @return void
*/
public function processAssert(CatalogProductView $catalogProductView, ReviewInjectable $reviewInitial, Browser $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.');
}
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:AssertProductReviewNotOnProductPage.php
示例18: processAssert
/**
* 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.");
}
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:18,代码来源:AssertConfigurableAttributesAbsentOnProductPage.php
示例19: processAssert
/**
* Assertion that the product is correctly displayed in cart
*
* @param CatalogProductView $catalogProductView
* @param FixtureInterface $product
* @param Browser $browser
* @param CheckoutCart $checkoutCart
* @return void
*/
public function processAssert(CatalogProductView $catalogProductView, FixtureInterface $product, Browser $browser, CheckoutCart $checkoutCart)
{
// Add product to cart
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$catalogProductView->getViewBlock()->fillOptions($product);
$catalogProductView->getViewBlock()->clickAddToCart();
// Check price
$this->assertOnShoppingCart($product, $checkoutCart);
}
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:18,代码来源:AssertProductInCart.php
示例20: processAssert
/**
* 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);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:AssertDownloadableSamplesData.php
注:本文中的Magento\Catalog\Test\Page\Product\CatalogProductView类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论