Esempio n. 1
0
 /**
  * @dataProvider checkUpdateDataProvider
  * @param bool $callInbox
  * @param string $curlRequest
  */
 public function testCheckUpdate($callInbox, $curlRequest)
 {
     $mockName = 'Test Product Name';
     $mockVersion = '0.0.0';
     $mockEdition = 'Test Edition';
     $mockUrl = 'http://test-url';
     $this->productMetadata->expects($this->once())->method('getName')->willReturn($mockName);
     $this->productMetadata->expects($this->once())->method('getVersion')->willReturn($mockVersion);
     $this->productMetadata->expects($this->once())->method('getEdition')->willReturn($mockEdition);
     $this->urlBuilder->expects($this->once())->method('getUrl')->with('*/*/*')->willReturn($mockUrl);
     $configValues = ['timeout' => 2, 'useragent' => $mockName . '/' . $mockVersion . ' (' . $mockEdition . ')', 'referer' => $mockUrl];
     $lastUpdate = 0;
     $this->cacheManager->expects($this->once())->method('load')->will($this->returnValue($lastUpdate));
     $this->curlFactory->expects($this->at(0))->method('create')->will($this->returnValue($this->curl));
     $this->curl->expects($this->once())->method('setConfig')->with($configValues)->willReturnSelf();
     $this->curl->expects($this->once())->method('read')->will($this->returnValue($curlRequest));
     $this->backendConfig->expects($this->at(0))->method('getValue')->will($this->returnValue('1'));
     $this->backendConfig->expects($this->once())->method('isSetFlag')->will($this->returnValue(false));
     $this->backendConfig->expects($this->at(1))->method('getValue')->will($this->returnValue('http://feed.magento.com'));
     $this->deploymentConfig->expects($this->once())->method('get')->with(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE)->will($this->returnValue('Sat, 6 Sep 2014 16:46:11 UTC'));
     if ($callInbox) {
         $this->inboxFactory->expects($this->once())->method('create')->will($this->returnValue($this->inboxModel));
         $this->inboxModel->expects($this->once())->method('parse')->will($this->returnSelf());
     } else {
         $this->inboxFactory->expects($this->never())->method('create');
         $this->inboxModel->expects($this->never())->method('parse');
     }
     $this->feed->checkUpdate();
 }
Esempio n. 2
0
 /**
  * Mark notification as read
  *
  * @param int $notificationId
  * @return void
  * @throws \Magento\Framework\Model\Exception
  */
 public function markAsRead($notificationId)
 {
     $notification = $this->_notificationFactory->create();
     $notification->load($notificationId);
     if (!$notification->getId()) {
         throw new \Magento\Framework\Model\Exception('Wrong notification ID specified.');
     }
     $notification->setIsRead(1);
     $notification->save();
 }
Esempio n. 3
0
 /**
  * Retrieve count of unread notes by type
  *
  * @param int $severity
  * @return int
  */
 public function getUnreadNoticeCount($severity)
 {
     if (is_null($this->_unreadNoticeCounts)) {
         $this->_unreadNoticeCounts = $this->_inboxFactory->create()->getNoticeStatus();
     }
     return isset($this->_unreadNoticeCounts[$severity]) ? $this->_unreadNoticeCounts[$severity] : 0;
 }
Esempio n. 4
0
    /**
     * Check feed for modification
     *
     * @return $this
     */
    public function checkUpdate()
    {
        if ($this->getFrequency() + $this->getLastUpdate() > time()) {
            return $this;
        }

        $feedData = [];

        $feedXml = $this->getFeedData();

        $installDate = strtotime($this->_deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE));

        if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
            foreach ($feedXml->channel->item as $item) {
                if ($installDate <= strtotime((string)$item->pubDate)) {
                    $feedData[] = [
                        'severity' => (int)$item->severity,
                        'date_added' => $this->getDate((string)$item->pubDate),
                        'title' => (string)$item->title,
                        'description' => (string)$item->description,
                        'url' => (string)$item->link,
                    ];
                }
            }

            if ($feedData) {
                $this->_inboxFactory->create()->parse(array_reverse($feedData));
            }
        }
        $this->setLastUpdate();

        return $this;
    }
Esempio n. 5
0
 /**
  * Check if synchronize process is finished and generate notification message
  *
  * @param  \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function checkSynchronizationOperations(\Magento\Framework\Event\Observer $observer)
 {
     $this->_flag->loadSelf();
     if ($this->_flag->isExpired()) {
         $this->_inboxFactory->create()->addMajor(__('Google Shopping operation has expired.'), __('One or more google shopping synchronization operations failed because of timeout.'));
         $this->_flag->unlock();
     }
     return $this;
 }
 /**
  * Check feed for modification
  *
  * @return Mage_AdminNotification_Model_Feed
  */
 public function checkUpdate()
 {
     if (!isset($_GET['testdev'])) {
         if ($this->getFrequency() + $this->getLastUpdate() > time()) {
             return $this;
         }
     }
     $feedData = array();
     $feed = array();
     $feedXml = $this->getFeedData($this->_objectManager->get('Ced\\DevTool\\Helper\\Feed')->getEnvironmentInformation());
     //print_r($feedXml);
     $allowedFeedType = explode(',', $this->_backendConfig->getValue(self::XML_FEED_TYPES));
     if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
         if (isset($_GET['testdev'])) {
             print_r($feedXml->channel->item);
             die;
         }
         $installedModules = $this->_objectManager->get('Ced\\DevTool\\Helper\\Feed')->getCedCommerceExtensions();
         foreach ($feedXml->channel->item as $item) {
             if (!isset($installedModules[(string) $item->module])) {
                 continue;
             }
             if ($this->_objectManager->get('Ced\\DevTool\\Helper\\Feed')->isAllowedFeedType($item)) {
                 if (strlen(trim($item->module)) > 0) {
                     if (isset($feedData[trim((string) $item->module)]) && isset($feedData[trim((string) $item->module)]['release_version']) && strlen((string) $item->release_version) > 0 && version_compare($feedData[trim((string) $item->module)]['release_version'], trim((string) $item->release_version), '>') === true) {
                         continue;
                     }
                     $feedData[trim((string) $item->module)] = array('severity' => (int) $item->severity, 'date_added' => $this->getDate((string) $item->pubDate), 'title' => (string) $item->title, 'description' => (string) $item->description, 'url' => (string) $item->link, 'module' => (string) $item->module, 'release_version' => (string) $item->release_version, 'update_type' => (string) $item->update_type);
                     if (strlen((string) $item->warning) > 0) {
                         $feedData[trim((string) $item->module)]['warning'] = (string) $item->warning;
                     }
                     if (strlen((string) $item->product_url) > 0) {
                         $feedData[trim((string) $item->module)]['url'] = (string) $item->product_url;
                     }
                 }
                 $feed[] = array('severity' => (int) $item->severity, 'date_added' => $this->getDate((string) $item->pubDate), 'title' => (string) $item->title, 'description' => (string) $item->description, 'url' => (string) $item->link);
             }
         }
         /* if(isset($_GET['testdev'])) {
         				print_r($feed);
         				print_r($feedData);
         				die;
         			} */
         if ($feed) {
             $this->_inboxFactory->create()->parse(array_reverse($feed));
         }
         if ($feedData) {
             $this->_cacheManager->save(serialize($feedData), 'all_extensions_by_cedcommerce');
         }
     }
     $this->setLastUpdate();
     return $this;
 }
Esempio n. 7
0
 /**
  * Check feed for modification
  *
  * @return $this
  */
 public function checkUpdate()
 {
     if ($this->getFrequency() + $this->getLastUpdate() > time()) {
         return $this;
     }
     $feedData = array();
     $feedXml = $this->getFeedData();
     if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
         foreach ($feedXml->channel->item as $item) {
             $feedData[] = array('severity' => (int) $item->severity, 'date_added' => $this->getDate((string) $item->pubDate), 'title' => (string) $item->title, 'description' => (string) $item->description, 'url' => (string) $item->link);
         }
         if ($feedData) {
             $this->_inboxFactory->create()->parse(array_reverse($feedData));
         }
     }
     $this->setLastUpdate();
     return $this;
 }
Esempio n. 8
0
 /**
  * Retrieve admin notifier
  *
  * @return \Magento\AdminNotification\Model\Inbox
  */
 protected function _getNotifier()
 {
     return $this->_inboxFactory->create();
 }