public function testGetDiscountCollection()
 {
     $ruleCollection = $this->getMock('Magento\\SalesRule\\Model\\ResourceModel\\Rule\\Collection', ['addWebsiteGroupDateFilter', 'addFieldToFilter', 'setOrder', 'load'], [], '', false);
     $this->collectionFactory->expects($this->once())->method('create')->will($this->returnValue($ruleCollection));
     $ruleCollection->expects($this->once())->method('addWebsiteGroupDateFilter')->will($this->returnSelf());
     $ruleCollection->expects($this->once())->method('addFieldToFilter')->will($this->returnSelf());
     $ruleCollection->expects($this->once())->method('setOrder')->will($this->returnSelf());
     $ruleCollection->expects($this->once())->method('load')->will($this->returnSelf());
     $this->assertEquals($ruleCollection, $this->discounts->getDiscountCollection(1, 1));
 }
 /**
  * {@inheritdoc}
  */
 public function getRssData()
 {
     $storeId = $this->getStoreId();
     $storeModel = $this->storeManager->getStore($storeId);
     $websiteId = $storeModel->getWebsiteId();
     $customerGroupId = $this->getCustomerGroupId();
     $url = $this->_urlBuilder->getUrl('');
     $newUrl = $this->rssUrlBuilder->getUrl(['type' => 'discounts', 'store_id' => $storeId, 'cid' => $customerGroupId]);
     $title = __('%1 - Discounts and Coupons', $storeModel->getFrontendName());
     $lang = $this->_scopeConfig->getValue('general/locale/code', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeModel);
     $data = ['title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8', 'language' => $lang];
     /** @var $rule \Magento\SalesRule\Model\Rule */
     foreach ($this->rssModel->getDiscountCollection($websiteId, $customerGroupId) as $rule) {
         $toDate = $rule->getToDate() ? '<br/>Discount End Date: ' . $this->formatDate($rule->getToDate(), \IntlDateFormatter::MEDIUM) : '';
         $couponCode = $rule->getCouponCode() ? '<br/> Coupon Code: ' . $rule->getCouponCode() : '';
         $description = sprintf('<table><tr><td style="text-decoration:none;">%s<br/>Discount Start Date: %s %s %s</td></tr></table>', $rule->getDescription(), $this->formatDate($rule->getFromDate(), \IntlDateFormatter::MEDIUM), $toDate, $couponCode);
         $data['entries'][] = ['title' => $rule->getName(), 'description' => $description, 'link' => $url];
     }
     return $data;
 }