本文整理匯總了PHP中Magento\Catalog\Test\Page\Product\CatalogProductView::getMessagesBlock方法的典型用法代碼示例。如果您正苦於以下問題:PHP CatalogProductView::getMessagesBlock方法的具體用法?PHP CatalogProductView::getMessagesBlock怎麽用?PHP CatalogProductView::getMessagesBlock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Catalog\Test\Page\Product\CatalogProductView
的用法示例。
在下文中一共展示了CatalogProductView::getMessagesBlock方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
/**
* Add products to the cart
*
* @return void
*/
public function run()
{
// Ensure that shopping cart is empty
$this->checkoutCart->open()->getCartBlock()->clearShoppingCart();
foreach ($this->products as $product) {
$this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$this->catalogProductView->getViewBlock()->addToCart($product);
$this->catalogProductView->getMessagesBlock()->waitSuccessMessage();
}
}
示例2: 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.');
}
示例3: addToCart
/**
* Fill options get price and add to cart
*
* @param CatalogProductSimple $product
* @param array $actualPrices
* @return array
*/
protected function addToCart(CatalogProductSimple $product, $actualPrices)
{
$this->catalogProductView->getViewBlock()->fillOptions($product);
$actualPrices['product_page_price'] = $this->catalogProductView->getViewBlock()->getPriceBlock()->getPrice();
$this->catalogProductView->getViewBlock()->clickAddToCart();
$this->catalogProductView->getMessagesBlock()->waitSuccessMessage();
return $actualPrices;
}
示例4: addProducts
/**
* Add products to compare list
*
* @param array $products
* @return void
*/
protected function addProducts(array $products)
{
foreach ($products as $itemProduct) {
$this->browser->open($_ENV['app_frontend_url'] . $itemProduct->getUrlKey() . '.html');
$this->catalogProductView->getViewBlock()->clickAddToCompare();
$this->catalogProductView->getMessagesBlock()->waitSuccessMessage();
}
}
示例5: processAssert
/**
* Assertion that the product is correctly displayed in cart
*
* @param CatalogProductView $catalogProductView
* @param FixtureInterface $product
* @param BrowserInterface $browser
* @param CheckoutCart $checkoutCart
* @return void
*/
public function processAssert(CatalogProductView $catalogProductView, FixtureInterface $product, BrowserInterface $browser, CheckoutCart $checkoutCart)
{
// Add product to cart
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$catalogProductView->getViewBlock()->fillOptions($product);
$catalogProductView->getViewBlock()->clickAddToCart();
$catalogProductView->getMessagesBlock()->waitSuccessMessage();
// Check price
$this->assertOnShoppingCart($product, $checkoutCart);
}
示例6: processAssert
/**
* Assertion that the product is correctly displayed in cart
*
* @param BrowserInterface $browser
* @param CatalogProductView $catalogProductView
* @param CheckoutCart $checkoutCart
* @param ConfigurableProduct $product
* @return void
*/
public function processAssert(BrowserInterface $browser, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, ConfigurableProduct $product)
{
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$catalogProductView->getViewBlock()->addToCart($product);
$catalogProductView->getMessagesBlock()->waitSuccessMessage();
$checkoutCart->open();
$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.');
}
示例7: addToCart
/**
* Fill options get price and add to cart
*
* @param CatalogProductSimple $product
* @param array $actualPrices
* @return array
*/
protected function addToCart(CatalogProductSimple $product, array $actualPrices)
{
$viewBlock = $this->catalogProductView->getViewBlock();
$priceBlock = $this->catalogProductView->getWeeeViewBlock()->getPriceBlock();
$viewBlock->fillOptions($product);
$actualPrices['product_page_price'] = $priceBlock->getPrice();
$actualPrices['product_page_fpt'] = $priceBlock->getFptPrice();
$actualPrices['product_page_fpt_total'] = $priceBlock->getFinalPrice();
$viewBlock->clickAddToCart();
$this->catalogProductView->getMessagesBlock()->waitSuccessMessage();
return $actualPrices;
}
示例8: addProductsToCart
/**
* Add products to cart.
*
* @param array $productQuantity
* @return void
*/
protected function addProductsToCart(array $productQuantity)
{
foreach ($productQuantity as $product => $quantity) {
if ($quantity > 0) {
$categoryName = $this->{$product}->getCategoryIds()[0];
$this->cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
$this->catalogCategoryView->getListProductBlock()->getProductItem($this->{$product})->open();
$this->catalogProductView->getViewBlock()->setQtyAndClickAddToCart($quantity);
$this->catalogProductView->getMessagesBlock()->waitSuccessMessage();
}
}
}
示例9: processAssert
/**
* Assert that product is not displayed in cross-sell section.
*
* @param BrowserInterface $browser
* @param CatalogProductSimple $product
* @param CatalogProductView $catalogProductView
* @param CheckoutCart $checkoutCart
* @param InjectableFixture[]|null $promotedProducts
* @return void
*/
public function processAssert(BrowserInterface $browser, CatalogProductSimple $product, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, array $promotedProducts = null)
{
if (!$promotedProducts) {
$promotedProducts = $product->hasData('cross_sell_products') ? $product->getDataFieldConfig('cross_sell_products')['source']->getProducts() : [];
}
$checkoutCart->open();
$checkoutCart->getCartBlock()->clearShoppingCart();
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$catalogProductView->getViewBlock()->addToCart($product);
$catalogProductView->getMessagesBlock()->waitSuccessMessage();
$checkoutCart->open();
foreach ($promotedProducts as $promotedProduct) {
\PHPUnit_Framework_Assert::assertFalse($checkoutCart->getCrosssellBlock()->getProductItem($promotedProduct)->isVisible(), 'Product \'' . $promotedProduct->getName() . '\' is exist in cross-sell section.');
}
}
示例10: processAssert
/**
* Place order and verify there is no checkbox Terms and Conditions.
*
* @param FixtureFactory $fixtureFactory
* @param ObjectManager $objectManager
* @param string $product
* @param BrowserInterface $browser
* @param CatalogProductView $catalogProductView
* @param CheckoutCart $checkoutCart
* @param CheckoutOnepage $checkoutOnepage
* @param CheckoutAgreement $agreement
* @param array $shipping
* @param array $payment
* @return void
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function processAssert(FixtureFactory $fixtureFactory, ObjectManager $objectManager, $product, BrowserInterface $browser, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, CheckoutOnepage $checkoutOnepage, CheckoutAgreement $agreement, $shipping, $payment)
{
$createProductsStep = $objectManager->create('Magento\\Catalog\\Test\\TestStep\\CreateProductsStep', ['products' => $product]);
$product = $createProductsStep->run();
$billingAddress = $fixtureFactory->createByCode('address', ['dataset' => 'default']);
$browser->open($_ENV['app_frontend_url'] . $product['products'][0]->getUrlKey() . '.html');
$catalogProductView->getViewBlock()->clickAddToCartButton();
$catalogProductView->getMessagesBlock()->waitSuccessMessage();
$checkoutCart->open();
$checkoutCart->getCartBlock()->getOnepageLinkBlock()->proceedToCheckout();
$checkoutOnepage->getLoginBlock()->clickContinue();
$checkoutOnepage->getBillingBlock()->fill($billingAddress);
$checkoutOnepage->getBillingBlock()->clickContinue();
$checkoutOnepage->getShippingMethodBlock()->selectShippingMethod($shipping);
$checkoutOnepage->getShippingMethodBlock()->clickContinue();
$checkoutOnepage->getPaymentBlock()->selectPaymentMethod($payment);
\PHPUnit_Framework_Assert::assertFalse($checkoutOnepage->getAgreementReview()->checkAgreement($agreement), 'Checkout Agreement \'' . $agreement->getName() . '\' is present in the Place order step.');
}
示例11: processAssert
/**
* Assert product MAP related data in Shopping Cart.
*
* @param CmsIndex $cmsIndex
* @param CatalogCategoryView $catalogCategoryView
* @param CatalogProductView $catalogProductView
* @param CheckoutCart $checkoutCart
* @param InjectableFixture $product
* @return void
*/
public function processAssert(CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, InjectableFixture $product)
{
/** @var CatalogProductSimple $product */
$cmsIndex->open();
$cmsIndex->getTopmenu()->selectCategoryByName($product->getCategoryIds()[0]);
$catalogCategoryView->getListProductBlock()->getProductItem($product)->open();
if ($product->hasData('checkout_data')) {
$catalogProductView->getViewBlock()->addToCart($product);
} else {
$catalogProductView->getMsrpViewBlock()->openMapBlock();
$catalogProductView->getMsrpViewBlock()->getMapBlock()->addToCart();
}
$catalogProductView->getMessagesBlock()->waitSuccessMessage();
$checkoutCart->open();
$productPrice = $product->hasData('checkout_data') ? $product->getCheckoutData()['cartItem']['price'] : $product->getPrice();
$unitPrice = $checkoutCart->getCartBlock()->getCartItem($product)->getPrice();
\PHPUnit_Framework_Assert::assertEquals($productPrice, $unitPrice, 'Incorrect unit price is displayed in Cart');
}
示例12: test
/**
* Update Shopping Cart
*
* @param CatalogProductSimple $product
* @return array
*/
public function test(CatalogProductSimple $product)
{
// Preconditions
$product->persist();
$this->checkoutCart->getCartBlock()->clearShoppingCart();
// Steps
$this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$productView = $this->catalogProductView->getViewBlock();
$productView->fillOptions($product);
$productView->setQty(1);
$productView->clickAddToCart();
$this->catalogProductView->getMessagesBlock()->waitSuccessMessage();
$qty = $product->getCheckoutData()['qty'];
$this->checkoutCart->open();
$this->checkoutCart->getCartBlock()->getCartItem($product)->setQty($qty);
$this->checkoutCart->getCartBlock()->updateShoppingCart();
$cart['data']['items'] = ['products' => [$product]];
return ['cart' => $this->fixtureFactory->createByCode('cart', $cart)];
}
示例13: processAssert
/**
* Check that checkbox is present on the last checkout step - Order Review.
* Check that after Place order without click on checkbox "Terms and Conditions" order was not successfully placed.
* Check that after clicking on "Terms and Conditions" checkbox and "Place Order" button success place order message
* appears.
*
* @param FixtureFactory $fixtureFactory
* @param ObjectManager $objectManager
* @param string $product
* @param BrowserInterface $browser
* @param CatalogProductView $catalogProductView
* @param CheckoutCart $checkoutCart
* @param CheckoutOnepage $checkoutOnepage
* @param CheckoutOnepageSuccess $checkoutOnepageSuccess
* @param AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage
* @param array $shipping
* @param array $payment
* @return void
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function processAssert(FixtureFactory $fixtureFactory, ObjectManager $objectManager, $product, BrowserInterface $browser, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, CheckoutOnepage $checkoutOnepage, CheckoutOnepageSuccess $checkoutOnepageSuccess, AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage, $shipping, $payment)
{
$createProductsStep = $objectManager->create('Magento\\Catalog\\Test\\TestStep\\CreateProductsStep', ['products' => $product]);
$product = $createProductsStep->run();
$billingAddress = $fixtureFactory->createByCode('address', ['dataset' => 'default']);
$browser->open($_ENV['app_frontend_url'] . $product['products'][0]->getUrlKey() . '.html');
$catalogProductView->getViewBlock()->clickAddToCartButton();
$catalogProductView->getMessagesBlock()->waitSuccessMessage();
$checkoutCart->open();
$checkoutCart->getCartBlock()->getOnepageLinkBlock()->proceedToCheckout();
$checkoutOnepage->getLoginBlock()->clickContinue();
$checkoutOnepage->getBillingBlock()->fill($billingAddress);
$checkoutOnepage->getBillingBlock()->clickContinue();
$checkoutOnepage->getShippingMethodBlock()->selectShippingMethod($shipping);
$checkoutOnepage->getShippingMethodBlock()->clickContinue();
$checkoutOnepage->getPaymentBlock()->selectPaymentMethod($payment);
$checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->clickPlaceOrder();
\PHPUnit_Framework_Assert::assertEquals(self::NOTIFICATION_MESSAGE, $checkoutOnepage->getAgreementReview()->getNotificationMassage(), 'Notification required message of Terms and Conditions is absent.');
$checkoutOnepage->getAgreementReview()->setAgreement('Yes');
$checkoutOnepage->getAgreementReview()->placeOrder();
$assertOrderSuccessPlacedMessage->processAssert($checkoutOnepageSuccess);
}
示例14: processAssert
/**
* Assert that specified prices are actual on category, product and cart pages.
*
* @param InjectableFixture $product
* @param array $prices
* @param int $qty
* @param CmsIndex $cmsIndex
* @param CatalogCategoryView $catalogCategoryView
* @param CatalogProductView $catalogProductView
* @param CheckoutCart $checkoutCart
* @param FixtureFactory $fixtureFactory
* @return void
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function processAssert(InjectableFixture $product, array $prices, $qty, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, FixtureFactory $fixtureFactory)
{
$this->cmsIndex = $cmsIndex;
$this->catalogCategoryView = $catalogCategoryView;
$this->catalogProductView = $catalogProductView;
$this->checkoutCart = $checkoutCart;
$actualPrices = [];
//Assertion steps
$productCategory = $product->getCategoryIds()[0];
$this->openCategory($productCategory);
$actualPrices = $this->getCategoryPrices($product, $actualPrices);
$catalogCategoryView->getListProductBlock()->getProductItem($product)->open();
$catalogProductView->getViewBlock()->fillOptions($product);
$actualPrices = $this->getProductPagePrices($actualPrices);
$catalogProductView->getViewBlock()->clickAddToCart();
$catalogProductView->getMessagesBlock()->waitSuccessMessage();
$actualPrices = $this->getCartPrices($product, $actualPrices);
$actualPrices = $this->getTotals($actualPrices);
//Prices verification
$message = 'Prices from dataset should be equal to prices on frontend';
\PHPUnit_Framework_Assert::assertEquals($prices, $actualPrices, $message);
}
示例15: processAssert
/**
* Assert success message is presented on page
*
* @param CatalogProductView $catalogProductView
* @param FixtureInterface $product
* @return void
*/
public function processAssert(CatalogProductView $catalogProductView, FixtureInterface $product)
{
$successMessage = sprintf(self::SUCCESS_MESSAGE, $product->getName());
$actualMessage = $catalogProductView->getMessagesBlock()->getSuccessMessages();
\PHPUnit_Framework_Assert::assertEquals($successMessage, $actualMessage, 'Wrong success message is displayed.' . "\nExpected: " . $successMessage . "\nActual: " . $actualMessage);
}