Example #1
0
 public function testGetRssData()
 {
     $this->rssUrlBuilder->expects($this->once())->method('getUrl')->will($this->returnValue('http://magento.com/rss/feeds/index/type/notifystock'));
     $item = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->setMethods(['__sleep', '__wakeup', 'getId', 'getQty', 'getName'])->disableOriginalConstructor()->getMock();
     $item->expects($this->once())->method('getId')->will($this->returnValue(1));
     $item->expects($this->once())->method('getQty')->will($this->returnValue(1));
     $item->expects($this->any())->method('getName')->will($this->returnValue('Low Stock Product'));
     $this->rssModel->expects($this->once())->method('getProductsCollection')->will($this->returnValue([$item]));
     $this->urlBuilder->expects($this->once())->method('getUrl')->with('catalog/product/edit', ['id' => 1, '_secure' => true, '_nosecret' => true])->will($this->returnValue('http://magento.com/catalog/product/edit/id/1'));
     $this->assertEquals($this->rssFeed, $this->block->getRssData());
 }
Example #2
0
 public function testGetLink()
 {
     $rssUrl = 'http://rss.magento.com';
     $this->urlBuilderInterface->expects($this->once())->method('getUrl')->will($this->returnValue($rssUrl));
     $categoryModel = $this->getMock('\\Magento\\Catalog\\Model\\Category', ['__wakeup', 'getId'], [], '', false);
     $this->registry->expects($this->once())->method('registry')->will($this->returnValue($categoryModel));
     $categoryModel->expects($this->any())->method('getId')->will($this->returnValue('1'));
     $storeModel = $this->getMock('\\Magento\\Store\\Model\\Category', ['__wakeup', 'getId'], [], '', false);
     $this->storeManagerInterface->expects($this->any())->method('getStore')->will($this->returnValue($storeModel));
     $storeModel->expects($this->any())->method('getId')->will($this->returnValue('1'));
     $this->assertEquals($rssUrl, $this->link->getLink());
 }
Example #3
0
 public function testGetLink()
 {
     $order = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->setMethods(['getId', 'getCustomerId', 'getIncrementId', 'load', '__wakeup', '__sleep'])->disableOriginalConstructor()->getMock();
     $order->expects($this->once())->method('load')->will($this->returnSelf());
     $order->expects($this->once())->method('getId')->will($this->returnValue(1));
     $order->expects($this->once())->method('getCustomerId')->will($this->returnValue(1));
     $order->expects($this->once())->method('getIncrementId')->will($this->returnValue('100000001'));
     $this->orderFactory->expects($this->once())->method('create')->will($this->returnValue($order));
     $data = base64_encode(json_encode(['order_id' => 1, 'increment_id' => '100000001', 'customer_id' => 1]));
     $link = 'http://magento.com/rss/feed/index/type/order_status?data=' . $data;
     $this->urlBuilderInterface->expects($this->once())->method('getUrl')->with(['type' => 'order_status', '_secure' => true, '_query' => ['data' => $data]])->will($this->returnValue($link));
     $this->assertEquals($link, $this->rss->getLink());
 }
 public function testGetFeeds()
 {
     $this->scopeConfig->expects($this->once())->method('isSetFlag')->with('rss/catalog/category', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)->will($this->returnValue(true));
     $category = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Category')->setMethods(['__sleep', '__wakeup', 'getTreeModel', 'getResourceCollection', 'getId', 'getName'])->disableOriginalConstructor()->getMock();
     $collection = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Resource\\Category\\Collection')->setMethods(['addIdFilter', 'addAttributeToSelect', 'addAttributeToSort', 'load', 'addAttributeToFilter', 'getIterator'])->disableOriginalConstructor()->getMock();
     $collection->expects($this->once())->method('addIdFilter')->will($this->returnSelf());
     $collection->expects($this->exactly(3))->method('addAttributeToSelect')->will($this->returnSelf());
     $collection->expects($this->once())->method('addAttributeToSort')->will($this->returnSelf());
     $collection->expects($this->once())->method('addAttributeToFilter')->will($this->returnSelf());
     $collection->expects($this->once())->method('load')->will($this->returnSelf());
     $collection->expects($this->once())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$category])));
     $category->expects($this->once())->method('getId')->will($this->returnValue(1));
     $category->expects($this->once())->method('getName')->will($this->returnValue('Category Name'));
     $category->expects($this->once())->method('getResourceCollection')->will($this->returnValue($collection));
     $this->categoryFactory->expects($this->once())->method('create')->will($this->returnValue($category));
     $node = new \Magento\Framework\Object(['id' => 1]);
     $nodes = $this->getMockBuilder('Magento\\Framework\\Data\\Tree\\Node')->setMethods(['getChildren'])->disableOriginalConstructor()->getMock();
     $nodes->expects($this->once())->method('getChildren')->will($this->returnValue([$node]));
     $tree = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Resource\\Category\\Tree')->setMethods(['loadChildren', 'loadNode'])->disableOriginalConstructor()->getMock();
     $tree->expects($this->once())->method('loadNode')->will($this->returnSelf());
     $tree->expects($this->once())->method('loadChildren')->will($this->returnValue($nodes));
     $category->expects($this->once())->method('getTreeModel')->will($this->returnValue($tree));
     $category->expects($this->once())->method('getResourceCollection')->will($this->returnValue(''));
     $this->rssUrlBuilder->expects($this->once())->method('getUrl')->will($this->returnValue('http://magento.com/category-name.html'));
     $feeds = ['group' => 'Categories', 'feeds' => [['label' => 'Category Name', 'link' => 'http://magento.com/category-name.html']]];
     $this->assertEquals($feeds, $this->block->getFeeds());
 }
Example #5
0
 public function testGetFeeds()
 {
     $this->scopeConfig->expects($this->once())->method('isSetFlag')->with('rss/catalog/special', \Magento\Framework\Store\ScopeInterface::SCOPE_STORE)->will($this->returnValue(true));
     $this->rssUrlBuilder->expects($this->once())->method('getUrl')->with(['type' => 'special_products'])->will($this->returnValue('http://magento.com/rss/feed/index/type/special_products/store_id/1'));
     $expected = ['label' => 'Special Products', 'link' => 'http://magento.com/rss/feed/index/type/special_products/store_id/1'];
     $this->assertEquals($expected, $this->block->getFeeds());
 }
Example #6
0
 public function testGetFeeds()
 {
     $feedData = ['label' => 'Coupons/Discounts', 'link' => 'http://rss.magento.com/discount'];
     $this->rssBuilderInterface->expects($this->any())->method('getUrl')->will($this->returnValue($feedData['link']));
     $this->scopeConfigInterface->expects($this->once())->method('isSetFlag')->will($this->returnValue(true));
     $this->assertEquals($feedData, $this->block->getFeeds());
 }
 public function testGetFeeds()
 {
     $this->scopeConfig->expects($this->once())->method('isSetFlag')->will($this->returnValue(true));
     $rssUrl = 'http://magento.com/rss/feed/index/type/new_products/store_id/1';
     $this->rssUrlBuilder->expects($this->once())->method('getUrl')->with(['type' => 'new_products'])->will($this->returnValue($rssUrl));
     $expected = ['label' => 'New Products', 'link' => $rssUrl];
     $this->assertEquals($expected, $this->block->getFeeds());
 }
 public function testGetData()
 {
     $this->dateTime->expects($this->once())->method('formatDate')->will($this->returnValue(date('Y-m-d H:i:s')));
     $this->rssUrlBuilderInterface->expects($this->once())->method('getUrl')->with(['_secure' => true, '_nosecret' => true, 'type' => 'new_order'])->will($this->returnValue('http://magento.com/backend/rss/feed/index/type/new_order'));
     $this->timezoneInterface->expects($this->once())->method('formatDate')->will($this->returnValue('2014-09-10 17:39:50'));
     $order = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->setMethods(['__sleep', '__wakeup', 'getResourceCollection', 'getIncrementId', 'getId', 'getCreatedAt'])->disableOriginalConstructor()->getMock();
     $order->expects($this->once())->method('getId')->will($this->returnValue(1));
     $order->expects($this->once())->method('getIncrementId')->will($this->returnValue('100000001'));
     $order->expects($this->once())->method('getCreatedAt')->will($this->returnValue(time()));
     $collection = $this->getMockBuilder('\\Magento\\Sales\\Model\\ResourceModel\\Order\\Collection')->setMethods(['addAttributeToFilter', 'addAttributeToSort', 'getIterator'])->disableOriginalConstructor()->getMock();
     $collection->expects($this->once())->method('addAttributeToFilter')->will($this->returnSelf());
     $collection->expects($this->once())->method('addAttributeToSort')->will($this->returnSelf());
     $collection->expects($this->once())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$order])));
     $order->expects($this->once())->method('getResourceCollection')->will($this->returnValue($collection));
     $this->orderFactory->expects($this->once())->method('create')->will($this->returnValue($order));
     $this->eventManager->expects($this->once())->method('dispatch')->will($this->returnSelf());
     $block = $this->getMock('Magento\\Sales\\Block\\Adminhtml\\Order\\Details', ['setOrder', 'toHtml'], [], '', false);
     $block->expects($this->once())->method('setOrder')->with($order)->will($this->returnSelf());
     $block->expects($this->once())->method('toHtml')->will($this->returnValue('Order Description'));
     $this->layout->expects($this->once())->method('getBlockSingleton')->will($this->returnValue($block));
     $this->urlBuiler->expects($this->once())->method('getUrl')->will($this->returnValue('http://magento.com/sales/order/view/order_id/1'));
     $this->assertEquals($this->feedData, $this->model->getRssData());
 }
 public function testGetLink()
 {
     $this->urlBuilder->expects($this->atLeastOnce())->method('getUrl')->with($this->equalTo(['type' => 'wishlist', 'data' => 'OCx0ZXN0QGV4YW1wbGUuY29t', '_secure' => false, 'wishlist_id' => 5, 'sharing_code' => 'somesharingcode']))->will($this->returnValue('http://url.com/rss/feed/index/type/wishlist/wishlist_id/5'));
     $this->assertEquals('http://url.com/rss/feed/index/type/wishlist/wishlist_id/5', $this->link->getLink());
 }
Example #10
0
 public function testGetLink()
 {
     $rssUrl = 'http://rss.magento.com';
     $this->urlBuilderInterface->expects($this->once())->method('getUrl')->will($this->returnValue($rssUrl));
     $this->assertEquals($rssUrl, $this->link->getLink());
 }
Example #11
0
 public function testGetLink()
 {
     $link = 'http://magento.com/backend/rss/feed/index/type/new_order';
     $this->urlBuilderInterface->expects($this->once())->method('getUrl')->with(['type' => 'new_order'])->will($this->returnValue($link));
     $this->assertEquals($link, $this->link->getLink());
 }