本文整理汇总了PHP中Magento\Checkout\Test\Page\CheckoutCart类的典型用法代码示例。如果您正苦于以下问题:PHP CheckoutCart类的具体用法?PHP CheckoutCart怎么用?PHP CheckoutCart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CheckoutCart类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: processAssert
/**
* Assert that shipping amount is equal to expected.
*
* @param CheckoutCart $checkoutCart
* @param Cart $cart
* @return void
*/
public function processAssert(CheckoutCart $checkoutCart, Cart $cart)
{
$checkoutCart->open();
$fixtureShippingAmount = number_format((double) $cart->getShippingAmount(), 2);
$pageShippingAmount = $checkoutCart->getTotalsBlock()->getShippingPrice();
\PHPUnit_Framework_Assert::assertEquals($fixtureShippingAmount, $pageShippingAmount, 'Shipping amount in the shopping cart not equals to shipping amount from fixture.');
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:AssertShippingInShoppingCart.php
示例2: processAssert
/**
* Assert that prices on order review and customer order pages are equal to specified in dataset.
*
* @param array $prices
* @param InjectableFixture $product
* @param CheckoutCart $checkoutCart
* @param CheckoutOnepage $checkoutOnepage
* @param CheckoutOnepageSuccess $checkoutOnepageSuccess
* @param CustomerOrderView $customerOrderView
* @param CmsIndex $cmsIndex
* @return void
*/
public function processAssert(array $prices, InjectableFixture $product, CheckoutCart $checkoutCart, CheckoutOnepage $checkoutOnepage, CheckoutOnepageSuccess $checkoutOnepageSuccess, CustomerOrderView $customerOrderView, CmsIndex $cmsIndex)
{
$this->checkoutOnepage = $checkoutOnepage;
$this->customerOrderView = $customerOrderView;
$checkoutCart->getProceedToCheckoutBlock()->proceedToCheckout();
$cmsIndex->getCmsPageBlock()->waitPageInit();
$shippingMethod = ['shipping_service' => 'Flat Rate', 'shipping_method' => 'Fixed'];
$checkoutOnepage->getShippingMethodBlock()->selectShippingMethod($shippingMethod);
$checkoutOnepage->getShippingMethodBlock()->clickContinue();
$checkoutOnepage->getPaymentBlock()->selectPaymentMethod(['method' => 'checkmo']);
$actualPrices = [];
$actualPrices = $this->getReviewPrices($actualPrices, $product);
$actualPrices = $this->getReviewTotals($actualPrices);
$prices = $this->preparePrices($prices);
//Order review prices verification
$message = 'Prices on order review should be equal to defined in dataset.';
\PHPUnit_Framework_Assert::assertEquals(array_diff_key($prices, ['cart_item_price_excl_tax' => null, 'cart_item_price_incl_tax' => null]), $actualPrices, $message);
$checkoutOnepage->getPaymentBlock()->placeOrder();
$checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId();
$checkoutOnepageSuccess->getSuccessBlock()->openOrder();
$actualPrices = [];
$actualPrices = $this->getOrderPrices($actualPrices, $product);
$actualPrices = $this->getOrderTotals($actualPrices);
//Frontend order prices verification
$message = 'Prices on order view page should be equal to defined in dataset.';
\PHPUnit_Framework_Assert::assertEquals($prices, $actualPrices, $message);
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:39,代码来源:AbstractAssertTaxCalculationAfterCheckout.php
示例3: assertOnShoppingCart
/**
* Assert prices on the shopping cart
*
* @param FixtureInterface $product
* @param CheckoutCart $checkoutCart
* @return void
*/
protected function assertOnShoppingCart(FixtureInterface $product, CheckoutCart $checkoutCart)
{
$customOptions = $product->getCustomOptions();
$checkoutData = $product->getCheckoutData();
$checkoutCustomOptions = isset($checkoutData['custom_options']) ? $checkoutData['custom_options'] : [];
$fixturePrice = $product->getPrice();
$groupPrice = $product->getGroupPrice();
$specialPrice = $product->getSpecialPrice();
$cartItem = $checkoutCart->getCartBlock()->getCartItem($product);
$formPrice = $cartItem->getPrice();
if ($groupPrice) {
$groupPrice = reset($groupPrice);
$fixturePrice = $groupPrice['price'];
}
if ($specialPrice) {
$fixturePrice = $specialPrice;
}
$fixtureActualPrice = $fixturePrice;
foreach ($checkoutCustomOptions as $checkoutOption) {
$attributeKey = $checkoutOption['title'];
$optionKey = $checkoutOption['value'];
$option = $customOptions[$attributeKey]['options'][$optionKey];
if ('Fixed' == $option['price_type']) {
$fixtureActualPrice += $option['price'];
} else {
$fixtureActualPrice += $fixturePrice / 100 * $option['price'];
}
}
\PHPUnit_Framework_Assert::assertEquals(number_format($fixtureActualPrice, 2), $formPrice, 'Product price in shopping cart is not correct.');
}
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:37,代码来源:AssertProductInCart.php
示例4: 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
示例5: processAssert
/**
* Assert that grand total is equal to expected
*
* @param CheckoutCart $checkoutCart
* @param Cart $cart
* @return void
*/
public function processAssert(CheckoutCart $checkoutCart, Cart $cart)
{
$checkoutCart->open();
$fixtureGrandTotal = number_format($cart->getGrandTotal(), 2);
$pageGrandTotal = $checkoutCart->getTotalsBlock()->getGrandTotal();
\PHPUnit_Framework_Assert::assertEquals($fixtureGrandTotal, $pageGrandTotal, 'Grand total price in the shopping cart not equals to grand total price from fixture.');
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:AssertGrandTotalInShoppingCart.php
示例6: processAssert
/**
* Assert that prices on order review and customer order pages are equal to specified in dataset.
*
* @param array $prices
* @param InjectableFixture $product
* @param CheckoutCart $checkoutCart
* @param CheckoutOnepage $checkoutOnepage
* @param CheckoutOnepageSuccess $checkoutOnepageSuccess
* @param CustomerOrderView $customerOrderView
* @return void
*/
public function processAssert(array $prices, InjectableFixture $product, CheckoutCart $checkoutCart, CheckoutOnepage $checkoutOnepage, CheckoutOnepageSuccess $checkoutOnepageSuccess, CustomerOrderView $customerOrderView)
{
$this->checkoutOnepage = $checkoutOnepage;
$this->customerOrderView = $customerOrderView;
$checkoutCart->getProceedToCheckoutBlock()->proceedToCheckout();
$checkoutOnepage->getBillingBlock()->clickContinue();
$checkoutOnepage->getPaymentMethodsBlock()->selectPaymentMethod(['method' => 'check_money_order']);
$checkoutOnepage->getPaymentMethodsBlock()->clickContinue();
$actualPrices = [];
$actualPrices = $this->getReviewPrices($actualPrices, $product);
$actualPrices = $this->getReviewTotals($actualPrices);
$prices = $this->preparePrices($prices);
//Order review prices verification
$message = 'Prices on order review should be equal to defined in dataset.';
\PHPUnit_Framework_Assert::assertEquals($prices, $actualPrices, $message);
$checkoutOnepage->getReviewBlock()->placeOrder();
$checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId();
$checkoutOnepageSuccess->getSuccessBlock()->openOrder();
$actualPrices = [];
$actualPrices = $this->getOrderPrices($actualPrices, $product);
$actualPrices = $this->getOrderTotals($actualPrices);
//Frontend order prices verification
$message = 'Prices on order view page should be equal to defined in dataset.';
\PHPUnit_Framework_Assert::assertEquals($prices, $actualPrices, $message);
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:36,代码来源:AbstractAssertTaxCalculationAfterCheckoutDownloadable.php
示例7: assertOnShoppingCart
/**
* Assert prices on the shopping cart
*
* @param FixtureInterface $product
* @param CheckoutCart $checkoutCart
* @return void
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function assertOnShoppingCart(FixtureInterface $product, CheckoutCart $checkoutCart)
{
$checkoutCart->open();
/** @var CatalogProductSimple $product */
$customOptions = $product->getCustomOptions();
$checkoutData = $product->getCheckoutData();
$checkoutCartItem = isset($checkoutData['cartItem']) ? $checkoutData['cartItem'] : [];
$checkoutCustomOptions = isset($checkoutData['options']['custom_options']) ? $checkoutData['options']['custom_options'] : [];
$fixturePrice = $product->getPrice();
$specialPrice = $product->getSpecialPrice();
$cartItem = $checkoutCart->getCartBlock()->getCartItem($product);
$formPrice = $cartItem->getPrice();
if ($specialPrice) {
$fixturePrice = $specialPrice;
}
if (isset($checkoutCartItem['price'])) {
$fixturePrice = $checkoutCartItem['price'];
}
$fixtureActualPrice = $fixturePrice;
foreach ($checkoutCustomOptions as $checkoutOption) {
$attributeKey = str_replace('attribute_key_', '', $checkoutOption['title']);
$optionKey = str_replace('option_key_', '', $checkoutOption['value']);
$option = $customOptions[$attributeKey]['options'][$optionKey];
if ('Fixed' == $option['price_type']) {
$fixtureActualPrice += $option['price'];
} else {
$fixtureActualPrice += $fixturePrice / 100 * $option['price'];
}
}
\PHPUnit_Framework_Assert::assertEquals($fixtureActualPrice, $formPrice, 'Product price in shopping cart is not correct.');
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:40,代码来源:AssertProductInCart.php
示例8: assertOnShoppingCart
/**
* Assert prices on the shopping cart
*
* @param FixtureInterface $product
* @param CheckoutCart $checkoutCart
* @return void
*/
protected function assertOnShoppingCart(FixtureInterface $product, CheckoutCart $checkoutCart)
{
$cartBlock = $checkoutCart->getCartBlock();
$productName = $product->getName();
$productOptions = $product->getCustomOptions();
$priceComparing = $product->getPrice();
if ($groupPrice = $product->getGroupPrice()) {
$groupPrice = reset($groupPrice);
$priceComparing = $groupPrice['price'];
}
if ($specialPrice = $product->getSpecialPrice()) {
$priceComparing = $specialPrice;
}
if (!empty($productOptions)) {
$productOption = reset($productOptions);
$optionsData = reset($productOption['options']);
$optionName = $cartBlock->getCartItemOptionsNameByProductName($productName);
$optionValue = $cartBlock->getCartItemOptionsValueByProductName($productName);
\PHPUnit_Framework_Assert::assertTrue(trim($optionName) === $productOption['title'] && trim($optionValue) === $optionsData['title'], 'In the cart wrong option product.');
if ($optionsData['price_type'] === 'Percent') {
$priceComparing = $priceComparing * (1 + $optionsData['price'] / 100);
} else {
$priceComparing += $optionsData['price'];
}
}
$price = $checkoutCart->getCartBlock()->getProductPriceByName($productName);
\PHPUnit_Framework_Assert::assertEquals(number_format($priceComparing, 2), $price, 'Product price in shopping cart is not correct.');
}
开发者ID:aiesh,项目名称:magento2,代码行数:35,代码来源:AssertProductInCart.php
示例9: processAssert
/**
* Assert that products are present in shopping cart
*
* @param CheckoutCart $checkoutCart
* @param array $products
* @return void
*/
public function processAssert(CheckoutCart $checkoutCart, array $products)
{
$checkoutCart->open();
foreach ($products as $product) {
\PHPUnit_Framework_Assert::assertTrue($checkoutCart->getCartBlock()->getCartItem($product)->isVisible(), 'Product ' . $product->getName() . ' is absent in shopping cart.');
}
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:AssertProductPresentInShoppingCart.php
示例10: processAssert
/**
* Check that Shopping Cart is empty, opened page contains text "You have no items in your shopping cart.
* Click here to continue shopping." where 'here' is link that leads to index page
*
* @param CheckoutCart $checkoutCart
* @param BrowserInterface $browser
* @return void
*/
public function processAssert(CheckoutCart $checkoutCart, BrowserInterface $browser)
{
$checkoutCart->open();
$cartEmptyBlock = $checkoutCart->getCartEmptyBlock();
\PHPUnit_Framework_Assert::assertEquals(self::TEXT_EMPTY_CART, $cartEmptyBlock->getText(), 'Wrong text on empty cart page.');
$cartEmptyBlock->clickLinkToMainPage();
\PHPUnit_Framework_Assert::assertEquals($_ENV['app_frontend_url'], $browser->getUrl(), 'Wrong link to main page on empty cart page.');
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:AssertCartIsEmpty.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: assertOnShoppingCart
/**
* Assert prices on the shopping Cart
*
* @param CatalogProductConfigurable $configurable
* @param CheckoutCart $checkoutCart
* @return void
*/
protected function assertOnShoppingCart(CatalogProductConfigurable $configurable, CheckoutCart $checkoutCart)
{
/** @var \Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable\Price $priceFixture */
$priceFixture = $configurable->getDataFieldConfig('price')['source'];
$pricePresetData = $priceFixture->getPreset();
$price = $checkoutCart->getCartBlock()->getProductPriceByName($configurable->getName());
\PHPUnit_Framework_Assert::assertEquals($pricePresetData['cart_price'], $price, 'Product price in shopping cart is not correct.');
}
开发者ID:Atlis,项目名称:docker-magento2,代码行数:15,代码来源:AssertConfigurableInCart.php
示例13: processAssert
/**
* Assert that tax amount is equal to expected.
*
* @param CheckoutCart $checkoutCart
* @param Cart $cart
* @param boolean $requireReload
* @return void
*/
public function processAssert(CheckoutCart $checkoutCart, Cart $cart, $requireReload = true)
{
if ($requireReload) {
$checkoutCart->open();
}
$fixtureTaxAmount = number_format((double) $cart->getTaxAmount(), 2);
$pageTaxAmount = $checkoutCart->getTotalsBlock()->getTax();
\PHPUnit_Framework_Assert::assertEquals($fixtureTaxAmount, $pageTaxAmount, 'Tax amount in the shopping cart not equals to tax amount from fixture.');
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:AssertTaxInShoppingCart.php
示例14: processAssert
/**
* Assert that Catalog Price Rule is not applied for product(s) in Shopping Cart.
*
* @param CheckoutCart $checkoutCartPage
* @param array $products
* @param array $productPrice
* @return void
*/
public function processAssert(CheckoutCart $checkoutCartPage, array $products, array $productPrice)
{
$this->objectManager->create('\\Magento\\Checkout\\Test\\TestStep\\AddProductsToTheCartStep', ['products' => $products])->run();
$checkoutCartPage->open();
foreach ($products as $key => $product) {
$actualPrice = $checkoutCartPage->getCartBlock()->getCartItem($product)->getSubtotalPrice();
\PHPUnit_Framework_Assert::assertEquals($productPrice[$key]['regular'], $actualPrice, 'Wrong product price is displayed.' . "\nExpected: " . $productPrice[$key]['regular'] . "\nActual: " . $actualPrice . "\n");
}
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:17,代码来源:AssertCatalogPriceRuleNotAppliedShoppingCart.php
示例15: 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.');
}
开发者ID:aiesh,项目名称:magento2,代码行数:21,代码来源:AssertCrossSellsProductsSection.php
示例16: 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.');
}
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:25,代码来源:AssertProductAbsentCrossSells.php
示例17: processAssert
/**
* 1. Navigate to frontend
* 2. If "Log Out" link is visible and "isLoggedIn" empty
* - makes logout
* 3. If "isLoggedIn" not empty
* - login as customer
* 4. Clear shopping cart
* 5. Add test product(s) to shopping cart with specify quantity
* 6. If "salesRule/data/coupon_code" not empty:
* - fill "Enter your code" input in Dіscount Codes
* - click "Apply Coupon" button
* 7. If "address/data/country_id" not empty:
* On Estimate Shipping and Tax:
* - fill Country, State/Province, Zip/Postal Code
* - click 'Get a Quote' button
* - select 'Flat Rate' shipping
* - click 'Update Total' button
* 8. Implementation assert
*
* @param CheckoutCart $checkoutCart
* @param CmsIndex $cmsIndex
* @param CustomerAccountLogin $customerAccountLogin
* @param CustomerAccountLogout $customerAccountLogout
* @param CatalogCategoryView $catalogCategoryView
* @param CatalogProductView $catalogProductView
* @param SalesRule $salesRule
* @param SalesRule $salesRuleOrigin
* @param array $productQuantity
* @param CatalogProductSimple $productForSalesRule1
* @param CatalogProductSimple $productForSalesRule2
* @param Customer $customer
* @param Address $address
* @param int|null $isLoggedIn
* @param array $shipping
* @param array $cartPrice
* @return void
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function processAssert(CheckoutCart $checkoutCart, CmsIndex $cmsIndex, CustomerAccountLogin $customerAccountLogin, CustomerAccountLogout $customerAccountLogout, CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView, SalesRule $salesRule, SalesRule $salesRuleOrigin, array $productQuantity, CatalogProductSimple $productForSalesRule1, CatalogProductSimple $productForSalesRule2 = null, Customer $customer = null, Address $address = null, $isLoggedIn = null, array $shipping = [], array $cartPrice = [])
{
$this->checkoutCart = $checkoutCart;
$this->cmsIndex = $cmsIndex;
$this->customerAccountLogin = $customerAccountLogin;
$this->customerAccountLogout = $customerAccountLogout;
$this->catalogCategoryView = $catalogCategoryView;
$this->catalogProductView = $catalogProductView;
$this->productForSalesRule1 = $productForSalesRule1;
$this->productForSalesRule2 = $productForSalesRule2;
$this->cartPrice = $cartPrice;
if ($customer !== null) {
$this->customer = $customer;
}
$isLoggedIn ? $this->login() : $this->customerAccountLogout->open();
$this->checkoutCart->open()->getCartBlock()->clearShoppingCart();
$this->addProductsToCart($productQuantity);
$this->checkoutCart->open();
if ($address !== null) {
$this->checkoutCart->getShippingBlock()->fillEstimateShippingAndTax($address);
$this->checkoutCart->getShippingBlock()->selectShippingMethod($shipping);
}
if ($salesRule->getCouponCode() || $salesRuleOrigin->getCouponCode()) {
$this->checkoutCart->getDiscountCodesBlock()->applyCouponCode($salesRule->getCouponCode() ? $salesRule->getCouponCode() : $salesRuleOrigin->getCouponCode());
}
$this->assert();
}
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:66,代码来源:AssertCartPriceRuleApplying.php
示例18: assertCheckoutCart
/**
* Verify checkout cart.
*
* @param array $checkoutProducts
* @return void
*/
protected function assertCheckoutCart(array $checkoutProducts)
{
$this->checkoutCart->open();
foreach ($checkoutProducts as $product) {
\PHPUnit_Framework_Assert::assertTrue($this->checkoutCart->getCartBlock()->getCartItem($product)->isVisible(), "Product {$product->getName()} absent in cart.");
}
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:13,代码来源:NavigateRelatedProductsTest.php
示例19: processAssert
/**
* 1. Creating product simple with custom tax product class
* 2. Log In as customer
* 3. Add product to shopping cart
* 4. Estimate Shipping and Tax
* 5. Implementation assert
*
* @param FixtureFactory $fixtureFactory
* @param TaxRule $taxRule
* @param Customer $customer
* @param CatalogProductView $catalogProductView
* @param CheckoutCart $checkoutCart
* @param Address $address
* @param array $shipping
* @param BrowserInterface $browser
* @param TaxRule $initialTaxRule
* @return void
*/
public function processAssert(FixtureFactory $fixtureFactory, TaxRule $taxRule, Customer $customer, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, Address $address, array $shipping, BrowserInterface $browser, TaxRule $initialTaxRule = null)
{
$this->initialTaxRule = $initialTaxRule;
$this->taxRule = $taxRule;
$this->checkoutCart = $checkoutCart;
$this->shipping = $shipping;
if ($this->initialTaxRule !== null) {
$this->taxRuleCode = $this->taxRule->hasData('code') ? $this->taxRule->getCode() : $this->initialTaxRule->getCode();
} else {
$this->taxRuleCode = $this->taxRule->getCode();
}
// Creating simple product with custom tax class
/** @var \Magento\Tax\Test\Fixture\TaxClass $taxProductClass */
$taxProductClass = $taxRule->getDataFieldConfig('tax_product_class')['source']->getFixture()[0];
$this->productSimple = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'product_100_dollar_for_tax_rule', 'data' => ['tax_class_id' => ['tax_product_class' => $taxProductClass]]]);
$this->productSimple->persist();
// Customer login
$this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
// Clearing shopping cart and adding product to shopping cart
$checkoutCart->open()->getCartBlock()->clearShoppingCart();
$browser->open($_ENV['app_frontend_url'] . $this->productSimple->getUrlKey() . '.html');
$catalogProductView->getViewBlock()->clickAddToCart();
$catalogProductView->getMessagesBlock()->waitSuccessMessage();
// Estimate Shipping and Tax
$checkoutCart->open();
$checkoutCart->getShippingBlock()->openEstimateShippingAndTax();
$checkoutCart->getShippingBlock()->fill($address);
$checkoutCart->getShippingBlock()->clickGetQuote();
$checkoutCart->getShippingBlock()->selectShippingMethod($shipping);
$this->assert();
}
开发者ID:opexsw,项目名称:magento2,代码行数:49,代码来源:AssertTaxRuleApplying.php
示例20: processAssert
/**
* Assert that Catalog Price Rule is applied for product(s) in Shopping Cart
* according to Priority(Priority/Stop Further Rules Processing).
*
* @param CheckoutCart $checkoutCartPage
* @param array $products
* @param array $cartPrice
* @param array $productPrice
* @param Customer $customer
* @return void
*/
public function processAssert(CheckoutCart $checkoutCartPage, array $products, array $cartPrice, array $productPrice, Customer $customer = null)
{
if ($customer !== null) {
$this->objectManager->create('\\Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
}
$this->objectManager->create('\\Magento\\Checkout\\Test\\TestStep\\AddProductsToTheCartStep', ['products' => $products])->run();
$checkoutCartPage->open();
foreach ($products as $key => $product) {
$actualPrice = $checkoutCartPage->getCartBlock()->getCartItem($product)->getSubtotalPrice();
\PHPUnit_Framework_Assert::assertEquals($productPrice[$key]['sub_total'], $actualPrice, 'Wrong product price is displayed.' . "\nExpected: " . $productPrice[$key]['sub_total'] . "\nActual: " . $actualPrice . "\n");
}
$actualPrices['sub_total'] = $checkoutCartPage->getTotalsBlock()->getSubtotal();
$actualPrices['grand_total'] = $checkoutCartPage->getTotalsBlock()->getGrandTotal();
$expectedPrices['sub_total'] = $cartPrice['sub_total'];
$expectedPrices['grand_total'] = $cartPrice['grand_total'];
\PHPUnit_Framework_Assert::assertEquals($expectedPrices, $actualPrices, 'Wrong total cart prices are displayed.');
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:28,代码来源:AssertCatalogPriceRuleAppliedShoppingCart.php
注:本文中的Magento\Checkout\Test\Page\CheckoutCart类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论