public function testGetAttributes() { $typeId = 1; $linkAttributes = ['link_type_id' => 1, 'product_link_attribute_code' => 1, 'data_type' => 'int', 'id' => 1]; $this->resource->expects($this->any())->method('getAttributesByType')->with($typeId)->will($this->returnValue($linkAttributes)); $this->model->setData('link_type_id', $typeId); $this->assertEquals($linkAttributes, $this->model->getAttributes()); }
public function testSaveProductRelations() { $data = [1]; $typeId = 1; $this->model->setData('link_type_id', $typeId); $product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['getRelatedLinkData', 'getUpSellLinkData', 'getCrossSellLinkData', '__wakeup'])->getMock(); $product->expects($this->any())->method('getRelatedLinkData')->will($this->returnValue($data)); $product->expects($this->any())->method('getUpSellLinkData')->will($this->returnValue($data)); $product->expects($this->any())->method('getCrossSellLinkData')->will($this->returnValue($data)); $map = [[$product, $data, Link::LINK_TYPE_RELATED, $this->resource], [$product, $data, Link::LINK_TYPE_UPSELL, $this->resource], [$product, $data, Link::LINK_TYPE_CROSSSELL, $this->resource]]; $this->resource->expects($this->any())->method('saveProductLinks')->will($this->returnValueMap($map)); $this->model->saveProductRelations($product); }
/** * {@inheritdoc} */ public function setData($key, $value = null) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'setData'); if (!$pluginInfo) { return parent::setData($key, $value); } else { return $this->___callPlugins('setData', func_get_args(), $pluginInfo); } }