示例#1
0
 public function testDataModelToArray()
 {
     $array = ['type' => 'conditionType', 'value' => 'value', 'attribute' => 'getAttributeName', 'operator' => 'getOperator', 'aggregator' => 'getAggregatorType', 'conditions' => [['type' => null, 'value' => null, 'attribute' => null, 'operator' => null], ['type' => null, 'value' => null, 'attribute' => null, 'operator' => null]]];
     /**
      * @var \Magento\SalesRule\Model\Data\Condition $dataCondition
      */
     $dataCondition = $this->getMockBuilder('\\Magento\\SalesRule\\Model\\Data\\Condition')->disableOriginalConstructor()->setMethods(['create', 'load', 'getConditionType', 'getValue', 'getAttributeName', 'getOperator', 'getAggregatorType', 'getConditions'])->getMock();
     $dataCondition->expects($this->atLeastOnce())->method('getConditionType')->willReturn('conditionType');
     $dataCondition->expects($this->atLeastOnce())->method('getValue')->willReturn('value');
     $dataCondition->expects($this->atLeastOnce())->method('getAttributeName')->willReturn('getAttributeName');
     $dataCondition->expects($this->atLeastOnce())->method('getOperator')->willReturn('getOperator');
     $dataCondition->expects($this->atLeastOnce())->method('getAggregatorType')->willReturn('getAggregatorType');
     $dataCondition1 = $this->getMockBuilder('\\Magento\\SalesRule\\Model\\Data\\Condition')->disableOriginalConstructor()->setMethods(['create', 'load', 'getConditionType', 'getValue', 'getAttributeName', 'getOperator', 'getAggregatorType', 'getConditions'])->getMock();
     $dataCondition2 = $this->getMockBuilder('\\Magento\\SalesRule\\Model\\Data\\Condition')->disableOriginalConstructor()->setMethods(['create', 'load', 'getConditionType', 'getValue', 'getAttributeName', 'getOperator', 'getAggregatorType', 'getConditions'])->getMock();
     $dataCondition->expects($this->atLeastOnce())->method('getConditions')->willReturn([$dataCondition1, $dataCondition2]);
     $result = $this->model->dataModelToArray($dataCondition);
     $this->assertEquals($array, $result);
 }