/** * @return null|string */ public function getLinksTitle() { if ($this->_purchased->getLinkSectionTitle()) { return $this->_purchased->getLinkSectionTitle(); } return $this->_scopeConfig->getValue(\Magento\Downloadable\Model\Link::XML_PATH_LINKS_TITLE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); }
/** * Enter description here... * * @return Purchased */ public function getLinks() { $this->_purchased = $this->_purchasedFactory->create()->load($this->getItem()->getId(), 'order_item_id'); $purchasedLinks = $this->_itemsFactory->create()->addFieldToFilter('order_item_id', $this->getItem()->getId()); $this->_purchased->setPurchasedItems($purchasedLinks); return $this->_purchased; }
public function testGetLinkForWrongCustomer() { $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(false); $this->session->expects($this->once())->method('getCustomerId')->willReturn('customer_id'); $this->objectManager->expects($this->at(3))->method('create')->with('Magento\\Downloadable\\Model\\Link\\Purchased')->willReturn($this->linkPurchased); $this->linkPurchasedItem->expects($this->once())->method('getPurchasedId')->willReturn('purchased_id'); $this->linkPurchased->expects($this->once())->method('load')->with('purchased_id')->willReturnSelf(); $this->linkPurchased->expects($this->once())->method('getCustomerId')->willReturn('other_customer_id'); $this->messageManager->expects($this->once())->method('addNotice')->with("We can't find the link you requested."); $this->redirect->expects($this->once())->method('redirect')->with($this->response, '*/customer/products', []); $this->assertEquals($this->response, $this->link->execute()); }