예제 #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());
 }
예제 #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());
 }
예제 #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());
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 public function getRssData()
 {
     $newUrl = $this->rssUrlBuilder->getUrl(['_secure' => true, '_nosecret' => true, 'type' => 'notifystock']);
     $title = __('Low Stock Products');
     $data = ['title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8'];
     foreach ($this->rssModel->getProductsCollection() as $item) {
         /* @var $item \Magento\Catalog\Model\Product */
         $url = $this->getUrl('catalog/product/edit', ['id' => $item->getId(), '_secure' => true, '_nosecret' => true]);
         $qty = 1 * $item->getQty();
         $description = __('%1 has reached a quantity of %2.', $item->getName(), $qty);
         $data['entries'][] = ['title' => $item->getName(), 'link' => $url, 'description' => $description];
     }
     return $data;
 }
예제 #5
0
 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());
 }
예제 #6
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());
 }
예제 #7
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());
 }
예제 #8
0
 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());
 }
예제 #9
0
 /**
  * @return array
  */
 public function getFeeds()
 {
     $data = [];
     if ($this->isAllowed()) {
         $url = $this->rssUrlBuilder->getUrl(['type' => 'special_products']);
         $data = ['label' => __('Special Products'), 'link' => $url];
     }
     return $data;
 }
 /**
  * @return array
  */
 public function getFeeds()
 {
     $data = [];
     if ($this->isAllowed()) {
         $url = $this->rssUrlBuilder->getUrl(['type' => 'blog_categories']);
         $data = ['label' => __('Posts'), 'link' => $url];
     }
     return $data;
 }
예제 #11
0
 /**
  * Get RSS feed items
  *
  * @return array
  */
 public function getRssData()
 {
     $passDate = $this->dateTime->formatDate(mktime(0, 0, 0, date('m'), date('d') - 7));
     $newUrl = $this->rssUrlBuilder->getUrl(['_secure' => true, '_nosecret' => true, 'type' => 'new_order']);
     $title = __('New Orders');
     $data = ['title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8'];
     /** @var $order \Magento\Sales\Model\Order */
     $order = $this->orderFactory->create();
     /** @var $collection \Magento\Sales\Model\ResourceModel\Order\Collection */
     $collection = $order->getResourceCollection();
     $collection->addAttributeToFilter('created_at', ['date' => true, 'from' => $passDate])->addAttributeToSort('created_at', 'desc');
     $this->eventManager->dispatch('rss_order_new_collection_select', ['collection' => $collection]);
     $detailBlock = $this->layout->getBlockSingleton('Magento\\Sales\\Block\\Adminhtml\\Order\\Details');
     foreach ($collection as $item) {
         $title = __('Order #%1 created at %2', $item->getIncrementId(), $this->localeDate->formatDate($item->getCreatedAt()));
         $url = $this->urlBuilder->getUrl('sales/order/view', ['_secure' => true, 'order_id' => $item->getId(), '_nosecret' => true]);
         $detailBlock->setOrder($item);
         $data['entries'][] = ['title' => $title, 'link' => $url, 'description' => $detailBlock->toHtml()];
     }
     return $data;
 }
예제 #12
0
 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());
 }
예제 #13
0
 /**
  * @return array
  */
 public function getFeeds()
 {
     $result = [];
     if ($this->isAllowed()) {
         /** @var $category \Magento\Catalog\Model\Category */
         $category = $this->categoryFactory->create();
         $treeModel = $category->getTreeModel()->loadNode($this->storeManager->getStore()->getRootCategoryId());
         $nodes = $treeModel->loadChildren()->getChildren();
         $nodeIds = [];
         foreach ($nodes as $node) {
             $nodeIds[] = $node->getId();
         }
         /* @var $collection \Magento\Catalog\Model\ResourceModel\Category\Collection */
         $collection = $category->getResourceCollection();
         $collection->addIdFilter($nodeIds)->addAttributeToSelect('url_key')->addAttributeToSelect('name')->addAttributeToSelect('is_anchor')->addAttributeToFilter('is_active', 1)->addAttributeToSort('name')->load();
         $feeds = [];
         foreach ($collection as $category) {
             $feeds[] = ['label' => $category->getName(), 'link' => $this->rssUrlBuilder->getUrl(['type' => 'category', 'cid' => $category->getId()])];
         }
         $result = ['group' => 'Categories', 'feeds' => $feeds];
     }
     return $result;
 }
예제 #14
0
 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());
 }
예제 #15
0
 /**
  * @return string
  */
 public function getLink()
 {
     return $this->rssUrlBuilder->getUrl($this->getLinkParams());
 }
예제 #16
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());
 }
예제 #17
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());
 }