/** * Assert that displayed target rule data on edit page equals passed from fixture. * * @param TargetRuleIndex $targetRuleIndex * @param TargetRule $targetRule * @param TargetRuleEdit $targetRuleEdit * @param array $replacementData * @return void */ public function processAssert(TargetRuleIndex $targetRuleIndex, TargetRule $targetRule, TargetRuleEdit $targetRuleEdit, array $replacementData) { $fixtureData = $this->prepareData($targetRule->getData(), $replacementData['rule_information']); $targetRuleIndex->open(); $targetRuleIndex->getTargetRuleGrid()->searchAndOpen(['name' => $targetRule->getName()]); $formData = $targetRuleEdit->getTargetRuleForm()->getData(); $errors = $this->verifyData($fixtureData, $formData); \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); }
/** * Prepare target rule data. * * @param TargetRule $targetRule * @return array */ protected function prepareData(TargetRule $targetRule) { $data = $this->replaceMappingData($targetRule->getData()); if (!isset($data['conditions_serialized'])) { $data['rule']['conditions'] = ''; } else { $data['rule']['conditions'] = $this->prepareCondition($data['conditions_serialized']); } unset($data['conditions_serialized']); if (!isset($data['actions_serialized'])) { $data['actions_serialized'] = ''; } $data['rule']['actions'] = $this->prepareCondition($data['actions_serialized']); unset($data['actions_serialized']); return $data; }