/**
  * Delete all sales rules on backend.
  *
  * @return array
  */
 public function run()
 {
     $this->promoQuoteIndex->open();
     $this->promoQuoteIndex->getPromoQuoteGrid()->resetFilter();
     while ($this->promoQuoteIndex->getPromoQuoteGrid()->isFirstRowVisible()) {
         $this->promoQuoteIndex->getPromoQuoteGrid()->openFirstRow();
         $this->promoQuoteEdit->getFormPageActions()->delete();
     }
 }
 /**
  * Delete Sales Rule Entity test.
  *
  * @param SalesRule $salesRule
  * @return void
  */
 public function test(SalesRule $salesRule)
 {
     // Preconditions:
     $salesRule->persist();
     // Steps:
     $this->promoQuoteIndex->open();
     $this->promoQuoteIndex->getPromoQuoteGrid()->searchAndOpen(['name' => $salesRule->getName()]);
     $this->promoQuoteEdit->getFormPageActions()->delete();
 }
 /**
  * Assert that displayed sales rule data on edit page equals passed from fixture.
  *
  * @param PromoQuoteIndex $promoQuoteIndex
  * @param PromoQuoteEdit $promoQuoteEdit
  * @param SalesRule $salesRule
  * @return void
  */
 public function processAssert(PromoQuoteIndex $promoQuoteIndex, PromoQuoteEdit $promoQuoteEdit, SalesRule $salesRule)
 {
     $promoQuoteIndex->open();
     $promoQuoteIndex->getPromoQuoteGrid()->searchAndOpen(['name' => $salesRule->getName()]);
     $formData = $promoQuoteEdit->getSalesRuleForm()->getData();
     $errors = $this->verifyData($salesRule->getData(), $formData);
     \PHPUnit_Framework_Assert::assertEmpty($errors, $errors);
 }
 /**
  * Delete sales rule.
  *
  * @return void
  */
 public function tearDown()
 {
     if ($this->salesRuleName !== null) {
         $this->promoQuoteIndex->open();
         $this->promoQuoteIndex->getPromoQuoteGrid()->searchAndOpen(['name' => $this->salesRuleName]);
         $this->promoQuoteEdit->getFormPageActions()->delete();
         $this->salesRuleName = null;
     }
 }
 /**
  * Deleting cart price rule.
  *
  * @return void
  */
 public function tearDown()
 {
     if (!$this->salesRule instanceof SalesRule) {
         return;
     }
     $this->promoQuoteIndex->open();
     $this->promoQuoteIndex->getPromoQuoteGrid()->searchAndOpen(['name' => $this->salesRule->getName()]);
     $this->promoQuoteEdit->getFormPageActions()->delete();
 }
 /**
  * Delete sales rule, catalog rule, all tax rules and setup default tax configuration.
  *
  * @return void
  */
 public function tearDown()
 {
     if (isset($this->salesRule)) {
         $this->promoQuoteIndex->open();
         $this->promoQuoteIndex->getPromoQuoteGrid()->searchAndOpen(['name' => $this->salesRule->getName()]);
         $this->promoQuoteEdit->getFormPageActions()->delete();
         $this->salesRule = null;
     }
     if (isset($this->catalogRule)) {
         $this->catalogRuleIndex->open();
         $this->catalogRuleIndex->getCatalogRuleGrid()->searchAndOpen(['name' => $this->catalogRule->getName()]);
         $this->catalogRuleEdit->getFormPageActions()->delete();
         $this->catalogRule = null;
     }
     $this->objectManager->create('Mage\\Tax\\Test\\TestStep\\DeleteAllTaxRulesStep')->run();
 }
 /**
  * Delete sales rule, catalog rule, all tax rules and setup default tax configuration.
  *
  * @return void
  */
 public function tearDown()
 {
     if (isset($this->salesRule)) {
         $this->promoQuoteIndex->open();
         $this->promoQuoteIndex->getPromoQuoteGrid()->searchAndOpen(['name' => $this->salesRule->getName()]);
         $this->promoQuoteEdit->getFormPageActions()->delete();
         $this->salesRule = null;
     }
     if (isset($this->catalogRule)) {
         $this->catalogRuleIndex->open();
         $this->catalogRuleIndex->getCatalogRuleGrid()->searchAndOpen(['name' => $this->catalogRule->getName()]);
         $this->catalogRuleEdit->getFormPageActions()->delete();
         $this->catalogRule = null;
     }
     $this->objectManager->create('Mage\\Tax\\Test\\TestStep\\DeleteAllTaxRulesStep')->run();
     // TODO: Move set default configuration and create default tax rule to "tearDownAfterClass" method after fix bug MAGETWO-29331
     $this->objectManager->create('Mage\\Core\\Test\\TestStep\\SetupConfigurationStep', ['configData' => 'default_tax_configuration'])->run();
     $this->objectManager->create('\\Mage\\Tax\\Test\\TestStep\\CreateTaxRuleStep', ['taxRule' => 'default'])->run();
 }
 /**
  * Assert that sales rule is not present in cart price rules grid.
  *
  * @param PromoQuoteIndex $promoQuoteIndex
  * @param SalesRule $salesRule
  * @return void
  */
 public function processAssert(PromoQuoteIndex $promoQuoteIndex, SalesRule $salesRule)
 {
     $promoQuoteIndex->open();
     \PHPUnit_Framework_Assert::assertFalse($promoQuoteIndex->getPromoQuoteGrid()->isRowVisible(['name' => $salesRule->getName()]), "Sales rule {$salesRule->getName()} is present in cart price rules grid.");
 }