Exemplo n.º 1
0
 public function testArrayToDataModel()
 {
     $array = ['type' => 'type', 'attribute' => 'attr', 'operator' => 'operator', 'value' => 'value', 'is_value_parsed' => true, 'aggregator' => 'all', 'conditions' => [['type' => 'child-type', 'attribute' => 'child-attr', 'operator' => 'child-operator', 'value' => 'child-value', 'is_value_parsed' => false, 'aggregator' => 'any']]];
     $conditionMock = $this->getMock('\\Magento\\CatalogRule\\Api\\Data\\ConditionInterface');
     $conditionChildMock = $this->getMock('\\Magento\\CatalogRule\\Api\\Data\\ConditionInterface');
     $this->conditionFactoryMock->expects($this->at(0))->method('create')->willReturn($conditionMock);
     $this->conditionFactoryMock->expects($this->at(1))->method('create')->willReturn($conditionChildMock);
     $conditionMock->expects($this->once())->method('setType')->with('type')->willReturnSelf();
     $conditionMock->expects($this->once())->method('setAggregator')->with('all')->willReturnSelf();
     $conditionMock->expects($this->once())->method('setAttribute')->with('attr')->willReturnSelf();
     $conditionMock->expects($this->once())->method('setOperator')->with('operator')->willReturnSelf();
     $conditionMock->expects($this->once())->method('setIsValueParsed')->with(true)->willReturnSelf();
     $conditionMock->expects($this->once())->method('setConditions')->with([$conditionChildMock])->willReturnSelf();
     $conditionChildMock->expects($this->once())->method('setType')->with('child-type')->willReturnSelf();
     $conditionChildMock->expects($this->once())->method('setAggregator')->with('any')->willReturnSelf();
     $conditionChildMock->expects($this->once())->method('setAttribute')->with('child-attr')->willReturnSelf();
     $conditionChildMock->expects($this->once())->method('setOperator')->with('child-operator')->willReturnSelf();
     $conditionChildMock->expects($this->once())->method('setIsValueParsed')->with(false)->willReturnSelf();
     $this->assertEquals($conditionMock, $this->model->arrayToDataModel($array));
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function setRuleCondition($condition)
 {
     $this->getConditions()->setConditions([])->loadArray($this->ruleConditionConverter->dataModelToArray($condition));
     return $this;
 }