/** * Check is link shareable or not * * @param \Magento\Downloadable\Model\Link|Item $link * @return bool */ public function getIsShareable($link) { $shareable = false; switch ($link->getIsShareable()) { case \Magento\Downloadable\Model\Link::LINK_SHAREABLE_YES: case \Magento\Downloadable\Model\Link::LINK_SHAREABLE_NO: $shareable = (bool) $link->getIsShareable(); break; case \Magento\Downloadable\Model\Link::LINK_SHAREABLE_CONFIG: $shareable = (bool) $this->_scopeConfig->isSetFlag(\Magento\Downloadable\Model\Link::XML_PATH_CONFIG_IS_SHAREABLE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); } return $shareable; }
/** * @param string $messageType * @param string $status * @param string $notice * @dataProvider linkNotAvailableDataProvider */ public function testLinkNotAvailable($messageType, $status, $notice) { $this->objectManager->expects($this->at(0))->method('get')->with('Magento\\Customer\\Model\\Session')->willReturn($this->session); $this->request->expects($this->once())->method('getParam')->with('id', 0)->willReturn('some_id'); $this->objectManager->expects($this->at(1))->method('create')->with('Magento\\Downloadable\\Model\\Link\\Purchased\\Item')->willReturn($this->linkPurchasedItem); $this->linkPurchasedItem->expects($this->once())->method('load')->with('some_id', 'link_hash')->willReturnSelf(); $this->linkPurchasedItem->expects($this->once())->method('getId')->willReturn(5); $this->objectManager->expects($this->at(2))->method('get')->with('Magento\\Downloadable\\Helper\\Data')->willReturn($this->helperData); $this->helperData->expects($this->once())->method('getIsShareable')->with($this->linkPurchasedItem)->willReturn(true); $this->linkPurchasedItem->expects($this->any())->method('getNumberOfDownloadsBought')->willReturn(10); $this->linkPurchasedItem->expects($this->any())->method('getNumberOfDownloadsUsed')->willReturn(9); $this->linkPurchasedItem->expects($this->once())->method('getStatus')->willReturn($status); $this->messageManager->expects($this->once())->method($messageType)->with($notice)->willReturnSelf(); $this->assertEquals($this->response, $this->link->execute()); }
/** * @param Item $item * @return string */ public function getPurchasedLinkUrl($item) { return $this->_urlBuilder->getUrl('downloadable/download/link', array('id' => $item->getLinkHash(), '_scope' => $this->getOrder()->getStore(), '_secure' => true, '_nosid' => true)); }
/** * Return url to download link * * @param Item $item * @return string */ public function getDownloadUrl($item) { return $this->getUrl('downloadable/download/link', ['id' => $item->getLinkHash(), '_secure' => true]); }
/** * Return url to download link * * @param Item $item * @return string */ public function getDownloadUrl($item) { return $this->getUrl('*/download/link', array('id' => $item->getLinkHash(), '_secure' => true)); }
/** * @param Item $item * @return string */ public function getPurchasedLinkUrl($item) { $url = $this->getFrontendUrlBuilder()->getUrl('downloadable/download/link', ['id' => $item->getLinkHash(), '_scope' => $this->getOrder()->getStore(), '_secure' => true, '_nosid' => true]); return $url; }