/** * Initialize fixture data * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function _initData() { $this->_data['checkout'] = ['prices' => ['price_from' => 110, 'price_to' => 120], 'selection' => [0]]; parent::_initData(); $this->_data['fields'] = array_merge_recursive($this->_data['fields'], ['sku_type' => ['value' => 'Fixed', 'input_value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'price_type' => ['value' => 'Fixed', 'input_value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'price' => ['value' => 100, 'group' => static::GROUP_PRODUCT_DETAILS], 'tax_class_id' => ['value' => 'Taxable Goods', 'input_value' => '2', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'weight_type' => ['value' => 'Fixed', 'input_value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'weight' => ['value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS], 'product_website_1' => ['value' => 'Yes', 'input_value' => [1], 'group' => static::GROUP_PRODUCT_WEBSITE, 'input' => 'checkbox', 'input_name' => 'website_ids'], 'shipment_type' => ['value' => 'Separately', 'input_value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'bundle_selections' => ['value' => ['bundle_options' => [['title' => 'Drop-down Option', 'type' => 'Drop-down', 'required' => 'Yes', 'assigned_products' => [['search_data' => ['name' => '%item1_simple1::getName%'], 'data' => ['selection_price_value' => 10, 'selection_price_type' => 'Fixed', 'selection_qty' => 1, 'product_id' => '%item1_simple1::getProductId%']], ['search_data' => ['name' => '%item1_virtual2::getName%'], 'data' => ['selection_price_value' => 20, 'selection_price_type' => 'Percent', 'selection_qty' => 1, 'product_id' => '%item1_virtual2::getProductId%']]]]]], 'group' => static::GROUP]]); $this->_repository = Factory::getRepositoryFactory()->getMagentoBundleBundle($this->_dataConfig, $this->_data); }
/** * @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']); }
/** * Init most popular custom roles */ protected function initCustomRoles() { $resourceFixture = Factory::getFixtureFactory()->getMagentoUserResource(); $salesAllScopes = $this->_data['custom_permissions_all_scopes']['data']; $salesAllScopes['fields']['resource']['value'] = $resourceFixture->get('Magento_Sales::sales'); $this->_data['sales_all_scopes']['data'] = $salesAllScopes; }
/** * {inheritdoc} */ protected function _initData() { parent::_initData(); $this->_dataConfig = ['constraint' => 'Success', 'grid_filter' => ['name'], 'create_url_params' => ['type' => 'simple', 'set' => static::DEFAULT_ATTRIBUTE_SET_ID], 'input_prefix' => 'product']; $data = $this->_getPreparedData(); $this->_data['fields'] = array_merge($this->_data['fields'], $data); $this->_repository = Factory::getRepositoryFactory()->getMagentoCatalogSimpleProduct($this->_dataConfig, $this->_data); }
/** * {@inheritdoc} */ protected function _initData() { parent::_initData(); $this->_dataConfig = ['constraint' => 'Success', 'grid_filter' => ['name'], 'create_url_params' => ['type' => 'virtual', 'set' => static::DEFAULT_ATTRIBUTE_SET_ID], 'input_prefix' => 'product']; $data = ['is_virtual' => ['value' => '', 'group' => null], 'price' => ['value' => 15, 'group' => static::GROUP_PRODUCT_DETAILS], 'tax_class_id' => ['value' => 'Taxable Goods', 'input_value' => '2', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'qty' => ['value' => 1000, 'group' => static::GROUP_PRODUCT_DETAILS, 'input_name' => 'product[quantity_and_stock_status][qty]'], 'product_website_1' => ['value' => 'Yes', 'input_value' => 1, 'group' => static::GROUP_PRODUCT_WEBSITE, 'input' => 'checkbox', 'input_name' => 'product[website_ids][]'], 'inventory_manage_stock' => ['value' => 'No', 'input_value' => '0', 'group' => static::GROUP_PRODUCT_INVENTORY, 'input' => 'select', 'input_name' => 'product[stock_data][manage_stock]']]; $this->_data['fields'] = array_merge($this->_data['fields'], $data); $this->_repository = Factory::getRepositoryFactory()->getMagentoCatalogVirtualProduct($this->_dataConfig, $this->_data); }
/** * 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(); }
/** * Fill condition options * * @param array $fields * @param SimpleElement|null $element * @return void */ public function fillFormTab(array $fields, SimpleElement $element = null) { $data = $this->dataMapping($fields); $conditionsBlock = Factory::getBlockFactory()->getMagentoCatalogRuleConditions($element->find($this->ruleConditions)); $conditionsBlock->clickAddNew(); $conditionsBlock->selectCondition($data['condition_type']['value']); $conditionsBlock->clickEllipsis(); $conditionsBlock->selectConditionValue($data['condition_value']['value']); }
/** * Init Data */ protected function _initData() { $this->_dataConfig = ['assignType ' => $this->assignType]; $productsArray = []; foreach ($this->_products as $key => $product) { /** @var $product \Magento\Catalog\Test\Fixture\Product */ $productsArray['product_' . $key] = ['sku' => $product->getSku(), 'name' => $product->getName()]; } $this->_data['fields']['cross_sell_products']['value'] = $productsArray; $this->_data['fields']['cross_sell_products']['group'] = $this->group; $this->_repository = Factory::getRepositoryFactory()->getMagentoCatalogAssignProducts($this->_dataConfig, $this->_data); }
/** * 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); }
/** * 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(); } }
/** * 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); }
/** * 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()); }
/** * Get abstract block. * * @return \Magento\Backend\Test\Block\Template */ public function getTemplateBlock() { return Factory::getBlockFactory()->getMagentoBackendTemplate($this->browser->find($this->templateBlock, Locator::SELECTOR_CSS)); }
/** * Obtain store configuration form group. * * @param string $tabName * @param string $groupName * @return Form\Group */ public function getGroup($tabName, $groupName) { $tabUrl = $this->baseUrl . 'section/' . $tabName; if ($this->getBrowserUrl() !== $tabUrl) { $this->browser->open($tabUrl); } $this->waitForElementNotVisible($this->tabReadiness); $groupElement = $this->_rootElement->find(sprintf($this->groupBlock, $tabName, $groupName), Locator::SELECTOR_CSS); if (!$groupElement->isVisible()) { $this->_rootElement->find(sprintf($this->groupBlockLink, $tabName, $groupName), Locator::SELECTOR_CSS)->click(); $this->waitForElementNotVisible($this->tabReadiness); $groupElement = $this->_rootElement->find(sprintf($this->groupBlock, $tabName, $groupName), Locator::SELECTOR_CSS); } $blockFactory = Factory::getBlockFactory(); return $blockFactory->getMagentoBackendSystemConfigFormGroup($groupElement); }
/** * Get form for edit customer address. * * @return \Magento\Customer\Test\Block\Address\Edit */ public function getEditBlock() { return Factory::getBlockFactory()->getMagentoCustomerAddressEdit($this->browser->find($this->editBlock, Locator::SELECTOR_CSS)); }
/** * Get backend abstract block * * @return \Magento\Backend\Test\Block\Template */ protected function getTemplateBlock() { return Factory::getBlockFactory()->getMagentoBackendTemplate($this->_rootElement->find($this->templateBlock, Locator::SELECTOR_XPATH)); }
/** * Create product * * @return void */ public function persist() { $id = Factory::getApp()->magentoCatalogCreateProduct($this); $this->_data['fields']['id']['value'] = $id; }
/** * Persists prepared data into application */ public function persist() { Factory::getApp()->magentoCustomerCreateAddress($this); }
/** * Open backend page and log in if needed * * @param array $params * @return $this */ public function open(array $params = []) { Factory::getApp()->magentoBackendLoginUser(); return parent::open($params); }
/** * Get customer register block form. * * @return \Magento\Customer\Test\Block\Form\Register */ public function getRegisterBlock() { return Factory::getBlockFactory()->getMagentoCustomerFormRegister($this->browser->find($this->registerBlock, Locator::SELECTOR_CSS)); }
/** * Get Customer Forgot Password form. * * @return \Magento\Customer\Test\Block\Form\ForgotPassword */ public function getForgotPasswordForm() { return Factory::getBlockFactory()->getMagentoCustomerFormForgotPassword($this->browser->find($this->forgotPasswordForm, Locator::SELECTOR_CSS)); }
/** * Get "Proceed to One Page Checkout" block. * * @return Link */ public function getOnepageLinkBlock() { return Factory::getBlockFactory()->getMagentoCheckoutOnepageLink($this->_rootElement->find($this->onepageLinkBlock, Locator::SELECTOR_CSS)); }