50 'title' =>
'Low Stock Products',
51 'description' =>
'Low Stock Products',
52 'link' =>
'http://magento.com/rss/feeds/index/type/notifystock',
56 'title' =>
'Low Stock Product',
57 'description' =>
'Low Stock Product has reached a quantity of 1.',
58 'link' =>
'http://magento.com/catalog/product/edit/id/1',
66 $this->rssModel = $this->getMockBuilder(\
Magento\Catalog\Model\Rss\Product\NotifyStock::class)
67 ->setMethods([
'getProductsCollection',
'__wakeup'])
68 ->disableOriginalConstructor()->getMock();
69 $this->rssUrlBuilder = $this->createMock(\
Magento\Framework\
App\Rss\UrlBuilderInterface::class);
70 $this->urlBuilder = $this->createMock(\
Magento\Framework\UrlInterface::class);
71 $this->objectManagerHelper =
new ObjectManagerHelper($this);
72 $this->block = $this->objectManagerHelper->getObject(
73 \
Magento\Catalog\Block\Adminhtml\Rss\NotifyStock::class,
75 'urlBuilder' => $this->urlBuilder,
76 'rssModel' => $this->rssModel,
77 'rssUrlBuilder' => $this->rssUrlBuilder
84 $this->rssUrlBuilder->expects($this->once())->method(
'getUrl')
85 ->will($this->returnValue(
'http://magento.com/rss/feeds/index/type/notifystock'));
86 $item = $this->getMockBuilder(\
Magento\Catalog\Model\Product::class)
87 ->setMethods([
'__sleep',
'__wakeup',
'getId',
'getQty',
'getName'])
88 ->disableOriginalConstructor()
90 $item->expects($this->once())->method(
'getId')->will($this->returnValue(1));
91 $item->expects($this->once())->method(
'getQty')->will($this->returnValue(1));
92 $item->expects($this->any())->method(
'getName')->will($this->returnValue(
'Low Stock Product'));
94 $this->rssModel->expects($this->once())->method(
'getProductsCollection')
95 ->will($this->returnValue([
$item]));
96 $this->urlBuilder->expects($this->once())->method(
'getUrl')
97 ->with(
'catalog/product/edit', [
'id' => 1,
'_secure' =>
true,
'_nosecret' =>
true])
98 ->will($this->returnValue(
'http://magento.com/catalog/product/edit/id/1'));
99 $this->assertEquals($this->rssFeed, $this->block->getRssData());
104 $this->assertEquals(600, $this->block->getCacheLifetime());
109 $this->assertTrue($this->block->isAllowed());
114 $this->assertEmpty($this->block->getFeeds());