/** * Create Customer account on frontend * * @param CustomerInjectable $customer */ public function testCreateCustomer(CustomerInjectable $customer) { //Steps $this->cmsIndex->open(); $this->cmsIndex->getLinksBlock()->openLink('Register'); $this->customerAccountCreate->getRegisterForm()->registerCustomer($customer); }
/** * Create Customer account on Storefront. * * @param Customer $customer * @return void */ public function test(Customer $customer) { // Steps $this->cmsIndex->open(); $this->cmsIndex->getLinksBlock()->openLink('Create an Account'); $this->customerAccountCreate->getRegisterForm()->registerCustomer($customer); }
/** * Assert that link "Compare Products..." on top menu of page * * @param array $products * @param CmsIndex $cmsIndex * @return void */ public function processAssert(array $products, CmsIndex $cmsIndex) { $productQty = count($products); $qtyOnPage = $cmsIndex->getLinksBlock()->getQtyInCompareList(); \PHPUnit_Framework_Assert::assertEquals($productQty, $qtyOnPage, 'Qty is not correct in "Compare Products" link.'); $compareProductUrl = '/catalog/product_compare/'; \PHPUnit_Framework_Assert::assertTrue(strpos($cmsIndex->getLinksBlock()->getLinkUrl('Compare Products'), $compareProductUrl) !== false, 'Compare product link isn\'t lead to Compare Product Page.'); }
/** * Login customer and open Order page. * * @param Customer $customer * @return void */ protected function loginCustomerAndOpenOrderPage(Customer $customer) { $this->cmsIndex->open(); $loginCustomerOnFrontendStep = $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer]); $loginCustomerOnFrontendStep->run(); $this->cmsIndex->getLinksBlock()->openLink('My Account'); $this->customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Orders'); }
/** * 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'); } }
/** * Create Existing Customer account on frontend. * * @param Customer $customer * @return void */ public function testCreateExistingCustomer(Customer $customer) { // Precondition $existingCustomer = clone $customer; $customer->persist(); // Steps $this->cmsIndex->open(); $this->cmsIndex->getLinksBlock()->openLink('Create an Account'); $this->customerAccountCreate->getRegisterForm()->registerCustomer($existingCustomer); }
/** * 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 category name is different on different store view. * * @param BrowserInterface $browser * @param CatalogCategoryView $categoryView * @param Category $category * @param Category $initialCategory * @param CmsIndex $cmsIndex * @return void */ public function processAssert(BrowserInterface $browser, CatalogCategoryView $categoryView, Category $category, Category $initialCategory, CmsIndex $cmsIndex) { $cmsIndex->open(); $cmsIndex->getLinksBlock()->waitWelcomeMessage(); $browser->open($_ENV['app_frontend_url'] . $initialCategory->getUrlKey() . '.html'); \PHPUnit_Framework_Assert::assertEquals($initialCategory->getName(), $categoryView->getTitleBlock()->getTitle(), 'Wrong category name is displayed for default store.'); $store = $category->getDataFieldConfig('store_id')['source']->store->getName(); $cmsIndex->getStoreSwitcherBlock()->selectStoreView($store); $cmsIndex->getLinksBlock()->waitWelcomeMessage(); $browser->open($_ENV['app_frontend_url'] . $initialCategory->getUrlKey() . '.html'); \PHPUnit_Framework_Assert::assertEquals($category->getName(), $categoryView->getTitleBlock()->getTitle(), 'Wrong category name is displayed for ' . $store); }
/** * Runs Delete Customer Address test. * * @param Customer $customer * @return array */ public function test(Customer $customer) { $this->markTestIncomplete('Bug: MAGETWO-34634'); // Precondition: $customer->persist(); $addressToDelete = $customer->getDataFieldConfig('address')['source']->getAddresses()[1]; // Steps: $this->cmsIndex->open(); $this->cmsIndex->getLinksBlock()->openLink("Log In"); $this->customerAccountLogin->getLoginBlock()->login($customer); $this->customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book'); $this->customerAccountIndex->getAdditionalAddressBlock()->deleteAdditionalAddress($addressToDelete); return ['deletedAddress' => $addressToDelete]; }
/** * Login customer. * * @return void */ protected function loginCustomer() { if (!$this->cmsIndex->getLinksBlock()->isLinkVisible('Log Out')) { $this->cmsIndex->getLinksBlock()->openLink("Log In"); $this->customerAccountLogin->getLoginBlock()->login($this->customer); } }
/** * Login customer * * @param CustomerInjectable $customer * @return void */ protected function loginCustomer(CustomerInjectable $customer) { $this->cmsIndex->open(); if (!$this->cmsIndex->getLinksBlock()->isLinkVisible('Log Out')) { $this->cmsIndex->getLinksBlock()->openLink('Log In'); $this->customerAccountLogin->getLoginBlock()->login($customer); } }
/** * 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.'); } }
/** * Assert the product is not displayed on Compare Products block on my account page * * @param CmsIndex $cmsIndex * @param CustomerAccountIndex $customerAccountIndex * @param int $countProducts [optional] * @param FixtureInterface $product [optional] * @return void */ public function processAssert(CmsIndex $cmsIndex, CustomerAccountIndex $customerAccountIndex, $countProducts = 0, FixtureInterface $product = null) { $cmsIndex->open(); $cmsIndex->getLinksBlock()->openLink("My Account"); $compareBlock = $customerAccountIndex->getCompareProductsBlock(); if ($countProducts > 1 && $product !== null) { \PHPUnit_Framework_Assert::assertFalse($compareBlock->isProductVisibleInCompareBlock($product->getName()), 'The product displays on Compare Products block on my account page.'); } else { \PHPUnit_Framework_Assert::assertEquals(self::SUCCESS_MESSAGE, $compareBlock->getEmptyMessage(), 'The product displays on Compare Products block on my account page.'); } }
/** * Run Change customer password test. * * @param Customer $initialCustomer * @param Customer $customer * @return void */ public function test(Customer $initialCustomer, Customer $customer) { // Preconditions $initialCustomer->persist(); // Steps $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $initialCustomer])->run(); $this->cmsIndex->getLinksBlock()->openLink('My Account'); $this->customerAccountIndex->getInfoBlock()->openChangePassword(); $this->customerAccountEdit->getAccountInfoForm()->fill($customer); $this->customerAccountEdit->getAccountInfoForm()->submit(); }
/** * Assert that "Compare Product" page contains product(s) that was added * - Product name * - Price * - SKU * - Description (if exists, else text "No") * - Short Description (if exists, else text "No") * * @param array $products * @param CatalogProductCompare $comparePage * @param CmsIndex $cmsIndex * @return void * * @SuppressWarnings(PHPMD.NPathComplexity) */ public function processAssert(array $products, CatalogProductCompare $comparePage, CmsIndex $cmsIndex) { $cmsIndex->open(); $cmsIndex->getLinksBlock()->openLink("Compare Products"); foreach ($products as $key => $product) { foreach ($this->attributeProduct as $attributeKey => $attribute) { $value = $attribute; $attribute = is_numeric($attributeKey) ? $attribute : $attributeKey; $attributeValue = $attribute != 'price' ? $product->hasData($attribute) ? $product->getData($attribute) : 'N/A' : ($product->getDataFieldConfig('price')['source']->getPreset() !== null ? $product->getDataFieldConfig('price')['source']->getPreset()['compare_price'] : number_format($product->getPrice(), 2)); $attribute = is_numeric($attributeKey) ? 'info' : 'attribute'; \PHPUnit_Framework_Assert::assertEquals($attributeValue, $comparePage->getCompareProductsBlock()->{'getProduct' . ucfirst($attribute)}($key + 1, $value), 'Product "' . $product->getName() . '" is\'n equals with data from fixture.'); } } }
/** * Test Creation for CustomerReviewReportEntity * * @param Review $review * @param Customer $customer * @param $customerLogin * @param CatalogProductSimple $product * @param BrowserInterface $browser * @return array * * @SuppressWarnings(PHPMD.ConstructorWithNameAsEnclosingClass) */ public function test(Review $review, Customer $customer, CatalogProductSimple $product, BrowserInterface $browser, $customerLogin) { // Preconditions $product->persist(); $this->cmsIndex->open(); if ($customerLogin == 'Yes') { $this->cmsIndex->getLinksBlock()->openLink("Log In"); $this->customerAccountLogin->getLoginBlock()->login($customer); } // Steps $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $this->pageCatalogProductView->getReviewSummary()->getAddReviewLink()->click(); $this->pageCatalogProductView->getReviewFormBlock()->fill($review); $this->pageCatalogProductView->getReviewFormBlock()->submit(); return ['product' => $product]; }
/** * Run Lock customer on edit page test. * * @param Customer $initialCustomer * @param Customer $customer * @param int $attempts * @param string $configData * @return void */ public function test(Customer $initialCustomer, Customer $customer, $attempts, $configData = null) { $this->configData = $configData; // Preconditions $this->objectManager->create('Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => $this->configData])->run(); $initialCustomer->persist(); // Steps $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $initialCustomer])->run(); $this->cmsIndex->getLinksBlock()->openLink('My Account'); $this->customerAccountIndex->getInfoBlock()->openChangePassword(); for ($i = 0; $i < $attempts; $i++) { if ($i > 0) { $this->customerAccountIndex->getInfoBlock()->checkChangePassword(); } $this->customerAccountEdit->getAccountInfoForm()->fill($customer); $this->customerAccountEdit->getAccountInfoForm()->submit(); } }
/** * Move recently compared products on order page. * * @param Customer $customer * @param string $products * @return array */ public function test(Customer $customer, $products) { // Preconditions // Create product $products = $this->objectManager->create('\\Magento\\Catalog\\Test\\TestStep\\CreateProductsStep', ['products' => $products])->run()['products']; foreach ($products as $itemProduct) { $this->browser->open($_ENV['app_frontend_url'] . $itemProduct->getUrlKey() . '.html'); $this->catalogProductView->getViewBlock()->clickAddToCompare(); } $this->cmsIndex->getLinksBlock()->openLink("Compare Products"); $this->catalogProductCompare->getCompareProductsBlock()->removeAllProducts(); // Steps: $this->customerIndex->open(); $this->customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); $this->customerIndexEdit->getPageActionsBlock()->createOrder(); $this->orderCreateIndex->getStoreBlock()->selectStoreView(); $activitiesBlock = $this->orderCreateIndex->getCustomerActivitiesBlock(); $activitiesBlock->getRecentlyComparedProductsBlock()->addProductsToOrder($products); $activitiesBlock->updateChanges(); return ['products' => $products, 'productsIsConfigured' => false]; }
/** * Customer logout from account * * @return void */ public function tearDown() { if ($this->cmsIndex->getLinksBlock()->isVisible()) { $this->cmsIndex->getLinksBlock()->openLink('Log Out'); } }
/** * Assert that customer successfully logs in. * * @param CmsIndex $cmsIndex * @param Customer $customer * @return void */ public function processAssert(CmsIndex $cmsIndex, Customer $customer) { $this->objectManager->create(\Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer])->run(); \PHPUnit_Framework_Assert::assertFalse($cmsIndex->getLinksBlock()->isAuthorizationVisible(), "Authorisation link is visible after Login attempt."); }
/** * Assert compare products link is NOT visible at the top of page. * * @param CmsIndex $cmsIndex * @return void */ public function processAssert(CmsIndex $cmsIndex) { \PHPUnit_Framework_Assert::assertFalse($cmsIndex->getLinksBlock()->isLinkVisible("Compare Products"), 'The link "Compare Products..." is visible at the top of page.'); }
/** * Remove compare product * * @return void */ protected function removeCompareProducts() { $this->cmsIndex->open(); $this->cmsIndex->getLinksBlock()->openLink("Compare Products"); $this->catalogProductCompare->getCompareProductsBlock()->removeAllProducts(); }
/** * 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.'); }
/** * Assert that product is present in default wishlist * * @param CmsIndex $cmsIndex * @param CustomerAccountIndex $customerAccountIndex * @param WishlistIndex $wishlistIndex * @param InjectableFixture $product * @return void */ public function processAssert(CmsIndex $cmsIndex, CustomerAccountIndex $customerAccountIndex, WishlistIndex $wishlistIndex, InjectableFixture $product) { $cmsIndex->getLinksBlock()->openLink('My Account'); $customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Wish List'); \PHPUnit_Framework_Assert::assertTrue($wishlistIndex->getItemsBlock()->getItemProduct($product)->isVisible(), $product->getName() . ' is not visible on wishlist page.'); }
/** * Assert that selected language currently displays on frontend. * * @param string $languageTemplate * @param CmsIndex $indexPage * @return void */ public function processAssert($languageTemplate, CmsIndex $indexPage) { $indexPage->open(); \PHPUnit_Framework_Assert::assertTrue($indexPage->getLinksBlock()->isLinkVisible($languageTemplate), 'Selected language not displays on frontend.'); }
/** * Assert that the correct option details are displayed on the "See Details" tooltip. * * @param CmsIndex $cmsIndex * @param WishlistIndex $wishlistIndex * @param InjectableFixture $product * @param FixtureFactory $fixtureFactory * @return void */ public function processAssert(CmsIndex $cmsIndex, WishlistIndex $wishlistIndex, InjectableFixture $product, FixtureFactory $fixtureFactory) { $cmsIndex->getLinksBlock()->openLink('My Wish List'); $this->assertProductDetails($wishlistIndex, $product, $fixtureFactory); }