/**
  * 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);
 }
 /**
  * Run update TargetRule entity test.
  *
  * @param CatalogProductSimple $product
  * @param CatalogProductSimple $promotedProduct
  * @param TargetRule $initialTargetRule
  * @param TargetRule $targetRule
  * @param CustomerSegment|null $customerSegment
  * @return array
  */
 public function test(CatalogProductSimple $product, CatalogProductSimple $promotedProduct, TargetRule $initialTargetRule, TargetRule $targetRule, CustomerSegment $customerSegment = null)
 {
     // Preconditions:
     $this->defaultPreconditions($product, $promotedProduct, $customerSegment);
     $initialTargetRule->persist();
     $replacementData = $this->getReplaceData($product, $promotedProduct, $customerSegment);
     // Steps
     $filter = ['name' => $initialTargetRule->getName()];
     $this->targetRuleIndex->open();
     $this->targetRuleIndex->getTargetRuleGrid()->searchAndOpen($filter);
     $this->targetRuleEdit->getTargetRuleForm()->fillForm($targetRule, $replacementData);
     $this->targetRuleEdit->getPageActions()->save();
     // Prepare data for tear down
     $this->targetRule = $targetRule;
     return ['promotedProducts' => [$promotedProduct], 'replacementData' => $replacementData];
 }
示例#3
0
 /**
  * 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;
 }
 /**
  * Clear data after test.
  *
  * @return void
  */
 public function tearDown()
 {
     if (!$this->targetRule instanceof TargetRule) {
         return;
     }
     $this->targetRuleIndex->open();
     $this->targetRuleIndex->getTargetRuleGrid()->searchAndOpen(['name' => $this->targetRule->getName()]);
     $this->targetRuleEdit->getPageActions()->deleteAndAcceptAlert();
 }