Example #1
0
 /**
  * Test for method _toHtml for the case, when wishlist is absent
  */
 public function testToHtmlWithoutWishlist()
 {
     $url = 'http://base.url/index';
     $rssString = '<xml>Some empty xml</xml>';
     $rssObjMock = $this->getMock('Magento\\Rss\\Model\\Rss', [], [], '', false);
     $customerServiceMock = $this->getMock('Magento\\Customer\\Service\\V1\\Data\\Customer', [], [], '', false);
     $wishlistModelMock = $this->getMock('Magento\\Wishlist\\Model\\Wishlist', ['getId', '__wakeup', 'getCustomerId'], [], '', false);
     $expectedHeaders = ['title' => __('We cannot retrieve the wish list.'), 'description' => __('We cannot retrieve the wish list.'), 'link' => $url, 'charset' => 'UTF-8'];
     $this->rssFactoryMock->expects($this->once())->method('create')->will($this->returnValue($rssObjMock));
     $this->wishlistHelperMock->expects($this->once())->method('getWishlist')->will($this->returnValue($wishlistModelMock));
     $wishlistModelMock->expects($this->once())->method('getId')->will($this->returnValue(false));
     $this->urlBuilderMock->expects($this->once())->method('getUrl')->will($this->returnValue($url));
     $this->wishlistHelperMock->expects($this->once())->method('getCustomer')->will($this->returnValue($customerServiceMock));
     $rssObjMock->expects($this->once())->method('_addHeader')->with($expectedHeaders)->will($this->returnSelf());
     $rssObjMock->expects($this->once())->method('createRssXml')->will($this->returnValue($rssString));
     $this->assertEquals($rssString, $this->block->toHtml());
 }