/** * @param array $setData * @param string $attributeObjectFrontendInput * @param array $attrObjectSourceAllOptionsValue * @param array $attrSetCollectionOptionsArray * @param bool $expectedAttrObjSourceAllOptionsParam * @param array $expectedValueSelectOptions * @param array $expectedValueOption * @dataProvider prepareValueOptionsDataProvider * @SuppressWarnings(PHPMD.NPathComplexity) */ public function testPrepareValueOptions($setData, $attributeObjectFrontendInput, $attrObjectSourceAllOptionsValue, $attrSetCollectionOptionsArray, $expectedAttrObjSourceAllOptionsParam, $expectedValueSelectOptions, $expectedValueOption) { foreach ($setData as $key => $value) { $this->_condition->setData($key, $value); } $attrObjectSourceMock = $this->getMockBuilder('Magento\\Eav\\Model\\Entity\\Attribute\\Source\\AbstractSource')->setMethods(['getAllOptions'])->disableOriginalConstructor()->getMock(); $attrObjectSourceMock->expects(is_null($expectedAttrObjSourceAllOptionsParam) ? $this->never() : $this->once())->method('getAllOptions')->with($expectedAttrObjSourceAllOptionsParam)->willReturn($attrObjectSourceAllOptionsValue); $attributeObjectMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Resource\\Eav\\Attribute')->setMethods(['usesSource', 'getFrontendInput', 'getSource', 'getAllOptions'])->disableOriginalConstructor()->getMock(); $attributeObjectMock->method('usesSource')->willReturn(true); $attributeObjectMock->expects(is_null($attributeObjectFrontendInput) ? $this->never() : $this->once())->method('getFrontendInput')->willReturn($attributeObjectFrontendInput); $attributeObjectMock->method('getSource')->willReturn($attrObjectSourceMock); $entityTypeMock = $this->getMockBuilder('Magento\\Framework\\Model\\AbstractModel\\Type')->setMethods(['getId'])->disableOriginalConstructor()->getMock(); $entityTypeMock->method('getId')->willReturn('SomeEntityType'); $configValueMock = $this->getMock('Magento\\Eav\\Model\\Config', ['getAttribute', 'getEntityType'], [], '', false); $configValueMock->method('getAttribute')->willReturn($attributeObjectMock); $configValueMock->method('getEntityType')->willReturn($entityTypeMock); $configProperty = new ReflectionProperty('Magento\\Rule\\Model\\Condition\\Product\\AbstractProduct', '_config'); $configProperty->setAccessible(true); $configProperty->setValue($this->_condition, $configValueMock); $attrSetCollectionValueMock = $this->getMockBuilder('Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\Collection')->setMethods(['setEntityTypeFilter', 'load', 'toOptionArray'])->disableOriginalConstructor()->getMock(); $attrSetCollectionValueMock->method('setEntityTypeFilter')->will($this->returnSelf()); $attrSetCollectionValueMock->method('load')->will($this->returnSelf()); $attrSetCollectionValueMock->expects(is_null($attrSetCollectionOptionsArray) ? $this->never() : $this->once())->method('toOptionArray')->willReturn($attrSetCollectionOptionsArray); $attrSetCollectionProperty = new ReflectionProperty('Magento\\Rule\\Model\\Condition\\Product\\AbstractProduct', '_attrSetCollection'); $attrSetCollectionProperty->setAccessible(true); $attrSetCollectionProperty->setValue($this->_condition, $attrSetCollectionValueMock); $testedMethod = new ReflectionMethod('Magento\\Rule\\Model\\Condition\\Product\\AbstractProduct', '_prepareValueOptions'); $testedMethod->setAccessible(true); $testedMethod->invoke($this->_condition); $this->assertEquals($expectedValueSelectOptions, $this->_condition->getData('value_select_options')); $this->assertEquals($expectedValueOption, $this->_condition->getData('value_option')); }
public function __construct($data) { parent::__construct($data); if (isset($data['longitude'])) { $this->longitude = $data['longitude']; } if (isset($data['height'])) { $this->height = $data['height']; } if (isset($data['diameter'])) { $this->diameter = $data['diameter']; } }
/** * Initilizate AbstractProduct by order xml. * @param SimpleXmlElement $orderProduct * @param AbstractProduct $inventory * @param CmlSalesOrder $salesOrder * @return AbstractProduct */ private function initilizateOrderInventory($orderProduct, $inventory, $salesOrder) { $name = $this->getMandatoryChildContent($orderProduct, 'Наименование', 'Not product name in order! Order number - ' . $salesOrder->getNumber()); $oneEsIdentifier = $this->getMandatoryChildContent($orderProduct, 'Ид', 'Not product identificator in order. Order number - ' . $salesOrder->getNumber()); $price = $this->getMandatoryChildContent($orderProduct, 'ЦенаЗаЕдиницу', 'Not product price in order. Order number - ' . $salesOrder->getNumber()); $count = $this->getMandatoryChildContent($orderProduct, 'Количество', 'Not product count in order. Order number - ' . $salesOrder->getNumber()); $unitName = $this->getChildContent($orderProduct, 'БазоваяЕдиница'); $article = $this->getChildContent($orderProduct, 'Артикул'); $NDS = $this->getTaxRate($orderProduct); $name = $this->filter($name); $article = $this->filter($article); $inventory->orderInitilizate($oneEsIdentifier, $name, $article, $unitName, $price, $count, $NDS); return $inventory; }
/** * Update exists product * @param AbstractProduct $abstractProduct * @param String $reference */ private function updateInventory($abstractProduct, $reference) { $reference = $this->update($abstractProduct->toRestDescription(), $reference); $this->setTax($abstractProduct, $reference); return $reference; }
public function testGetMappedSqlField() { $this->_condition->setAttribute('category_ids'); $this->assertEquals('e.entity_id', $this->_condition->getMappedSqlField()); }
/** * Add inventory to catalog in CRM. * @param String $catalogReference * @param String $productReference * @param AbstractProduct $abstractProduct */ private function addInventory($catalogReference, $inventoryReference, $abstractProduct) { $price = $abstractProduct->getPrice(); $currencyReference = $this->getCurrencyReference($abstractProduct->getCurrency()); $currency = $this->trimReference($currencyReference); $catalogId = $this->trimReference($catalogReference); $inventoryId = $this->trimReference($inventoryReference); $this->insertInventoryToCatalog($catalogId, $inventoryId, $price, $currency); }