/** * @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(); }
/** * @param string $name application name * @param string $version application version * @SuppressWarnings(PHPMD.ExitExpression) */ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') { $this->serviceManager = \Zend\Mvc\Application::init(require BP . '/setup/config/application.config.php')->getServiceManager(); $generationDirectoryAccess = new GenerationDirectoryAccess($this->serviceManager); if (!$generationDirectoryAccess->check()) { $output = new ConsoleOutput(); $output->writeln('<error>Command line user does not have read and write permissions on var/generation directory. Please' . ' address this issue before using Magento command line.</error>'); exit(0); } /** * Temporary workaround until the compiler is able to clear the generation directory * @todo remove after MAGETWO-44493 resolved */ if (class_exists(CompilerPreparation::class)) { $compilerPreparation = new CompilerPreparation($this->serviceManager, new ArgvInput(), new File()); $compilerPreparation->handleCompilerEnvironment(); } if ($version == 'UNKNOWN') { $directoryList = new DirectoryList(BP); $composerJsonFinder = new ComposerJsonFinder($directoryList); $productMetadata = new ProductMetadata($composerJsonFinder); $version = $productMetadata->getVersion(); } parent::__construct($name, $version); }
/** * @return array|ViewModel */ public function indexAction() { $welcomeMsg = "Welcome to Magento Admin, your online store headquarters.<br>" . "Click 'Agree and Set Up Magento' or read "; $docRef = "http://devdocs.magento.com/guides/v1.0/install-gde/install/install-web.html"; $agreeButtonText = "Agree and Setup Magento"; $view = new ViewModel(); $view->setTerminal(true); $view->setTemplate('/magento/setup/landing.phtml'); $view->setVariable('version', $this->productMetadata->getVersion()); $view->setVariable('welcomeMsg', $welcomeMsg); $view->setVariable('docRef', $docRef); $view->setVariable('agreeButtonText', $agreeButtonText); return $view; }
/** * Return site specific information * * @return array */ public function getSiteDetails($storeId = null) { $edition = $this->productMetadata->getEdition(); $url = $this->storeManager->getStore($storeId)->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK); $siteDetails = $this->siteDetailsFactory->create(['ecommerceCart' => 'Magento 2 ' . $edition, 'ecommerceVersion' => $this->productMetadata->getVersion(), 'websiteUrl' => $url, 'environmentScope' => $this->shipperDataHelper->getConfigValue('carriers/shipper/environment_scope', $storeId), 'appVersion' => $this->shipperDataHelper->getConfigValue('carriers/shipper/extension_version')]); return $siteDetails; }
public function testGetName() { $productName = $this->productMetadata->getName(); $this->assertNotEmpty($productName, 'Empty product name'); }
/** * version information * * @return array */ public function getVersionInfo() { return ['product' => 'Magento2', 'productVersion' => $this->_productMetadata->getVersion(), 'pluginName' => $this->_pluginName, 'pluginVersion' => $this->_pluginVersion]; }