/** * Delete Catalog Rule on backend * * @return array */ public function run() { $this->catalogRuleIndex->open(); while ($this->catalogRuleIndex->getCatalogRuleGrid()->isFirstRowVisible()) { $this->catalogRuleIndex->getCatalogRuleGrid()->openFirstRow(); $this->catalogRuleNew->getFormPageActions()->delete(); } }
/** * Clear data after test * * @return void */ public function tearDown() { foreach ($this->catalogRules as $catalogRule) { $filter = ['name' => $catalogRule->getName()]; $this->catalogRuleIndex->open(); $this->catalogRuleIndex->getCatalogRuleGrid()->searchAndOpen($filter); $this->catalogRuleNew->getFormPageActions()->delete(); } $this->catalogRules = []; }
/** * Delete Catalog Rule on backend * * @return array */ public function run() { $this->catalogRuleIndex->open(); $this->catalogRuleIndex->getCatalogRuleGrid()->resetFilter(); while ($this->catalogRuleIndex->getCatalogRuleGrid()->isFirstRowVisible()) { $this->catalogRuleIndex->getCatalogRuleGrid()->openFirstRow(); $this->catalogRuleNew->getFormPageActions()->delete(); $this->catalogRuleIndex->getSystemMessageDialog()->closePopup(); } }
/** * Delete Catalog Price Rule test * * @param CatalogRule $catalogPriceRule * @return void */ public function testDeleteCatalogPriceRule(CatalogRule $catalogPriceRule) { // Precondition $catalogPriceRule->persist(); $filter = ['name' => $catalogPriceRule->getName(), 'rule_id' => $catalogPriceRule->getId()]; // Steps $this->catalogRuleIndex->open(); $this->catalogRuleIndex->getCatalogRuleGrid()->searchAndOpen($filter); $this->catalogRuleNew->getFormPageActions()->delete(); }
/** * Assert that product attribute can be used on promo rules conditions. * * @param CatalogRuleIndex $catalogRuleIndex * @param CatalogRuleNew $catalogRuleNew * @param CatalogProductAttribute $attribute * @return void */ public function processAssert(CatalogRuleIndex $catalogRuleIndex, CatalogRuleNew $catalogRuleNew, CatalogProductAttribute $attribute) { $catalogRuleIndex->open(); $catalogRuleIndex->getGridPageActions()->addNew(); $catalogRuleNew->getEditForm()->openTab('conditions'); \PHPUnit_Framework_Assert::assertTrue($catalogRuleNew->getEditForm()->isAttributeInConditions($attribute->getFrontendLabel()), 'Product attribute can\'t be used on promo rules conditions.'); }
/** * Assert that product attribute can be used on promo rules conditions. * * @param CatalogRuleIndex $catalogRuleIndex * @param CatalogRuleNew $catalogRuleNew * @param CatalogProductAttribute $attribute * @return void */ public function processAssert(CatalogRuleIndex $catalogRuleIndex, CatalogRuleNew $catalogRuleNew, CatalogProductAttribute $attribute) { $catalogRuleIndex->open(); $catalogRuleIndex->getGridPageActions()->addNew(); $catalogRuleNew->getEditForm()->openSection('conditions'); /** @var Conditions $conditionsSection */ $conditionsSection = $catalogRuleNew->getEditForm()->getSection('conditions'); \PHPUnit_Framework_Assert::assertTrue($conditionsSection->isAttributeInConditions($attribute), 'Product attribute can\'t be used on promo rules conditions.'); }
/** * Assert that customer group find on catalog price rule page. * * @param CatalogRuleIndex $catalogRuleIndex * @param CatalogRuleNew $catalogRuleNew * @param CustomerGroup $customerGroup * @return void */ public function processAssert(CatalogRuleIndex $catalogRuleIndex, CatalogRuleNew $catalogRuleNew, CustomerGroup $customerGroup) { $catalogRuleIndex->open(); $catalogRuleIndex->getGridPageActions()->addNew(); $catalogRuleNew->getEditForm()->openTab('rule_information'); /** @var RuleInformation $ruleInformationTab */ $ruleInformationTab = $catalogRuleNew->getEditForm()->getTab('rule_information'); \PHPUnit_Framework_Assert::assertTrue($ruleInformationTab->isVisibleCustomerGroup($customerGroup), "Customer group {$customerGroup->getCustomerGroupCode()} not in catalog price rule page."); }
/** * Assert that displayed Catalog Price Rule data on edit page equals passed from fixture. * * @param CatalogRule $catalogPriceRule * @param CatalogRuleIndex $pageCatalogRuleIndex * @param CatalogRuleNew $pageCatalogRuleNew * @param CatalogRule $catalogPriceRuleOriginal * @return void */ public function processAssert(CatalogRule $catalogPriceRule, CatalogRuleIndex $pageCatalogRuleIndex, CatalogRuleNew $pageCatalogRuleNew, CatalogRule $catalogPriceRuleOriginal = null) { $data = $catalogPriceRuleOriginal === null ? $catalogPriceRule->getData() : array_merge($catalogPriceRuleOriginal->getData(), $catalogPriceRule->getData()); $filter['name'] = $data['name']; $pageCatalogRuleIndex->open(); $pageCatalogRuleIndex->getCatalogRuleGrid()->searchAndOpen($filter); $formData = $pageCatalogRuleNew->getEditForm()->getData($catalogPriceRule); $fixtureData = $catalogPriceRule->getData(); //convert discount_amount to float to compare if (isset($formData['discount_amount'])) { $formData['discount_amount'] = floatval($formData['discount_amount']); } if (isset($fixtureData['discount_amount'])) { $fixtureData['discount_amount'] = floatval($fixtureData['discount_amount']); } $diff = $this->verifyData($formData, $fixtureData); \PHPUnit_Framework_Assert::assertTrue(empty($diff), implode(' ', $diff)); }
/** * Assert that data in grid on Catalog Price Rules page according to fixture * * @param CatalogRule $catalogPriceRule * @param CatalogRuleIndex $pageCatalogRuleIndex * @param CatalogRule $catalogPriceRuleOriginal * @return void */ public function processAssert(CatalogRule $catalogPriceRule, CatalogRuleIndex $pageCatalogRuleIndex, CatalogRule $catalogPriceRuleOriginal = null) { $data = $catalogPriceRuleOriginal === null ? $catalogPriceRule->getData() : array_merge($catalogPriceRuleOriginal->getData(), $catalogPriceRule->getData()); $filter = ['name' => $data['name'], 'is_active' => $data['is_active']]; //add ruleWebsite to filter if there is one if ($catalogPriceRule->getWebsiteIds() != null) { $ruleWebsite = $catalogPriceRule->getWebsiteIds(); $ruleWebsite = is_array($ruleWebsite) ? reset($ruleWebsite) : $ruleWebsite; $filter['rule_website'] = $ruleWebsite; } //add from_date & to_date to filter if there are ones if (isset($data['from_date']) && isset($data['to_date'])) { $dateArray['from_date'] = date("M j, Y", strtotime($catalogPriceRule->getFromDate())); $dateArray['to_date'] = date("M j, Y", strtotime($catalogPriceRule->getToDate())); $filter = array_merge($filter, $dateArray); } $pageCatalogRuleIndex->open(); $errorMessage = implode(', ', $filter); \PHPUnit_Framework_Assert::assertTrue($pageCatalogRuleIndex->getCatalogRuleGrid()->isRowVisible($filter), 'Catalog Price Rule with following data: \'' . $errorMessage . '\' ' . 'is absent in Catalog Price Rule grid.'); }
/** * Assert that Catalog Price Rule is not presented in grid and cannot be found using ID, Rule name * * @param CatalogRule $catalogPriceRule * @param CatalogRuleIndex $pageCatalogRuleIndex * @return void */ public function processAssert(CatalogRule $catalogPriceRule, CatalogRuleIndex $pageCatalogRuleIndex) { $filter = ['rule_id' => $catalogPriceRule->getId(), 'name' => $catalogPriceRule->getName()]; $pageCatalogRuleIndex->open(); \PHPUnit_Framework_Assert::assertFalse($pageCatalogRuleIndex->getCatalogRuleGrid()->isRowVisible($filter), 'Catalog Price Rule \'' . $filter['rule_id'] . '\', ' . 'with name \'' . $filter['name'] . '\', ' . 'is present in Catalog Price Rule grid.'); }