Example #1
0
 /**
  * Test for method addNewItemXmlCallback
  */
 public function testAddNewItemXmlCallback()
 {
     $priceHtmlForTest = '<div class="price">Price is 10 for example</div>';
     $productMock = $this->getMock('Magento\\Catalog\\Model\\Product', ['getProductUrl', 'getDescription', 'getAllowedInRss', 'getName', '__wakeup'], [], '', false);
     $rssObjMock = $this->getMock('Magento\\Rss\\Model\\Rss', [], [], '', false);
     $layoutMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\LayoutInterface', [], '', true, true, true, ['getBlock']);
     $priceRendererMock = $this->getMock('Magento\\Framework\\Pricing\\Render', ['render'], [], '', false);
     $productTitle = 'Product title';
     $productUrl = '<a href="http://product.url">Product Url</a>';
     $imgThumbSrc = 'http://source-for-thumbnail';
     $productDescription = 'Product description';
     $description = '<table><tr><td><a href="' . $productUrl . '"><img src="' . $imgThumbSrc . '" border="0" align="left" height="75" width="75"></a></td><td  style="text-decoration:none;">' . $productDescription . $priceHtmlForTest . '</td></tr></table>';
     $productMock->expects($this->exactly(2))->method('getProductUrl')->will($this->returnValue($productUrl));
     $productMock->expects($this->once())->method('getDescription')->will($this->returnValue($productDescription));
     $productMock->expects($this->any())->method('getAllowedInRss')->will($this->returnValue(true));
     $productMock->expects($this->once())->method('getName')->will($this->returnValue($productTitle));
     $this->imageHelperMock->expects($this->once())->method('init')->will($this->returnSelf());
     $this->imageHelperMock->expects($this->once())->method('resize')->will($this->returnValue($imgThumbSrc));
     $layoutMock->expects($this->once())->method('getBlock')->will($this->returnValue($priceRendererMock));
     $priceRendererMock->expects($this->once())->method('render')->will($this->returnValue($priceHtmlForTest));
     $expectedData = ['title' => $productTitle, 'link' => $productUrl, 'description' => $description];
     $rssObjMock->expects($this->once())->method('_addEntry')->with($expectedData)->will($this->returnSelf());
     $args = ['product' => $productMock, 'rssObj' => $rssObjMock];
     $this->block->setLayout($layoutMock);
     $this->assertNull($this->block->addNewItemXmlCallback($args));
 }