/**
  * 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.');
 }