/** * Assert that data at the form corresponds to the fixture data * * @param SystemVariable $customVariable * @param SystemVariableIndex $systemVariableIndex * @param SystemVariableNew $systemVariableNew * @param Store $storeOrigin * @param SystemVariable $customVariableOrigin * @return void * * @SuppressWarnings(PHPMD.NPathComplexity) */ public function processAssert(SystemVariable $customVariable, SystemVariableIndex $systemVariableIndex, SystemVariableNew $systemVariableNew, Store $storeOrigin = null, SystemVariable $customVariableOrigin = null) { // Prepare data $data = $customVariableOrigin === null ? $customVariable->getData() : array_merge($customVariableOrigin->getData(), $customVariable->getData()); if ($customVariableOrigin !== null) { $dataOrigin = $data; $dataOrigin['html_value'] = $customVariableOrigin->getHtmlValue(); $dataOrigin['plain_value'] = $customVariableOrigin->getPlainValue(); } else { $dataOrigin = $data; } if ($data['html_value'] == '') { $data['html_value'] = $customVariableOrigin->getHtmlValue(); $data['use_default_value'] = 'Yes'; } $data['plain_value'] = $data['plain_value'] == '' ? $customVariableOrigin->getPlainValue() : $data['plain_value']; // Perform assert $systemVariableIndex->open(); $systemVariableIndex->getSystemVariableGrid()->searchAndOpen(['code' => $data['code']]); $formData = $systemVariableNew->getSystemVariableForm()->getData($customVariable); $errors = $this->verifyData($dataOrigin, $formData); \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); if ($storeOrigin !== null) { $systemVariableNew->getFormPageActions()->selectStoreView($storeOrigin->getName()); $formData = $systemVariableNew->getSystemVariableForm()->getData($customVariable); $errors = $this->verifyData($data, $formData); \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); } }
/** * Check is Store View Visible * * @param Store $store * @return bool */ public function isStoreViewVisible($store) { $storeViewDropdown = $this->_rootElement->find($this->dropDownButton); $storeViewDropdown->click(); $isStoreViewVisible = $this->_rootElement->find(sprintf($this->storeViewSelector, $store->getCode()))->isVisible(); $storeViewDropdown->click(); return $isStoreViewVisible; }
/** * Select store view for order based on Order fixture * * @param StoreFixture|null $fixture */ public function selectStoreView(StoreFixture $fixture = null) { if (!$this->isVisible()) { return; } $storeName = $fixture == null ? 'Default Store View' : $fixture->getName(); $selector = '//label[text()="' . $storeName . '"]/preceding-sibling::*'; $this->_rootElement->find($selector, Locator::SELECTOR_XPATH, 'checkbox')->setValue('Yes'); $this->getTemplateBlock()->waitLoader(); }
/** * Runs Update Store Entity test * * @param Store $storeInitial * @param Store $store * @return void */ public function test(Store $storeInitial, Store $store) { // Preconditions: $storeInitial->persist(); // Steps: $this->storeIndex->open(); $this->storeIndex->getStoreGrid()->searchAndOpenStore($storeInitial); $this->editStore->getStoreForm()->fill($store); $this->editStore->getFormPageActions()->save(); }
/** * Select store view for order based on Order fixture * * @param StoreFixture|null $fixture */ public function selectStoreView(StoreFixture $fixture = null) { if (!$this->isVisible()) { return; } $storeName = $fixture == null ? 'Default Store View' : $fixture->getName(); $selector = sprintf($this->store, $storeName); $this->_rootElement->find($selector, Locator::SELECTOR_XPATH, 'checkbox')->setValue('Yes'); $this->getTemplateBlock()->waitLoader(); }
/** * Assert that locale options can be changed and checks new text on index page. * * @param SystemConfig $systemConfig * @param Store $store * @param CmsIndex $cmsIndex * @param string $locale * @param string $welcomeText * @return void */ public function processAssert(SystemConfig $systemConfig, Store $store, CmsIndex $cmsIndex, $locale, $welcomeText) { // Set locale options $systemConfig->open(); $systemConfig->getPageActions()->selectStore($store->getGroupId() . "/" . $store->getName()); $configGroup = $systemConfig->getForm()->getGroup('Locale Options'); $configGroup->open(); $configGroup->setValue('select-groups-locale-fields-code-value', $locale); $systemConfig->getPageActions()->save(); $systemConfig->getMessagesBlock()->waitSuccessMessage(); // Check presents income text on index page $cmsIndex->open(); $cmsIndex->getStoreSwitcherBlock()->selectStoreView($store->getName()); \PHPUnit_Framework_Assert::assertTrue($cmsIndex->getSearchBlock()->isPlaceholderContains($welcomeText), "Locale not applied."); }
/** * 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); } }
/** * Assert that locale options can be changed and checks new text on index page. * * @param SystemConfig $systemConfig * @param Store $store * @param CmsIndex $cmsIndex * @param AdminCache $adminCache * @param string $locale * @param string $welcomeText */ public function processAssert(SystemConfig $systemConfig, Store $store, CmsIndex $cmsIndex, AdminCache $adminCache, $locale, $welcomeText) { // Set locale options $systemConfig->open(); $systemConfig->getPageActions()->selectStore($store->getGroupId() . "/" . $store->getName()); $systemConfig->getModalBlock()->acceptAlert(); $configGroup = $systemConfig->getForm()->getGroup('general', 'locale', 'code'); $configGroup->setValue('general', 'locale', 'code', $locale); $systemConfig->getPageActions()->save(); $systemConfig->getMessagesBlock()->waitSuccessMessage(); // Flush cache $adminCache->open(); $adminCache->getActionsBlock()->flushMagentoCache(); $adminCache->getMessagesBlock()->waitSuccessMessage(); // Check presents income text on index page $cmsIndex->open(); if ($cmsIndex->getFooterBlock()->isStoreGroupSwitcherVisible() && $cmsIndex->getFooterBlock()->isStoreGroupVisible($store)) { $cmsIndex->getFooterBlock()->selectStoreGroup($store); } $cmsIndex->getStoreSwitcherBlock()->selectStoreView($store->getName()); \PHPUnit_Framework_Assert::assertTrue($cmsIndex->getSearchBlock()->isPlaceholderContains($welcomeText), "Locale not applied."); }
/** * Delete Store after test. * * @return void */ public function tearDown() { if ($this->store !== null) { $storeIndex = $this->objectManager->create('Magento\\Backend\\Test\\Page\\Adminhtml\\StoreIndex'); $storeIndex->open(); $storeIndex->getStoreGrid()->searchAndOpen(['store_title' => $this->store->getName()]); $storeNew = $this->objectManager->create('Magento\\Backend\\Test\\Page\\Adminhtml\\StoreNew'); $storeNew->getFormPageActions()->delete(); $storeDelete = $this->objectManager->create('Magento\\Backend\\Test\\Page\\Adminhtml\\StoreDelete'); $storeDelete->getStoreForm()->fillForm(['create_backup' => 'No']); $storeDelete->getFormPageActions()->delete(); } $this->store = null; }
/** * Delete Store after test. * * @return void */ public function tearDown() { // TODO: Move store clean up to "tearDownAfterClass" method after fix bug MAGETWO-29331 if ($this->store !== null) { $storeIndex = $this->objectManager->create('Magento\\Backend\\Test\\Page\\Adminhtml\\StoreIndex'); $storeIndex->open(); $storeIndex->getStoreGrid()->searchAndOpen(['store_title' => $this->store->getName()]); $storeNew = $this->objectManager->create('Magento\\Backend\\Test\\Page\\Adminhtml\\StoreNew'); $storeNew->getFormPageActions()->delete(); $storeDelete = $this->objectManager->create('Magento\\Backend\\Test\\Page\\Adminhtml\\StoreDelete'); $storeDelete->getStoreForm()->fillForm(['create_backup' => 'No']); $storeDelete->getFormPageActions()->delete(); } $this->store = null; }
/** * Check if store is visible in scope dropdown * * @param Store $store * @return bool */ public function isStoreVisible($store) { $storeViews = $this->_rootElement->find($this->scopeSelector, Locator::SELECTOR_CSS, 'liselectstore')->getValues(); return in_array($store->getGroupId() . "/" . $store->getName(), $storeViews); }
/** * Run Delete Store Entity test * * @param Store $store * @param string $createBackup * @return void */ public function test(Store $store, $createBackup) { // Preconditions: $store->persist(); $this->backupIndex->open()->getBackupGrid()->massaction([], 'Delete', true, 'Select All'); // Steps: $this->storeIndex->open(); $this->storeIndex->getStoreGrid()->searchAndOpenStore($store); $this->editStore->getFormPageActions()->delete(); $this->storeDelete->getStoreForm()->fillForm(['create_backup' => $createBackup]); $this->storeDelete->getFormPageFooterActions()->delete(); }
/** * Assert that created Store View can be found in Stores grid by name * * @param StoreIndex $storeIndex * @param Store $store * @return void */ public function processAssert(StoreIndex $storeIndex, Store $store) { $storeName = $store->getName(); $storeIndex->open()->getStoreGrid()->search(['store_title' => $storeName]); \PHPUnit_Framework_Assert::assertTrue($storeIndex->getStoreGrid()->isStoreExists($storeName), 'Store \'' . $storeName . '\' is not present in grid.'); }
/** * Check if correspondent "Store" is present in "Store" swither or not. * * @param Store $store * @return bool */ public function isStoreGroupVisible(Store $store) { $storeGroupName = explode("/", $store->getGroupId())[1]; $this->_rootElement->find($this->storeGroupSwitch)->click(); return $this->_rootElement->find(sprintf($this->storeGroupSelector, $storeGroupName), Locator::SELECTOR_XPATH)->isVisible(); }
/** * Search and open appropriate Store View. * * @param Store $store * @return void */ public function searchAndOpenStore(Store $store) { $storeName = $store->getName(); $this->search(['store_title' => $storeName]); $this->_rootElement->find(sprintf($this->storeName, $storeName), Locator::SELECTOR_XPATH)->click(); }
/** * Update Custom System Variable Entity test * * @param SystemVariable $customVariable * @param SystemVariable $customVariableOrigin * @param Store $storeOrigin * @param $saveAction * @return void */ public function test(SystemVariable $customVariable, SystemVariable $customVariableOrigin, Store $storeOrigin, $saveAction) { $filter = ['code' => $customVariableOrigin->getCode()]; // Steps $this->systemVariableIndexPage->open(); $this->systemVariableIndexPage->getSystemVariableGrid()->searchAndOpen($filter); $this->systemVariableNewPage->getFormPageActions()->selectStoreView($storeOrigin->getData('name')); $this->systemVariableNewPage->getSystemVariableForm()->fill($customVariable); $this->systemVariableNewPage->getFormPageActions()->{$saveAction}(); }