public function testGetBlock() { $blockName = 'block.name'; $block = $this->getMock('Magento\\Framework\\View\\Element\\BlockInterface'); $this->layout->expects($this->once())->method('getBlock')->with($blockName)->will($this->returnValue($block)); $this->assertEquals($block, $this->model->getBlock($blockName)); }
/** * Render price amount * * @param AmountInterface $amount * @param PriceInterface $price * @param SaleableInterface $saleableItem * @param array $arguments * @return string * @throws \RuntimeException */ public function renderAmount(AmountInterface $amount, PriceInterface $price, SaleableInterface $saleableItem = null, array $arguments = []) { $useArguments = array_replace($this->_data, $arguments); /** @var \Magento\Framework\Pricing\Render\RendererPool $rendererPool */ $rendererPool = $this->priceLayout->getBlock('render.product.prices'); if (!$rendererPool) { throw new \RuntimeException('Wrong Price Rendering layout configuration. Factory block is missed'); } // obtain concrete Amount Render $amountRender = $rendererPool->createAmountRender($amount, $saleableItem, $price, $useArguments); return $amountRender->toHtml(); }
/** * @expectedException \RuntimeException * @expectedExceptionMessage Wrong Price Rendering layout configuration. Factory block is missed */ public function testAmountRenderNoRenderPool() { $this->priceLayout->expects($this->once())->method('getBlock')->with('render.product.prices')->will($this->returnValue(false)); $this->model->renderAmount($this->amount, $this->price, $this->saleableItem); }