/** * Assert that message from dataSet is displayed for each items on order(s) view page on frontend * * @param GiftMessage $giftMessage * @param Customer $customer * @param OrderHistory $orderHistory * @param CustomerOrderView $customerOrderView * @param CustomerAccountLogout $customerAccountLogout * @param string $orderId * @param array $products * @return void */ public function processAssert(GiftMessage $giftMessage, Customer $customer, OrderHistory $orderHistory, CustomerOrderView $customerOrderView, CustomerAccountLogout $customerAccountLogout, $orderId, $products = []) { $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run(); $expectedData = ['sender' => $giftMessage->getSender(), 'recipient' => $giftMessage->getRecipient(), 'message' => $giftMessage->getMessage()]; $orderHistory->open(); $orderHistory->getOrderHistoryBlock()->openOrderById($orderId); foreach ($products as $key => $product) { if ($giftMessage->hasData('items')) { $itemGiftMessage = $giftMessage->getItems()[$key]; $expectedData = ['sender' => $itemGiftMessage->getSender(), 'recipient' => $itemGiftMessage->getRecipient(), 'message' => $itemGiftMessage->getMessage()]; } \PHPUnit_Framework_Assert::assertEquals($expectedData, $customerOrderView->getGiftMessageForItemBlock()->getGiftMessage($product->getName()), 'Wrong gift message is displayed on "' . $product->getName() . '" item.'); } $customerAccountLogout->open(); }
/** * Assert that message from dataset is displayed on order(s) view page on frontend. * * @param GiftMessage $giftMessage * @param Customer $customer * @param OrderHistory $orderHistory * @param CustomerOrderView $customerOrderView * @param CustomerAccountLogout $customerAccountLogout * @param string $orderId * @return void */ public function processAssert(GiftMessage $giftMessage, Customer $customer, OrderHistory $orderHistory, CustomerOrderView $customerOrderView, CustomerAccountLogout $customerAccountLogout, $orderId) { $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run(); $expectedData = ['sender' => $giftMessage->getSender(), 'recipient' => $giftMessage->getRecipient(), 'message' => $giftMessage->getMessage()]; $orderHistory->open(); $orderHistory->getOrderHistoryBlock()->openOrderById($orderId); \PHPUnit_Framework_Assert::assertEquals($expectedData, $customerOrderView->getGiftMessageForOrderBlock()->getGiftMessage(), 'Wrong gift message is displayed on order.'); $customerAccountLogout->open(); }
/** * Run step. * * @return void */ public function run() { $this->customerAccountLogout->open(); $this->cmsIndex->getFooterBlock()->clickLink('Orders and Returns'); $this->salesGuestForm->getSearchForm()->fill($this->order); $this->salesGuestForm->getSearchForm()->submit(); }
/** * Assert that product is not present in Wishlist on Frontend * * @param CustomerAccountIndex $customerAccountIndex * @param WishlistIndex $wishlistIndex * @param InjectableFixture $product * @param CustomerInjectable $customer * @param CmsIndex $cmsIndex * @param CustomerAccountLogin $customerAccountLogin * @param CustomerAccountLogout $customerAccountLogout * @return void */ public function processAssert(CustomerAccountIndex $customerAccountIndex, WishlistIndex $wishlistIndex, InjectableFixture $product, CustomerInjectable $customer, CmsIndex $cmsIndex, CustomerAccountLogin $customerAccountLogin, CustomerAccountLogout $customerAccountLogout) { $productName = $product->getName(); $customerAccountLogout->open(); $cmsIndex->getLinksBlock()->openLink('Log In'); $customerAccountLogin->getLoginBlock()->login($customer); $customerAccountIndex->open()->getAccountMenuBlock()->openMenuItem("My Wish List"); \PHPUnit_Framework_Assert::assertFalse($wishlistIndex->getWishlistBlock()->getProductItemsBlock()->isProductPresent($productName), 'Product \'' . $productName . '\' is present in Wishlist on Frontend.'); }
/** * Assert that product is not present in Wishlist on Frontend * * @param CustomerAccountIndex $customerAccountIndex * @param WishlistIndex $wishlistIndex * @param InjectableFixture[] $products * @param Customer $customer * @param CmsIndex $cmsIndex * @param CustomerAccountLogin $customerAccountLogin * @param CustomerAccountLogout $customerAccountLogout * @return void */ public function processAssert(CustomerAccountIndex $customerAccountIndex, WishlistIndex $wishlistIndex, $products, Customer $customer, CmsIndex $cmsIndex, CustomerAccountLogin $customerAccountLogin, CustomerAccountLogout $customerAccountLogout) { $customerAccountLogout->open(); $cmsIndex->getLinksBlock()->openLink('Log In'); $customerAccountLogin->getLoginBlock()->login($customer); $customerAccountIndex->open()->getAccountMenuBlock()->openMenuItem("My Wish List"); $itemBlock = $wishlistIndex->getWishlistBlock()->getProductItemsBlock(); foreach ($products as $itemProduct) { \PHPUnit_Framework_Assert::assertFalse($itemBlock->getItemProduct($itemProduct)->isVisible(), 'Product \'' . $itemProduct->getName() . '\' is present in Wishlist on Frontend.'); } }
/** * 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(); }
/** * 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 CustomerAccountLogin $customerAccountLogin * @param CustomerAccountLogout $customerAccountLogout * @param CustomerInjectable $customer * @param CatalogProductView $catalogProductView * @param CheckoutCart $checkoutCart * @param AddressInjectable $address * @param array $shipping * @param Browser $browser * @param TaxRule $initialTaxRule * @return void * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function processAssert(FixtureFactory $fixtureFactory, TaxRule $taxRule, CustomerAccountLogin $customerAccountLogin, CustomerAccountLogout $customerAccountLogout, CustomerInjectable $customer, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, AddressInjectable $address, array $shipping, Browser $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' => '100_dollar_product_for_tax_rule', 'data' => ['tax_class_id' => ['tax_product_class' => $taxProductClass]]]); $this->productSimple->persist(); // Customer login $customerAccountLogout->open(); $customerAccountLogin->open(); $customerAccountLogin->getLoginBlock()->login($customer); // 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(); // Estimate Shipping and Tax $checkoutCart->getShippingBlock()->openEstimateShippingAndTax(); $checkoutCart->getShippingBlock()->fill($address); $checkoutCart->getShippingBlock()->clickGetQuote(); $checkoutCart->getShippingBlock()->selectShippingMethod($shipping); $this->assert(); }
/** * Log out after test. * * @return void */ public function tearDown() { $this->customerAccountLogout->open(); }