php mage-checkout-test-page-CheckoutCart类(方法)实例源码

下面列出了php mage-checkout-test-page-CheckoutCart 类(方法)源码代码实例,从而了解它的用法。

作者:hientruong9    项目:ee_14_installe   
/**
  * Assert prices on the shopping cart.
  *
  * @param InjectableFixture $product
  * @param CheckoutCart $checkoutCart
  * @return void
  */
 protected function assertOnShoppingCart(InjectableFixture $product, CheckoutCart $checkoutCart)
 {
     $cartItem = $checkoutCart->getCartBlock()->getCartItem($product);
     $formPrice = $cartItem->getCartItemTypePrice('price');
     $fixturePrice = number_format($this->prepareFixturePrice($product), 2);
     \PHPUnit_Framework_Assert::assertEquals($fixturePrice, $formPrice, 'Product price in shopping cart is not correct.');
 }

作者:MikeTay    项目:magento.de   
/**
  * 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.");
     }
 }

作者:hientruong9    项目:ee_14_installe   
/**
  * Assert that products' MAP has been applied before checkout.
  *
  * @param CatalogCategory $category
  * @param Customer $customer
  * @param Address $address
  * @param CatalogCategoryView $catalogCategoryView
  * @param CmsIndex $cmsIndex
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $cart
  * @param CheckoutOnepage $checkoutOnePage
  * @param array $products
  * @return void
  */
 public function processAssert(CatalogCategory $category, Customer $customer, Address $address, CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, CatalogProductView $catalogProductView, CheckoutCart $cart, CheckoutOnepage $checkoutOnePage, array $products)
 {
     for ($i = 0; $i < count($products); $i++) {
         $cart->getCartBlock()->clearShoppingCart();
         $productName = $products[$i]->getName();
         $cmsIndex->open();
         $cmsIndex->getTopmenu()->selectCategory($category->getName());
         // Check that price is not present on category page.
         $listProductBlock = $catalogCategoryView->getListProductBlock();
         $productPriceBlock = $listProductBlock->getProductPriceBlock($productName);
         $productPriceBlock->clickForPrice();
         \PHPUnit_Framework_Assert::assertFalse($productPriceBlock->getMapBlock()->isPriceVisible(), 'Price is present in MSRP dialog on category page.');
         // Check that price is not present on product page.
         $listProductBlock->openProductViewPage($productName);
         \PHPUnit_Framework_Assert::assertFalse($catalogProductView->getViewBlock()->getPriceBlock()->isRegularPriceVisible(), 'Price is present in View block on product page.');
         // Check that price is not present on cart.
         $catalogProductView->getViewBlock()->addToCart($products[$i]);
         \PHPUnit_Framework_Assert::assertTrue($cart->getCartBlock()->getCartItem($products[$i])->isMsrpVisible(), "MSRP link is not visible in cart.");
         // Check that price is present on review block in onepage checkout page.
         $cart->getCartBlock()->getProceedToCheckoutBlock()->proceedToCheckout();
         $checkoutMethodBlock = $checkoutOnePage->getLoginBlock();
         $billingBlock = $checkoutOnePage->getBillingBlock();
         $paymentMethodBlock = $checkoutOnePage->getPaymentMethodsBlock();
         $shippingBlock = $checkoutOnePage->getShippingMethodBlock();
         $checkoutMethodBlock->guestCheckout();
         $checkoutMethodBlock->clickContinue();
         $billingBlock->fillBilling($address, $customer);
         $billingBlock->clickContinue();
         $shippingBlock->selectShippingMethod(['shipping_service' => 'Flat Rate', 'shipping_method' => 'Fixed']);
         $shippingBlock->clickContinue();
         $paymentMethodBlock->selectPaymentMethod(['method' => 'checkmo']);
         $paymentMethodBlock->clickContinue();
         \PHPUnit_Framework_Assert::assertEquals(number_format($products[$i]->getPrice(), 2), $checkoutOnePage->getReviewBlock()->getTotalBlock()->getData('subtotal'), "Subtotal in checkout one page for {$productName} is not equal to expected.");
     }
 }

作者:QiuLihua8    项目:magento-e   
/**
  * Assert prices on the product view page and shopping cart page.
  *
  * @param CheckoutCart $checkoutCartView
  * @return void
  */
 protected function assertPrice(CheckoutCart $checkoutCartView)
 {
     $formCartItem = $checkoutCartView->getCartBlock()->getCartItem($this->product);
     $fixtureCartItem = $this->product->getCheckoutData()['cartItem'];
     $this->assertCartOptions($fixtureCartItem['options']['bundle_options'], $formCartItem->getOptions());
     $this->assertCartPrice($fixtureCartItem['price'], $formCartItem->getCartItemTypePrice('price'));
 }

作者:chucky51    项目:Magento-CE-Mirro   
/**
  * Assert that grand total is equal to expected.
  *
  * @param CheckoutCart $checkoutCart
  * @param Cart $cart
  * @param Customer|null $customer
  * @return void
  */
 public function processAssert(CheckoutCart $checkoutCart, Cart $cart, Customer $customer = null)
 {
     if ($customer !== null) {
         $this->login($customer);
     }
     $checkoutCart->open();
     \PHPUnit_Framework_Assert::assertEquals(number_format($cart->getGrandTotal(), 2), $checkoutCart->getTotalsBlock()->getData('grand_total'));
 }

作者:chucky51    项目:Magento-CE-Mirro   
/**
  * Assertion that the product is correctly displayed in cart.
  *
  * @param CatalogProductView $catalogProductView
  * @param InjectableFixture $product
  * @param Browser $browser
  * @param CheckoutCart $checkoutCart
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, InjectableFixture $product, Browser $browser, CheckoutCart $checkoutCart)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     $checkoutData = $product->getCheckoutData();
     $price = $checkoutCart->getCartBlock()->getCartItem($product)->getCartItemTypePrice('price');
     \PHPUnit_Framework_Assert::assertEquals($checkoutData['cartItem']['price'], $price, 'Product price in shopping cart is not correct.');
 }

作者:hientruong9    项目:ee_14_installe   
/**
  * Assert that gift card usable in frontend.
  *
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param CatalogProductSimple $product
  * @param Browser $browser
  * @param string $code
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, CatalogProductSimple $product, Browser $browser, $code)
 {
     $this->checkoutCart = $checkoutCart;
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->clickAddToCart();
     $checkoutCart->getGiftCardAccountBlock()->addGiftCard($code);
     $this->assert();
 }

作者:MikeTay    项目:magento.de   
/**
  * Assert that product can be configured and added to cart after added this product to cart by sku.
  *
  * @param CheckoutCart $checkoutCart
  * @param CatalogProductView $catalogProductView
  * @param array $requiredAttentionProducts
  * @return void
  */
 public function processAssert(CheckoutCart $checkoutCart, CatalogProductView $catalogProductView, array $requiredAttentionProducts)
 {
     foreach ($requiredAttentionProducts as $product) {
         $checkoutCart->open()->getAdvancedCheckoutCart()->clickSpecifyProductOptionsLink($product);
         $catalogProductView->getViewBlock()->addToCart($product);
         \PHPUnit_Framework_Assert::assertEquals(sprintf(self::SUCCESS_MESSAGE, $product->getName()), $checkoutCart->getMessagesBlock()->getSuccessMessages());
     }
 }

作者:MikeTay    项目:magento.de   
/**
  * Assert that after adding products by sku, wrong requested quantity error message appears.
  *
  * @param CheckoutCart $checkoutCart
  * @param array $requiredAttentionProducts
  * @return void
  */
 public function processAssert(CheckoutCart $checkoutCart, array $requiredAttentionProducts)
 {
     foreach ($requiredAttentionProducts as $product) {
         $currentMessage = $checkoutCart->getAdvancedCheckoutCart()->getFailedItemErrorMessage($product);
         \PHPUnit_Framework_Assert::assertContains(self::ERROR_QUANTITY_MESSAGE, $currentMessage);
         \PHPUnit_Framework_Assert::assertContains(sprintf($this->allowedQtyMessage, $product->getStockData()[$this->saleQtyType]), $currentMessage);
     }
 }

作者:QiuLihua8    项目:magento-e   
/**
  * Assert that requested quantity is not available error message is displayed after adding products to cart by sku.
  *
  * @param CheckoutCart $checkoutCart
  * @param array $requiredAttentionProducts
  * @return void
  */
 public function processAssert(CheckoutCart $checkoutCart, $requiredAttentionProducts)
 {
     foreach ($requiredAttentionProducts as $product) {
         $currentMessage = $checkoutCart->getAdvancedCheckoutCart()->getFailedItemErrorMessage($product);
         \PHPUnit_Framework_Assert::assertContains(self::ERROR_QUANTITY_MESSAGE, $currentMessage);
         \PHPUnit_Framework_Assert::assertContains(sprintf(self::LEFT_IN_STOCK_ERROR_MESSAGE, $product->getStockData()['qty']), $currentMessage);
     }
 }

作者:QiuLihua8    项目:magento-e   
/**
  * Assert that product can be added to active gift registry from shopping cart.
  *
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param InjectableFixture $product
  * @param GiftRegistry $giftRegistry
  * @param GiftRegistryItems $giftRegistryItems
  * @param BrowserInterface $browser
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, InjectableFixture $product, GiftRegistry $giftRegistry, GiftRegistryItems $giftRegistryItems, BrowserInterface $browser)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     $catalogProductView->getMessagesBlock()->waitSuccessMessage();
     $checkoutCart->open();
     $checkoutCart->getGiftRegistryBlock()->addToGiftRegistry($giftRegistry);
     \PHPUnit_Framework_Assert::assertTrue($giftRegistryItems->getGiftRegistryItemsBlock()->isProductInGrid($product), "Product can not be added to active gift registry '{$giftRegistry->getTitle()}' from shopping cart.");
 }

作者:test3metizsof    项目:tes   
/**
  * Assert that Catalog Price Rule is applied for product(s) in Shopping Cart
  * according to Priority(Priority/Stop Further Rules Processing).
  *
  * @param InjectableFixture $product
  * @param CatalogProductView $pageCatalogProductView
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CheckoutCart $pageCheckoutCart
  * @param array $prices
  * @return void
  */
 public function processAssert(InjectableFixture $product, CatalogProductView $pageCatalogProductView, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CheckoutCart $pageCheckoutCart, array $prices)
 {
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategory($product->getCategoryIds()[0]);
     $catalogCategoryView->getListProductBlock()->openProductViewPage($product->getName());
     $pageCatalogProductView->getViewBlock()->addToCart($product);
     $actualGrandTotal = $pageCheckoutCart->getCartBlock()->getCartItem($product)->getCartItemTypePrice('price');
     \PHPUnit_Framework_Assert::assertEquals($prices['grand_total'], $actualGrandTotal);
 }

作者:cewolf200    项目:magent   
/**
  * Run Move from ShoppingCard to Wishlist test.
  *
  * @param Customer $customer
  * @param CheckoutCart $checkoutCart
  * @param string $product
  * @return array
  */
 public function test(Customer $customer, CheckoutCart $checkoutCart, $product)
 {
     // Preconditions:
     $product = $this->createProducts($product)[0];
     $this->loginCustomer($customer);
     // Steps:
     $this->addToCart($product);
     $checkoutCart->open()->getCartBlock()->getCartItem($product)->moveToWishlist();
     return ['product' => $product];
 }

作者:hientruong9    项目:ee_14_installe   
/**
  * Assert that created gift card account can be verified on the frontend in Shopping Cart.
  *
  * @param Customer $customer
  * @param Browser $browser
  * @param CatalogProductSimple $product
  * @param CatalogProductView $catalogProductView
  * @param GiftCardAccount $giftCardAccount
  * @param CheckoutCart $checkoutCart
  * @param string $code
  * @return void
  */
 public function processAssert(Customer $customer, Browser $browser, CatalogProductSimple $product, CatalogProductView $catalogProductView, GiftCardAccount $giftCardAccount, CheckoutCart $checkoutCart, $code)
 {
     $this->objectManager->create('Mage\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->clickAddToCart();
     $data = $giftCardAccount->getData();
     $checkoutCart->getGiftCardAccountBlock()->checkStatusAndBalance($code);
     $fixtureData = ['code' => $code, 'balance' => $data['balance'], 'date_expires' => $data['date_expires']];
     \PHPUnit_Framework_Assert::assertEquals($fixtureData, $checkoutCart->getCheckBlock()->getGiftCardAccountData($fixtureData));
 }

作者:hientruong9    项目:ee_14_installe   
/**
  * Assert that banner is absent on Shopping Cart page.
  *
  * @param Browser $browser
  * @param CatalogProductSimple $product
  * @param CatalogProductView $catalogProductView
  * @param Banner $banner
  * @param CheckoutCart $checkoutCart
  * @param Cache $adminCache
  * @return void
  */
 public function processAssert(Browser $browser, CatalogProductSimple $product, CatalogProductView $catalogProductView, Banner $banner, CheckoutCart $checkoutCart, Cache $adminCache)
 {
     // Flush cache
     $adminCache->open();
     $adminCache->getPageActions()->flushCacheStorage();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     \PHPUnit_Framework_Assert::assertFalse($checkoutCart->getBannerViewBlock()->checkWidgetBanners($banner), 'Banner is present on Shopping Cart page.');
 }

作者:MikeTay    项目:magento.de   
/**
  * 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);
     $checkoutCart->open();
     foreach ($promotedProducts as $promotedProduct) {
         \PHPUnit_Framework_Assert::assertFalse($checkoutCart->getCrosssellBlock()->getItemBlock($promotedProduct)->isVisible(), 'Product \'' . $promotedProduct->getName() . '\' is exist in cross-sell section.');
     }
 }

作者:QiuLihua8    项目:magento-e   
/**
  * Assert that product has tier price message appears after adding products by sku to shopping cart.
  *
  * @param CheckoutCart $checkoutCart
  * @param array $requiredAttentionProducts
  * @return void
  */
 public function processAssert(CheckoutCart $checkoutCart, array $requiredAttentionProducts)
 {
     foreach ($requiredAttentionProducts as $product) {
         $messages = $checkoutCart->getAdvancedCheckoutCart()->getTierPriceMessages($product);
         $tierPrices = $product->getTierPrice();
         \PHPUnit_Framework_Assert::assertTrue(count($messages) === count($tierPrices), 'Wrong qty messages is displayed.');
         foreach ($tierPrices as $key => $tierPrice) {
             $price = (bool) strpos($messages[$key], (string) $tierPrice['price']);
             $priceQty = (bool) strpos($messages[$key], (string) $tierPrice['price_qty']);
             $savePercent = (bool) strpos($messages[$key], $this->getSavePercent($product->getPrice(), $tierPrice));
             \PHPUnit_Framework_Assert::assertTrue($price and $priceQty and $savePercent, 'Wrong tier price message is displayed.');
         }
     }
 }

作者:cewolf200    项目:magent   
/**
  * Assert that products are displayed in cross-sell section.
  *
  * @param Browser $browser
  * @param CheckoutCart $checkoutCart
  * @param CatalogProductSimple $product
  * @param CatalogProductView $catalogProductView
  * @param InjectableFixture[] $crossSellProducts
  * @return void
  */
 public function processAssert(Browser $browser, CheckoutCart $checkoutCart, CatalogProductSimple $product, CatalogProductView $catalogProductView, array $crossSellProducts)
 {
     $checkoutCart->open()->getCartBlock()->clearShoppingCart();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     $errors = [];
     $crosssellBlock = $checkoutCart->getCrosssellBlock();
     foreach ($crossSellProducts as $crossSellProduct) {
         if (!$crosssellBlock->getItemBlock($crossSellProduct)->isVisible()) {
             $errors[] = "Product {$crossSellProduct->getName()} is absent in cross-sell section.";
         }
     }
     \PHPUnit_Framework_Assert::assertEmpty($errors, implode(" ", $errors));
 }

作者:QiuLihua8    项目:magento-e   
/**
  * Assert that Gift Wrapping can be found during one page checkout on frontend.
  *
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param BrowserInterface $browser
  * @param CheckoutOnepage $checkoutOnepage
  * @param GiftWrapping $giftWrapping
  * @param Address $billingAddress
  * @param CatalogProductSimple $product
  * @param Customer $customer
  * @param CustomerAccountLogout $customerAccountLogout
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, BrowserInterface $browser, CheckoutOnepage $checkoutOnepage, GiftWrapping $giftWrapping, Address $billingAddress, CatalogProductSimple $product, Customer $customer, CustomerAccountLogout $customerAccountLogout)
 {
     // Preconditions
     $customer->persist();
     $product->persist();
     // Steps
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     $checkoutCart->open()->getCartBlock()->getProceedToCheckoutBlock()->proceedToCheckout();
     $checkoutOnepage->getLoginBlock()->loginCustomer($customer);
     $checkoutOnepage->getBillingBlock()->fillBilling($billingAddress);
     $checkoutOnepage->getBillingBlock()->clickContinue();
     \PHPUnit_Framework_Assert::assertContains($giftWrapping->getDesign(), $checkoutOnepage->getGiftOptionsBlock()->getGiftWrappingsAvailable(), "Gift Wrapping '{$giftWrapping->getDesign()}' is not present in one page checkout on frontend.");
     $customerAccountLogout->open();
 }

作者:hientruong9    项目:ee_14_installe   
/**
  * Assert that product is displayed in cross-sell section.
  *
  * @param BrowserInterface $browser
  * @param CheckoutCart $checkoutCart
  * @param CatalogProductSimple $product
  * @param CatalogProductView $catalogProductView
  * @param InjectableFixture[]|null $promotedProducts
  * @return void
  */
 public function processAssert(BrowserInterface $browser, CheckoutCart $checkoutCart, CatalogProductSimple $product, CatalogProductView $catalogProductView, array $promotedProducts = null)
 {
     $errors = [];
     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);
     $checkoutCart->open();
     foreach ($promotedProducts as $promotedProduct) {
         if (!$checkoutCart->getCrosssellBlock()->verifyProductCrosssell($promotedProduct)) {
             $errors[] = 'Product \'' . $promotedProduct->getName() . '\' is absent in cross-sell section.';
         }
     }
     \PHPUnit_Framework_Assert::assertEmpty($errors, implode(" ", $errors));
 }


问题


面经


文章

微信
公众号

扫码关注公众号