本文整理汇总了PHP中Magento\Checkout\Test\Page\CheckoutCart::open方法的典型用法代码示例。如果您正苦于以下问题:PHP CheckoutCart::open方法的具体用法?PHP CheckoutCart::open怎么用?PHP CheckoutCart::open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Checkout\Test\Page\CheckoutCart
的用法示例。
在下文中一共展示了CheckoutCart::open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Add gift message to items and/or order.
*
* @return array
*/
public function run()
{
$this->checkoutCart->open();
$this->checkoutCart->getGiftMessagesItemBlock()->fillGiftMessageItem($this->giftMessage, $this->products);
$this->checkoutCart->getGiftMessagesOrderBlock()->fillGiftMessageOrder($this->giftMessage, $this->products);
return ['giftMessage' => $this->giftMessage];
}
示例2: run
/**
* Checkout with Braintree PayPal from Shopping Cart.
*
* @return void
*/
public function run()
{
$this->checkoutCart->open();
$this->checkoutCart->getTotalsBlock()->waitForShippingPriceBlock();
$this->checkoutCart->getTotalsBlock()->waitForUpdatedTotals();
$currentWindow = $this->checkoutCart->getCartBlock()->braintreePaypalCheckout();
$this->checkoutCart->getBraintreePaypalBlock()->process($currentWindow);
}
示例3: 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();
}
}
示例4: test
/**
* Run test add products to shopping cart
*
* @param string $products
* @param int $deletedProductIndex
* @return array
*/
public function test($products, $deletedProductIndex)
{
// Preconditions
$products = $this->prepareProducts($products);
$this->cartPage->open();
$this->cartPage->getCartBlock()->clearShoppingCart();
// Steps
$this->addToCart($products);
$this->cartPage->getMessagesBlock()->waitSuccessMessage();
$this->removeProduct($products[$deletedProductIndex]);
$deletedProduct = $products[$deletedProductIndex];
unset($products[$deletedProductIndex]);
return ['products' => $products, 'deletedProduct' => $deletedProduct];
}
示例5: 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.');
}
}
示例6: removeProducts
/**
* Remove products form cart
*
* @param array $products
* @return void
*/
protected function removeProducts(array $products)
{
$this->cartPage->open();
foreach ($products as $product) {
$this->cartPage->getCartBlock()->getCartItem($product)->removeItem();
}
}
示例7: 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
*/
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;
//Preconditions
$address = $fixtureFactory->createByCode('address', ['dataset' => 'US_address_NY']);
$shipping = ['shipping_service' => 'Flat Rate', 'shipping_method' => 'Fixed'];
$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()->setQtyAndClickAddToCart($qty);
$catalogProductView->getMessagesBlock()->waitSuccessMessage();
$this->checkoutCart->open();
$this->fillEstimateBlock($address, $shipping);
$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);
}
示例8: 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.");
}
}
示例9: 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();
}
示例10: 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.');
}
示例11: 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.');
}
示例12: 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.');
}
示例13: 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.');
}
示例14: 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.');
}
}
示例15: 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.');
}