public function testGetLinkPrice() { $linkPriceMock = $this->getMock('Magento\\Downloadable\\Pricing\\Price\\LinkPrice', [], [], '', false); $amountMock = $this->getMock('Magento\\Framework\\Pricing\\Amount\\Base', [], [], '', false); $linkMock = $this->getMock('Magento\\Downloadable\\Model\\Link', [], [], '', false); $priceCode = 'link_price'; $arguments = []; $expectedHtml = 'some html'; $this->productMock->expects($this->any())->method('getPriceInfo')->will($this->returnValue($this->priceInfoMock)); $this->priceInfoMock->expects($this->any())->method('getPrice')->with($this->equalTo($priceCode))->will($this->returnValue($linkPriceMock)); $linkPriceMock->expects($this->any())->method('getLinkAmount')->with($linkMock)->will($this->returnValue($amountMock)); $priceBoxMock = $this->getMock('Magento\\Framework\\Pricing\\Render', ['renderAmount'], [], '', false, false); $this->layout->expects($this->once())->method('getBlock')->with($this->equalTo('product.price.render.default'))->will($this->returnValue($priceBoxMock)); $priceBoxMock->expects($this->once())->method('renderAmount')->with($amountMock, $linkPriceMock, $this->productMock, $arguments)->will($this->returnValue($expectedHtml)); $result = $this->linksBlock->getLinkPrice($linkMock); $this->assertEquals($expectedHtml, $result); }
/** * {@inheritdoc} */ public function getLinkPrice(\Magento\Downloadable\Model\Link $link) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getLinkPrice'); if (!$pluginInfo) { return parent::getLinkPrice($link); } else { return $this->___callPlugins('getLinkPrice', func_get_args(), $pluginInfo); } }