/** * @ZephyrId MAGETWO-12405 */ public function testCreateNewLocalizedStoreView() { $objectManager = Factory::getObjectManager(); $storeFixture = $objectManager->create('Magento\\Store\\Test\\Fixture\\Store', ['dataSet' => 'german']); $storeListPage = Factory::getPageFactory()->getAdminSystemStore(); $storeListPage->open(); $storeListPage->getGridPageActions()->addStoreView(); $newStorePage = Factory::getPageFactory()->getAdminSystemStoreNewStore(); $newStorePage->getStoreForm()->fill($storeFixture); $newStorePage->getFormPageActions()->save(); $storeListPage->getMessagesBlock()->waitSuccessMessage(); $this->assertContains('The store view has been saved', $storeListPage->getMessagesBlock()->getSuccessMessages()); $this->assertTrue($storeListPage->getStoreGrid()->isStoreExists($storeFixture->getName())); $cachePage = Factory::getPageFactory()->getAdminCache(); $cachePage->open(); $cachePage->getActionsBlock()->flushCacheStorage(); $cachePage->getMessagesBlock()->waitSuccessMessage(); $configPage = Factory::getPageFactory()->getAdminSystemConfig(); $configPage->open(); $configPage->getPageActions()->selectStore($storeFixture->getGroupId() . "/" . $storeFixture->getName()); $configGroup = $configPage->getForm()->getGroup('Locale Options'); $configGroup->open(); $configGroup->setValue('select-groups-locale-fields-code-value', 'German (Germany)'); $configPage->getPageActions()->save(); $configPage->getMessagesBlock()->waitSuccessMessage(); $homePage = Factory::getPageFactory()->getCmsIndexIndex(); $homePage->open(); $homePage->getStoreSwitcherBlock()->selectStoreView($storeFixture->getName()); $this->assertTrue($homePage->getSearchBlock()->isPlaceholderContains('Den gesamten Shop durchsuchen')); }
/** * Assert configurable product on Frontend * * @param ConfigurableProduct $product * @return void */ protected function assertOnFrontend(ConfigurableProduct $product) { //Pages $frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex(); $categoryPage = Factory::getPageFactory()->getCatalogCategoryView(); $productPage = Factory::getPageFactory()->getCatalogProductView(); //Steps $frontendHomePage->open(); $frontendHomePage->getTopmenu()->selectCategoryByName($product->getCategoryName()); //Verification on category product list $productListBlock = $categoryPage->getListProductBlock(); $this->assertTrue($productListBlock->isProductVisible($product->getName()), 'Product is absent on category page.'); //Verification on product detail page $productViewBlock = $productPage->getViewBlock(); $productListBlock->openProductViewPage($product->getName()); $this->assertEquals($product->getName(), $productViewBlock->getProductName(), 'Product name does not correspond to specified.'); $price = $product->getProductPrice(); $priceOnPage = $productViewBlock->getPriceBlock()->getPrice(); $this->assertEquals(number_format($price, 2), number_format($priceOnPage, 2), 'Product price does not correspond to specified.'); $pageOptions = $productViewBlock->getOptions($product); $configurableOptions = []; foreach ($pageOptions['configurable_options'] as $attribute) { $configurableOption = []; foreach ($attribute['options'] as $option) { $configurableOption[] = $option['title']; } $configurableOptions[$attribute['title']] = $configurableOption; } $this->assertEquals($product->getConfigurableOptions(), $configurableOptions); }
/** * Edit configurable product and add new options to attribute * * @ZephyrId MAGETWO-12840 * @return void */ public function testCreateConfigurableProduct() { //Preconditions //Preparing Data for original product $configurable = Factory::getFixtureFactory()->getMagentoConfigurableProductConfigurableProduct(); $configurable->switchData('configurable'); $configurable->persist(); $productSku = $configurable->getSku(); //Preparing Data for editing product $editProduct = $configurable->getEditData(); //Steps $createProductPage = Factory::getPageFactory()->getCatalogProductNew(); $productForm = $createProductPage->getProductForm(); //Login Factory::getApp()->magentoBackendLoginUser(); $productGridPage = Factory::getPageFactory()->getCatalogProductIndex(); $productGridPage->open(); //Search and open original configurable product $productGridPage->getProductGrid()->searchAndOpen(['sku' => $productSku]); //Editing product options $productForm->fill($editProduct); $createProductPage->getFormPageActions()->save(); //Verifying $createProductPage->getMessagesBlock()->waitSuccessMessage(); //Flush cache $cachePage = Factory::getPageFactory()->getAdminCache(); $cachePage->open(); $cachePage->getActionsBlock()->flushMagentoCache(); //Verifying $this->assertOnGrid($editProduct); $this->assertOnFrontend($editProduct); }
/** * Assert product data on category and product pages * * @param Product $product * @return void */ protected function assertOnCategory($product) { //Pages $frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex(); $categoryPage = Factory::getPageFactory()->getCatalogCategoryView(); $productPage = Factory::getPageFactory()->getCatalogProductView(); //Steps $frontendHomePage->open(); $frontendHomePage->getTopmenu()->selectCategoryByName($product->getCategoryName()); //Verification on category product list $productListBlock = $categoryPage->getListProductBlock(); $this->assertTrue($productListBlock->isProductVisible($product->getName())); $productListBlock->openProductViewPage($product->getName()); //Verification on product detail page $productViewBlock = $productPage->getViewBlock(); $this->assertEquals($product->getName(), $productViewBlock->getProductName()); $price = $productViewBlock->getPriceBlock()->getPrice(); $this->assertEquals(number_format($product->getProductPrice(), 2), $price); $productOptionsBlock = $productPage->getViewBlock()->getCustomOptionsBlock(); $fixture = $product->getData('fields/custom_options/value'); $actualOptions = $productOptionsBlock->getOptions($product); $this->assertCount(count($fixture), $actualOptions); $this->assertTrue(isset($actualOptions['custom_options'][$fixture[0]['title']]['options'][0]['title'])); $this->assertEquals($fixture[0]['title'], $actualOptions['custom_options'][$fixture[0]['title']]['title']); }
/** * Create product * * @param FixtureInterface $fixture [optional] * @return mixed|string */ public function persist(FixtureInterface $fixture = null) { Factory::getApp()->magentoBackendLoginUser(); $createProductPage = Factory::getPageFactory()->getCatalogProductNew(); $createProductPage->open(['type' => $fixture->getDataConfig()['create_url_params']['type'], 'set' => $fixture->getDataConfig()['create_url_params']['set']]); $createProductPage->getProductForm()->fill($fixture); $createProductPage->getFormPageActions()->save(); $createProductPage->getMessagesBlock()->waitSuccessMessage(); }
/** * Assert absence product on category page (frontend) * * @param Product $product * @return void */ protected function assertAbsenceOnCategory(Product $product) { //Pages $frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex(); $categoryPage = Factory::getPageFactory()->getCatalogCategoryView(); //Steps $frontendHomePage->open(); $frontendHomePage->getTopmenu()->selectCategoryByName($product->getCategoryName()); //Verification on category product list $productListBlock = $categoryPage->getListProductBlock(); $this->assertFalse($productListBlock->isProductVisible($product->getName())); }
/** * Reset password on frontend */ public function testForgotPassword() { // Create Customer $customer = $this->objectManager->getInstance()->create('Magento\\Customer\\Test\\Fixture\\Customer', ['dataSet' => 'customer_US_1']); $customer->persist(); $customerAccountLoginPage = Factory::getPageFactory()->getCustomerAccountLogin(); $forgotPasswordPage = Factory::getPageFactory()->getCustomerAccountForgotpassword(); $forgotPasswordPage->open(); $forgotPasswordPage->getForgotPasswordForm()->resetForgotPassword($customer); //Verifying $message = sprintf('If there is an account associated with %s you will receive an email with a link to reset your password.', $customer->getEmail()); $this->assertContains($message, $customerAccountLoginPage->getMessages()->getSuccessMessages()); }
/** * Execute handler * * @param FixtureInterface $fixture [optional] * @return mixed */ public function persist(FixtureInterface $fixture = null) { /** @var \Magento\Customer\Test\Fixture\Address $fixture */ // Pages $loginPage = Factory::getPageFactory()->getCustomerAccountLogin(); $addressPage = Factory::getPageFactory()->getCustomerAddressEdit(); $loginPage->open(); if ($loginPage->getLoginBlock()->isVisible()) { $loginPage->getLoginBlock()->login($fixture->getCustomer()); } $addressPage->open(); $addressPage->getEditForm()->editCustomerAddress($fixture); }
/** * Assert simple product on Frontend * * @param SimpleProduct $product * @return void */ protected function assertProductOnFrontend(SimpleProduct $product) { //Pages $frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex(); $categoryPage = Factory::getPageFactory()->getCatalogCategoryView(); $productPage = Factory::getPageFactory()->getCatalogProductView(); $frontendHomePage->open(); $frontendHomePage->getTopmenu()->selectCategoryByName($product->getNewCategoryName()); //Verification on category product list $productListBlock = $categoryPage->getListProductBlock(); $this->assertTrue($productListBlock->isProductVisible($product->getName()), 'Product is absent on category page.'); //Verification on product detail page $productViewBlock = $productPage->getViewBlock(); $productListBlock->openProductViewPage($product->getName()); $this->assertEquals($product->getName(), $productViewBlock->getProductName()); $price = $productViewBlock->getPriceBlock()->getPrice(); $this->assertEquals(number_format($product->getProductPrice(), 2), $price); }
/** * Login admin user * * @param FixtureInterface $fixture [optional] * @return void|mixed */ public function persist(FixtureInterface $fixture = null) { if (null === $fixture) { $fixture = Factory::getFixtureFactory()->getMagentoBackendAdminSuperAdmin(); } $loginPage = Factory::getPageFactory()->getAdminAuthLogin(); $loginForm = $loginPage->getLoginBlock(); $adminHeaderPanel = $loginPage->getHeaderBlock(); if (!$adminHeaderPanel || !$adminHeaderPanel->isVisible()) { $loginPage->open(); if ($adminHeaderPanel->isVisible()) { return; } $loginForm->fill($fixture); $loginForm->submit(); $loginPage->waitForHeaderBlock(); } }
/** * New customer creation in backend * * @ZephyrId MAGETWO-12516 */ public function testCreateCustomer() { //Data $customerFixture = Factory::getFixtureFactory()->getMagentoCustomerCustomer(); $customerFixture->switchData('backend_customer'); $searchData = ['email' => $customerFixture->getEmail()]; //Pages $customerPage = Factory::getPageFactory()->getCustomerIndex(); $customerCreatePage = Factory::getPageFactory()->getCustomerIndexNew(); //Steps $customerPage->open(); $customerPage->getPageActionsBlock()->addNew(); $customerCreatePage->getCustomerForm()->fillCustomer($customerFixture); $customerCreatePage->getPageActionsBlock()->saveAndContinue(); $customerCreatePage->getMessagesBlock()->waitSuccessMessage(); //Verifying $customerPage->open(); $this->assertTrue($customerPage->getCustomerGridBlock()->isRowVisible($searchData), 'Customer email "' . $searchData['email'] . '" not found in the grid'); }
/** * Assert product data on category and product pages * * @return void */ protected function assertOnFrontend() { $product = $this->product; $frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex(); $categoryPage = Factory::getPageFactory()->getCatalogCategoryView(); $productPage = Factory::getPageFactory()->getCatalogProductView(); $frontendHomePage->open(); $frontendHomePage->getTopmenu()->selectCategoryByName($product->getCategoryName()); $productListBlock = $categoryPage->getListProductBlock(); $this->assertTrue($productListBlock->isProductVisible($product->getName())); $productListBlock->openProductViewPage($product->getName()); $productViewBlock = $productPage->getViewBlock(); $this->assertEquals($product->getName(), $productViewBlock->getProductName()); $this->assertEquals(number_format($product->getProductPrice(), 2), $productViewBlock->getPriceBlock()->getPrice()); $productDownloadableLinks = $product->getData('fields/downloadable_links/value/downloadable/link'); $pageOptions = $productViewBlock->getOptions($product); $pageDownloadableOptions = $pageOptions['downloadable_options']['downloadable_links']; $pageDownloadableLinks = $pageDownloadableOptions['downloadable']['link']; foreach ($productDownloadableLinks as $key => $link) { $this->assertEquals($pageDownloadableLinks[$key]['title'], $link['title']); $this->assertEquals($pageDownloadableLinks[$key]['price'], $link['price']); } }
/** * Checking the product on the category page * * @param Bundle $product * @return void */ protected function assertOnCategory($product) { //Pages $frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex(); $categoryPage = Factory::getPageFactory()->getCatalogCategoryView(); $productPage = Factory::getPageFactory()->getCatalogProductView(); //Steps $frontendHomePage->open(); $frontendHomePage->getTopmenu()->selectCategoryByName($product->getCategoryName()); //Verification on category product list $productListBlock = $categoryPage->getListProductBlock(); $this->assertTrue($productListBlock->isProductVisible($product->getName()), 'Product "' . $product->getName() . '" is absent on category page'); $productListBlock->openProductViewPage($product->getName()); //Verification on product detail page $productViewBlock = $productPage->getViewBlock(); $this->assertSame($product->getName(), $productViewBlock->getProductName()); $this->assertEquals($product->getProductPrice(), ['price_from' => $productViewBlock->getPriceBlock()->getPriceFrom(), 'price_to' => $productViewBlock->getPriceBlock()->getPriceTo()]); $expectedOptions = $product->getBundleOptions(); $actualOptions = $productViewBlock->getOptions($product)['bundle_options']; foreach ($actualOptions as $key => $actualOption) { $this->assertContains($expectedOptions[$key]['title'], $actualOption); } }
/** * @param Product $product * @param Product[] $assigned * @return void */ protected function assertOnTheFrontEnd(Product $product, array $assigned) { /** @var Product $simple2 */ /** @var Product $configurable */ list($simple2, $configurable) = $assigned; //Open up simple1 product page $productPage = Factory::getPageFactory()->getCatalogProductView(); Factory::getClientBrowser()->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $this->assertEquals($product->getName(), $productPage->getViewBlock()->getProductName()); /** @var \Magento\Catalog\Test\Block\Product\ProductList\Upsell $upsellBlock */ $upsellBlock = $productPage->getUpsellBlock(); //Verify upsell simple2 and configurable on Simple1 product page $this->assertTrue($upsellBlock->isUpsellProductVisible($simple2->getName())); $this->assertTrue($upsellBlock->isUpsellProductVisible($configurable->getName())); //Open and verify configurable page $upsellBlock->openUpsellProduct($configurable->getName()); $this->assertEquals($configurable->getName(), $productPage->getViewBlock()->getProductName()); //Verify upsell simple2 on Configurable product page and open it $upsellBlock = $productPage->getUpsellBlock(); $this->assertTrue($upsellBlock->isUpsellProductVisible($simple2->getName())); $upsellBlock->openUpsellProduct($simple2->getName()); $this->assertEquals($simple2->getName(), $productPage->getViewBlock()->getProductName()); $this->assertFalse($productPage->getUpsellBlock()->isVisible()); }
/** * Assert Grouped product on Frontend * * @param GroupedProduct $product * @return void */ protected function assertOnFrontend(GroupedProduct $product) { //Pages $frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex(); $categoryPage = Factory::getPageFactory()->getCatalogCategoryView(); $productPage = Factory::getPageFactory()->getCatalogProductView(); //Steps $frontendHomePage->open(); $frontendHomePage->getTopmenu()->selectCategoryByName($product->getCategoryName()); //Verification on category product list $productListBlock = $categoryPage->getListProductBlock(); $this->assertTrue($productListBlock->isProductVisible($product->getName()), 'Product is absent on category page.'); //Verification on product detail page $productViewBlock = $productPage->getViewBlock(); $productListBlock->openProductViewPage($product->getName()); $this->assertEquals($product->getName(), $productViewBlock->getProductName(), 'Product name does not correspond to specified.'); $optionsOnPage = $productViewBlock->getOptions($product); $pageAssociatedProductNames = []; foreach ($optionsOnPage['grouped_options'] as $optionOnPage) { $pageAssociatedProductNames[] = $optionOnPage['name']; } $this->assertEquals($product->getAssociatedProductNames(), $pageAssociatedProductNames); }
/** * Assign an array of products as cross-sells to the passed in $product * * @param Product $product * @param array $crosssellProducts * @return void */ private function addCrosssellProducts(Product $product, array $crosssellProducts) { $crosssellFixture = Factory::getFixtureFactory()->getMagentoCatalogCrosssellProducts(); $crosssellFixture->setProducts($crosssellProducts); $crosssellFixture->switchData('add_crosssell_products'); //Data $productGridPage = Factory::getPageFactory()->getCatalogProductIndex(); $editProductPage = Factory::getPageFactory()->getCatalogProductEdit(); //Steps $productGridPage->open(); $productGridPage->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]); $editProductPage->getProductForm()->fill($crosssellFixture); $editProductPage->getFormPageActions()->save(); $editProductPage->getMessagesBlock()->waitSuccessMessage(); }
/** * Check the product on the category page * * @param Bundle $product * @param string $categoryName * @return void */ protected function assertOnCategory($product, $categoryName) { //Pages $frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex(); $categoryPage = Factory::getPageFactory()->getCatalogCategoryView(); $productPage = Factory::getPageFactory()->getCatalogProductView(); //Steps $frontendHomePage->open(); $frontendHomePage->getTopmenu()->selectCategoryByName($categoryName); //Verification on category product list $productListBlock = $categoryPage->getListProductBlock(); $this->assertTrue($productListBlock->isProductVisible($product->getName())); $productListBlock->openProductViewPage($product->getName()); //Verification on product detail page $productViewBlock = $productPage->getViewBlock(); $this->assertSame($product->getName(), $productViewBlock->getProductName()); $this->assertEquals($product->getProductPrice(), ['price_from' => $productViewBlock->getPriceBlock()->getPriceFrom(), 'price_to' => $productViewBlock->getPriceBlock()->getPriceTo()]); }
/** * Assert product data on product page * * @param SimpleProduct $productOld * @param SimpleProduct $productEdited * @return void */ protected function assertOnProductPage(SimpleProduct $productOld, SimpleProduct $productEdited) { Factory::getClientBrowser()->open($_ENV['app_frontend_url'] . $productOld->getUrlKey() . '.html'); $productPage = Factory::getPageFactory()->getCatalogProductView(); $productViewBlock = $productPage->getViewBlock(); $this->assertEquals($productEdited->getName(), $productViewBlock->getProductName()); $price = $productViewBlock->getPriceBlock()->getPrice(); $this->assertEquals(number_format($productEdited->getProductPrice(), 2), $price); }
/** * Assert configurable product is added to cart together with the proper related product * * @param Product $product * @param Product[] $assigned * @return void */ protected function assertOnTheFrontEnd(Product $product, array $assigned) { /** @var Product $simple2 */ /** @var Product $configurable */ list($simple2, $configurable) = $assigned; //Open up simple1 product page $productPage = Factory::getPageFactory()->getCatalogProductView(); Factory::getClientBrowser()->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $this->assertEquals($product->getName(), $productPage->getViewBlock()->getProductName()); /** @var \Magento\Catalog\Test\Block\Product\ProductList\Related $relatedBlock */ $relatedBlock = $productPage->getRelatedProductBlock(); //Verify related simple2 and configurable on Simple1 product page $this->assertTrue($relatedBlock->isRelatedProductVisible($simple2->getName())); $this->assertTrue($relatedBlock->isRelatedProductSelectable($simple2->getName())); $this->assertTrue($relatedBlock->isRelatedProductVisible($configurable->getName())); $this->assertFalse($relatedBlock->isRelatedProductSelectable($configurable->getName())); //Open and verify configurable page $relatedBlock->openRelatedProduct($configurable->getName()); $this->assertEquals($configurable->getName(), $productPage->getViewBlock()->getProductName()); //Verify related simple2 on Configurable product page and add to cart it $relatedBlock = $productPage->getRelatedProductBlock(); $this->assertTrue($relatedBlock->isRelatedProductVisible($simple2->getName())); $this->assertTrue($relatedBlock->isRelatedProductSelectable($simple2->getName())); $relatedBlock->selectProductForAddToCart($simple2->getName()); $productPage->getViewBlock()->addToCart($configurable); //Verify that both configurable product and simple product 2 are added to shopping cart $checkoutCartPage = Factory::getPageFactory()->getCheckoutCartIndex(); $checkoutCartBlock = $checkoutCartPage->getCartBlock(); $checkoutCartPage->getMessagesBlock()->waitSuccessMessage(); $this->assertTrue($checkoutCartBlock->isProductInShoppingCart($configurable), 'Configurable product was not found in the shopping cart.'); $this->assertTrue($checkoutCartBlock->isProductInShoppingCart($simple2), 'Related product was not found in the shopping cart.'); }
/** * Logout admin user * * @param FixtureInterface $fixture [optional] * @return mixed|string * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function persist(FixtureInterface $fixture = null) { $homePage = Factory::getPageFactory()->getAdminDashboard(); $headerBlock = $homePage->getAdminPanelHeader(); $headerBlock->logOut(); }