/** * Login customer. * * @return void */ public function run() { $this->logoutCustomerOnFrontend->run(); $this->cmsIndex->getLinksBlock()->openLink('Sign In'); $this->cmsIndex->getCmsPageBlock()->waitPageInit(); $this->customerAccountLogin->getLoginBlock()->login($this->customer); $this->cmsIndex->getCmsPageBlock()->waitPageInit(); }
/** * Logout customer * * @return void */ public function run() { $this->cmsIndex->open(); $this->cmsIndex->getCmsPageBlock()->waitPageInit(); if ($this->cmsIndex->getLinksBlock()->isLinkVisible("Log Out")) { $this->cmsIndex->getLinksBlock()->openLink("Log Out"); $this->cmsIndex->getCmsPageBlock()->waitUntilTextIsVisible('Home Page'); } }
/** * Assert that customer success log out. * * @param CustomerAccountIndex $customerAccountIndex * @param CmsIndex $cmsIndex * @return void */ public function processAssert(CustomerAccountIndex $customerAccountIndex, CmsIndex $cmsIndex) { $customerAccountIndex->open(); $cmsIndex->getCmsPageBlock()->waitPageInit(); $cmsIndex->getLinksBlock()->openLink('Sign Out'); $cmsIndex->getCmsPageBlock()->waitUntilTextIsVisible(self::LOGOUT_PAGE_TITLE); $cmsIndex->getCmsPageBlock()->waitUntilTextIsVisible(self::HOME_PAGE_TITLE); $cmsIndex->getCmsPageBlock()->waitPageInit(); \PHPUnit_Framework_Assert::assertTrue($cmsIndex->getLinksBlock()->isLinkVisible('Sign In'), "Customer wasn't logged out."); }
/** * Logout customer. * * @return void */ public function run() { $this->customerAccount->open(); $this->cmsIndex->getCmsPageBlock()->waitPageInit(); if ($this->cmsIndex->getTitleBlock()->getTitle() != 'Customer Login') { $this->cmsIndex->getLinksBlock()->openLink('Sign Out'); $this->cmsIndex->getCmsPageBlock()->waitUntilTextIsVisible('Home Page'); $this->cmsIndex->getCmsPageBlock()->waitPageInit(); } }
/** * Login customer. * * @return void */ public function run() { $this->cmsIndex->open(); $this->cmsIndex->getCmsPageBlock()->waitPageInit(); if ($this->cmsIndex->getLinksBlock()->isLinkVisible("Log Out")) { $this->cmsIndex->getLinksBlock()->openLink("Log Out"); $this->cmsIndex->getCmsPageBlock()->waitUntilTextIsVisible('Home Page'); } $this->cmsIndex->getLinksBlock()->openLink("Log In"); $this->customerAccountLogin->getLoginBlock()->login($this->customer); }
/** * 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); }
/** * Add created variable to page and assert that Custom Variable is displayed on frontend page and has * correct data according to dataset. * * @param SystemVariable $customVariable * @param CmsIndex $cmsIndex * @param SystemVariable $variable * @param FixtureFactory $fixtureFactory * @param BrowserInterface $browser * @param Store $storeOrigin * @param SystemVariable $customVariableOrigin * @return void */ public function processAssert(SystemVariable $customVariable, CmsIndex $cmsIndex, SystemVariable $variable, FixtureFactory $fixtureFactory, BrowserInterface $browser, Store $storeOrigin = null, SystemVariable $customVariableOrigin = null) { $cmsPage = $fixtureFactory->createByCode('cmsPage', ['dataset' => 'default', 'data' => ['content' => ['content' => '{{customVar code=' . $customVariable->getCode() . '}}']]]); $cmsPage->persist(); $browser->open($_ENV['app_frontend_url'] . $cmsPage->getIdentifier()); $cmsIndex->getStoreSwitcherBlock()->selectStoreView('Default Store View'); $htmlValue = $customVariableOrigin ? $this->getHtmlValue($customVariable, $customVariableOrigin) : strip_tags($customVariable->getHtmlValue()); $pageContent = $cmsIndex->getCmsPageBlock()->getPageContent(); $this->checkVariable($htmlValue, $pageContent); if ($storeOrigin !== null) { $cmsIndex->getStoreSwitcherBlock()->selectStoreView($storeOrigin->getName()); $htmlValue = strip_tags($customVariable->getHtmlValue()); if ($htmlValue === '') { $htmlValue = strip_tags($variable->getHtmlValue()); } $pageContent = $cmsIndex->getCmsPageBlock()->getPageContent(); $this->checkVariable($htmlValue, $pageContent); } }
/** * Share wish list. * * @param Customer $customer * @param CatalogProductSimple $product * @param array $sharingInfo * @return void */ public function test(Customer $customer, CatalogProductSimple $product, array $sharingInfo) { //Steps $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run(); $this->objectManager->create('Magento\\Wishlist\\Test\\TestStep\\AddProductsToWishlistStep', ['products' => [$product]])->run(); $this->wishlistIndex->getMessagesBlock()->waitSuccessMessage(); $this->wishlistIndex->getWishlistBlock()->clickShareWishList(); $this->cmsIndex->getCmsPageBlock()->waitPageInit(); $this->wishlistShare->getSharingInfoForm()->fillForm($sharingInfo); $this->wishlistShare->getSharingInfoForm()->shareWishlist(); }
/** * Share wish list * * @param BrowserInterface $browser * @param Customer $customer * @param CatalogProductSimple $product * @param array $sharingInfo * @return void */ public function test(BrowserInterface $browser, Customer $customer, CatalogProductSimple $product, array $sharingInfo) { //Steps $this->loginCustomer($customer); $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $this->catalogProductView->getViewBlock()->clickAddToWishlist(); $this->wishlistIndex->getMessagesBlock()->waitSuccessMessage(); $this->wishlistIndex->getWishlistBlock()->clickShareWishList(); $this->cmsIndex->getCmsPageBlock()->waitPageInit(); $this->wishlistShare->getSharingInfoForm()->fillForm($sharingInfo); $this->wishlistShare->getSharingInfoForm()->shareWishlist(); }
/** * Run Update Customer Entity test * * @param Customer $initialCustomer * @param Customer $customer * @param Address $address * @param AssertCustomerInfoSuccessSavedMessage $assertCustomerInfoSuccessSavedMessage * @return void */ public function test(Customer $initialCustomer, Customer $customer, Address $address, AssertCustomerInfoSuccessSavedMessage $assertCustomerInfoSuccessSavedMessage) { // Preconditions $initialCustomer->persist(); // Steps $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $initialCustomer])->run(); $this->customerAccountIndex->getInfoBlock()->openEditContactInfo(); $this->customerAccountEdit->getAccountInfoForm()->fill($customer); $this->customerAccountEdit->getAccountInfoForm()->submit(); \PHPUnit_Framework_Assert::assertThat($this->getName(), $assertCustomerInfoSuccessSavedMessage); $this->cmsIndex->getCmsPageBlock()->waitPageInit(); $this->customerAccountIndex->getDashboardAddress()->editBillingAddress(); $this->customerAddressEdit->getEditForm()->fill($address); $this->customerAddressEdit->getEditForm()->saveAddress(); }
/** * Assert that created widget displayed on frontent on Home page and on Advanced Search and * after click on widget link on frontend system redirects you to cms page. * * @param CmsIndex $cmsIndex * @param Widget $widget * @param AdminCache $adminCache * @return void */ public function processAssert(CmsIndex $cmsIndex, Widget $widget, AdminCache $adminCache) { // Flush cache $adminCache->open(); $adminCache->getActionsBlock()->flushMagentoCache(); $adminCache->getMessagesBlock()->waitSuccessMessage(); $cmsIndex->open(); $widgetText = $widget->getParameters()['anchor_text']; \PHPUnit_Framework_Assert::assertTrue($cmsIndex->getWidgetView()->isWidgetVisible($widget, $widgetText), 'Widget with type CmsPageLink is absent on Home page.'); $title = isset($widget->getParameters()['node']) ? $widget->getParameters()['entities'][0]->getLabel() : $widget->getParameters()['entities'][0]->getContentHeading(); $cmsIndex->getWidgetView()->clickToWidget($widget, $widgetText); $pageTitle = $cmsIndex->getCmsPageBlock()->getPageTitle(); \PHPUnit_Framework_Assert::assertEquals($title, $pageTitle, 'Wrong page title on Cms page.'); $cmsIndex->getFooterBlock()->openAdvancedSearch(); \PHPUnit_Framework_Assert::assertTrue($cmsIndex->getWidgetView()->isWidgetVisible($widget, $widgetText), 'Widget with type CmsPageLink is absent on Advanced Search page.'); }
/** * 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, CmsIndex $cmsIndex) { $this->checkoutOnepage = $checkoutOnepage; $this->customerOrderView = $customerOrderView; $checkoutCart->getProceedToCheckoutBlock()->proceedToCheckout(); $cmsIndex->getCmsPageBlock()->waitPageInit(); $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($prices, array_filter($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, array_filter($actualPrices), $message); }
/** * Assert wish list is empty * * @param CmsIndex $cmsIndex * @param WishlistIndex $wishlistIndex * @return void */ public function processAssert(CmsIndex $cmsIndex, WishlistIndex $wishlistIndex) { $cmsIndex->getCmsPageBlock()->waitPageInit(); $cmsIndex->getLinksBlock()->openLink("My Wish List"); \PHPUnit_Framework_Assert::assertTrue($wishlistIndex->getWishlistBlock()->isEmptyBlockVisible(), 'Wish List is not empty.'); }