/** * @dataProvider saveDataProvider * @param \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product * @param array $data * @param array $modelData */ public function testSave($product, array $data, array $modelData) { $link = $this->createLinkkModel($product, $modelData, true); $this->linkFactory->expects($this->once())->method('create')->will($this->returnValue($link)); $product->expects($this->once())->method('setIsCustomOptionChanged')->will($this->returnSelf()); $this->target->save($product, $data); }
/** * @return Link */ private function getComponent() { if (!$this->component) { $this->component = $this->componentFactory->create(); } return $this->component; }
/** * {@inheritdoc} */ public function delete($id) { /** @var $link \Magento\Downloadable\Model\Link */ $link = $this->linkFactory->create()->load($id); if (!$link->getId()) { throw new NoSuchEntityException(__('There is no downloadable link with provided ID.')); } $link->delete(); return true; }
/** * {@inheritdoc} */ public function delete($id) { /** @var $link \Magento\Downloadable\Model\Link */ $link = $this->linkFactory->create()->load($id); if (!$link->getId()) { throw new NoSuchEntityException(__('There is no downloadable link with provided ID.')); } try { $link->delete(); } catch (\Exception $exception) { throw new StateException(__('Cannot delete link with id %1', $link->getId()), $exception); } return true; }
/** * @return \Magento\Downloadable\Model\Link */ protected function _createLink() { return $this->_linkFactory->create(); }