コード例 #1
0
ファイル: FeedTest.php プロジェクト: shabbirvividads/magento2
 /**
  * @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('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();
 }
コード例 #2
0
ファイル: Feed.php プロジェクト: swissup/core
 /**
  * Overriden to check config status before fetching data
  *
  * @return $this
  */
 public function checkUpdate()
 {
     if (!$this->_backendConfig->isSetFlag(self::CONFIG_PATH_ENABLED)) {
         return $this;
     }
     return parent::checkUpdate();
 }
コード例 #3
0
 /**
  * @dataProvider checkUpdateDataProvider
  * @param bool $callInbox
  * @param string $curlRequest
  */
 public function testCheckUpdate($callInbox, $curlRequest)
 {
     $lastUpdate = 1410121748;
     $this->curlFactory->expects($this->at(0))->method('create')->will($this->returnValue($this->curl));
     $this->curl->expects($this->any())->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->cacheManager->expects($this->once())->method('load')->will($this->returnValue($lastUpdate));
     $this->deploymentConfig->expects($this->once())->method('get')->with('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();
 }
コード例 #4
0
 public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Backend\App\ConfigInterface $backendConfig, \Magento\AdminNotification\Model\InboxFactory $inboxFactory, \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory, \Magento\Framework\App\DeploymentConfig $deploymentConfig, \Magento\Framework\App\ProductMetadataInterface $productMetadata, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\Module\ModuleListInterface $moduleLoader, \Magento\Framework\Module\Declaration\Converter\Dom $dom, \Magento\Framework\Component\ComponentRegistrarInterface $moduleRegistry, \Magento\Framework\Xml\Parser $parser, \Magento\Framework\Filesystem\Driver\File $filesystemDriver, \Magento\Framework\Module\ModuleList\Loader $loader, \Magento\Framework\ObjectManagerInterface $objectManager, array $data = [])
 {
     $this->moduleList = $moduleLoader;
     $this->dom = $dom;
     $this->loader = $loader;
     $this->moduleRegistry = $moduleRegistry;
     $this->parser = $parser;
     $this->filesystemDriver = $filesystemDriver;
     $this->_objectManager = $objectManager;
     $this->_inboxFactory = $inboxFactory;
     parent::__construct($context, $registry, $backendConfig, $inboxFactory, $curlFactory, $deploymentConfig, $productMetadata, $urlBuilder);
 }
コード例 #5
0
 /**
  * Check feed for modification
  *
  * @return $this
  */
 public function checkUpdate()
 {
     $session = $this->_backendAuthSession;
     $time = time();
     $frequency = $this->getFrequency();
     if ($frequency + $session->getMfNoticeLastUpdate() > $time || $frequency + $this->getLastUpdate() > $time) {
         return $this;
     }
     $session->setMfNoticeLastUpdate($time);
     return parent::checkUpdate();
 }
コード例 #6
0
ファイル: Feed.php プロジェクト: Doability/magento2dev
 public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Backend\App\ConfigInterface $backendConfig, \Magento\AdminNotification\Model\InboxFactory $inboxFactory, \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory, \Magento\Framework\App\DeploymentConfig $deploymentConfig, \Magento\Framework\App\ProductMetadataInterface $productMetadata, \Magento\Framework\UrlInterface $urlBuilder, \Wyomind\Core\Helper\Data $coreHelper, \Magento\Framework\Module\ModuleList $moduleList, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [])
 {
     parent::__construct($context, $registry, $backendConfig, $inboxFactory, $curlFactory, $deploymentConfig, $productMetadata, $urlBuilder, $resource, $resourceCollection, $data);
     $this->coreHelper = $coreHelper;
     $this->moduleList = $moduleList;
 }