71 'title' =>
'New Orders',
72 'link' =>
'http://magento.com/backend/rss/feed/index/type/new_order',
73 'description' =>
'New Orders',
77 'title' =>
'Order #100000001 created at 2014-09-10 17:39:50',
78 'link' =>
'http://magento.com/sales/order/view/order_id/1',
79 'description' =>
'Order Description',
86 $this->orderFactory = $this->createPartialMock(\
Magento\Sales\Model\OrderFactory::class, [
'create']);
87 $this->urlBuilder = $this->createMock(\
Magento\Framework\UrlInterface::class);
88 $this->timezoneInterface = $this->createMock(\
Magento\Framework\Stdlib\DateTime\TimezoneInterface::class);
89 $this->dateTime = $this->createMock(\
Magento\Framework\Stdlib\DateTime::class);
90 $this->scopeConfigInterface = $this->createMock(\
Magento\Framework\
App\
Config\ScopeConfigInterface::class);
91 $this->eventManager = $this->createMock(\
Magento\Framework\Event\ManagerInterface::class);
92 $this->layout = $this->createMock(\
Magento\Framework\View\LayoutInterface::class);
93 $this->rssUrlBuilderInterface = $this->getMockBuilder(\
Magento\Framework\
App\Rss\UrlBuilderInterface::class)
94 ->setMethods([
'getUrl'])
95 ->disableOriginalConstructor()->getMock();
96 $this->objectManagerHelper =
new ObjectManagerHelper($this);
97 $this->model = $this->objectManagerHelper->getObject(
98 \
Magento\Sales\Model\Rss\NewOrder::class,
100 'orderFactory' => $this->orderFactory,
101 'urlBuilder' => $this->urlBuilder,
102 'rssUrlBuilder' => $this->rssUrlBuilderInterface,
103 'localeDate' => $this->timezoneInterface,
104 'dateTime' => $this->dateTime,
105 'scopeConfig' => $this->scopeConfigInterface,
106 'eventManager' => $this->eventManager,
107 'layout' => $this->layout
114 $this->assertTrue($this->model->isAllowed());
119 $this->dateTime->expects($this->once())->method(
'formatDate')->will($this->returnValue(date(
'Y-m-d H:i:s')));
121 $this->rssUrlBuilderInterface->expects($this->once())->method(
'getUrl')
122 ->with([
'_secure' =>
true,
'_nosecret' =>
true,
'type' =>
'new_order'])
123 ->will($this->returnValue(
'http://magento.com/backend/rss/feed/index/type/new_order'));
125 $this->timezoneInterface->expects($this->once())->method(
'formatDate')
126 ->will($this->returnValue(
'2014-09-10 17:39:50'));
128 $order = $this->getMockBuilder(\
Magento\Sales\Model\Order::class)
129 ->setMethods([
'__sleep',
'__wakeup',
'getResourceCollection',
'getIncrementId',
'getId',
'getCreatedAt'])
130 ->disableOriginalConstructor()->getMock();
131 $order->expects($this->once())->method(
'getId')->will($this->returnValue(1));
132 $order->expects($this->once())->method(
'getIncrementId')->will($this->returnValue(
'100000001'));
133 $order->expects($this->once())->method(
'getCreatedAt')->will($this->returnValue(
time()));
136 ->setMethods([
'addAttributeToFilter',
'addAttributeToSort',
'getIterator'])
137 ->disableOriginalConstructor()->getMock();
138 $collection->expects($this->once())->method(
'addAttributeToFilter')->will($this->returnSelf());
139 $collection->expects($this->once())->method(
'addAttributeToSort')->will($this->returnSelf());
140 $collection->expects($this->once())->method(
'getIterator')
141 ->will($this->returnValue(
new \ArrayIterator([
$order])));
143 $order->expects($this->once())->method(
'getResourceCollection')->will($this->returnValue(
$collection));
144 $this->orderFactory->expects($this->once())->method(
'create')->will($this->returnValue(
$order));
146 $this->eventManager->expects($this->once())->method(
'dispatch')->will($this->returnSelf());
148 $block = $this->createPartialMock(\
Magento\Sales\Block\Adminhtml\
Order\Details::class, [
'setOrder',
'toHtml']);
149 $block->expects($this->once())->method(
'setOrder')->with(
$order)->will($this->returnSelf());
150 $block->expects($this->once())->method(
'toHtml')->will($this->returnValue(
'Order Description'));
152 $this->layout->expects($this->once())->method(
'getBlockSingleton')->will($this->returnValue(
$block));
153 $this->urlBuilder->expects($this->once())->method(
'getUrl')
154 ->will($this->returnValue(
'http://magento.com/sales/order/view/order_id/1'));
155 $this->assertEquals($this->feedData, $this->model->getRssData());
160 $this->assertEquals(
'rss_new_orders_data', $this->model->getCacheKey());
165 $this->assertEquals(60, $this->model->getCacheLifetime());
170 $this->assertEmpty($this->model->getFeeds());