/**
  * @test
  */
 public function findOneTypo3OrgRepositoryReturnsRepositoryWithCorrectTitle()
 {
     $mockModelOne = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository');
     $mockModelOne->expects($this->once())->method('getTitle')->will($this->returnValue('foo'));
     $mockModelTwo = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository');
     $mockModelTwo->expects($this->once())->method('getTitle')->will($this->returnValue('TYPO3.org Main Repository'));
     $this->fixture->expects($this->once())->method('findAll')->will($this->returnValue(array($mockModelOne, $mockModelTwo)));
     $this->assertSame($mockModelTwo, $this->fixture->findOneTypo3OrgRepository());
 }
 /**
  * Update extension list from TER
  *
  * @param boolean $forceUpdateCheck
  * @return void
  */
 public function updateExtensionListFromTerAction($forceUpdateCheck = FALSE)
 {
     $updated = FALSE;
     $errorMessage = '';
     if ($this->extensionRepository->countAll() === 0 || $forceUpdateCheck) {
         try {
             $updated = $this->repositoryHelper->updateExtList();
         } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
             $errorMessage = $e->getMessage();
         }
     }
     /** @var $repository \TYPO3\CMS\Extensionmanager\Domain\Model\Repository */
     $repository = $this->repositoryRepository->findByUid((int) $this->settings['repositoryUid']);
     $this->view->assign('updated', $updated)->assign('repository', $repository)->assign('errorMessage', $errorMessage);
 }
Example #3
0
 /**
  * Check main repository status: existence, has extensions, last update younger than 7 days
  *
  * @return \TYPO3\CMS\Reports\Report\Status\Status
  */
 protected function getMainRepositoryStatus()
 {
     /** @var $mainRepository \TYPO3\CMS\Extensionmanager\Domain\Model\Repository */
     $mainRepository = $this->repositoryRepository->findOneTypo3OrgRepository();
     if (is_null($mainRepository) === TRUE) {
         $value = $this->languageService->getLL('report.status.mainRepository.notFound.value');
         $message = $this->languageService->getLL('report.status.mainRepository.notFound.message');
         $severity = \TYPO3\CMS\Reports\Status::ERROR;
     } elseif ($mainRepository->getLastUpdate()->getTimestamp() < $GLOBALS['EXEC_TIME'] - 24 * 60 * 60 * 7) {
         $value = $this->languageService->getLL('report.status.mainRepository.notUpToDate.value');
         $message = $this->languageService->getLL('report.status.mainRepository.notUpToDate.message');
         $severity = \TYPO3\CMS\Reports\Status::NOTICE;
     } else {
         $value = $this->languageService->getLL('report.status.mainRepository.upToDate.value');
         $message = '';
         $severity = \TYPO3\CMS\Reports\Status::OK;
     }
     /** @var $status \TYPO3\CMS\Reports\Status */
     $status = $this->objectManager->get(\TYPO3\CMS\Reports\Status::class, $this->languageService->getLL('report.status.mainRepository.title'), $value, $message, $severity);
     return $status;
 }
 /**
  * Update the mirrors, using the scheduler task of EXT:em.
  *
  * @throws RuntimeException
  * @return boolean
  */
 public function updateMirrors()
 {
     $result = FALSE;
     $repositories = $this->repositoryRepository->findAll();
     // update all repositories
     foreach ($repositories as $repository) {
         $this->repositoryHelper->setRepository($repository);
         $result = $this->repositoryHelper->updateExtList();
         unset($objRepository, $this->repositoryHelper);
     }
     return $result;
 }
 /**
  * Update extension list from TER
  *
  * @param boolean $forceUpdateCheck
  * @return void
  */
 public function updateExtensionListFromTerAction($forceUpdateCheck = FALSE)
 {
     $updated = FALSE;
     $errorMessage = '';
     /** @var $repository \TYPO3\CMS\Extensionmanager\Domain\Model\Repository */
     $repository = $this->repositoryRepository->findOneByUid((int) $this->settings['repositoryUid']);
     if ($repository->getLastUpdate()->getTimestamp() < $GLOBALS['EXEC_TIME'] - 24 * 60 * 60 || $forceUpdateCheck) {
         try {
             $updated = $this->repositoryHelper->updateExtList();
         } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
             $errorMessage = $e->getMessage();
         }
     }
     $this->view->assign('updated', $updated)->assign('repository', $repository)->assign('errorMessage', $errorMessage);
 }
 /**
  * Method initializes parsing of extension.xml.gz file.
  *
  * @param string $localExtensionListFile absolute path to extension list xml.gz
  * @param int $repositoryUid UID of repository when inserting records into DB
  * @return int total number of imported extension versions
  */
 public function import($localExtensionListFile, $repositoryUid = NULL)
 {
     if (!is_null($repositoryUid) && is_int($repositoryUid)) {
         $this->repositoryUid = $repositoryUid;
     }
     $zlibStream = 'compress.zlib://';
     $this->sumRecords = 0;
     $this->parser->parseXML($zlibStream . $localExtensionListFile);
     // flush last rows to database if existing
     if (!empty($this->arrRows)) {
         $GLOBALS['TYPO3_DB']->exec_INSERTmultipleRows('tx_extensionmanager_domain_model_extension', self::$fieldNames, $this->arrRows, self::$fieldIndicesNoQuote);
     }
     $extensions = $this->extensionRepository->insertLastVersion($this->repositoryUid);
     $this->repositoryRepository->updateRepositoryCount($extensions, $this->repositoryUid);
     return $this->sumRecords;
 }
 /**
  * Method initializes parsing of extension.xml.gz file.
  *
  * @param string $localExtensionListFile absolute path to extension list xml.gz
  * @param int $repositoryUid UID of repository when inserting records into DB
  * @return int total number of imported extension versions
  */
 public function import($localExtensionListFile, $repositoryUid = null)
 {
     if (!is_null($repositoryUid) && is_int($repositoryUid)) {
         $this->repositoryUid = $repositoryUid;
     }
     $zlibStream = 'compress.zlib://';
     $this->sumRecords = 0;
     $this->parser->parseXml($zlibStream . $localExtensionListFile);
     // flush last rows to database if existing
     if (!empty($this->arrRows)) {
         GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_extensionmanager_domain_model_extension')->bulkInsert('tx_extensionmanager_domain_model_extension', $this->arrRows, self::$fieldNames);
     }
     $extensions = $this->extensionRepository->insertLastVersion($this->repositoryUid);
     $this->repositoryRepository->updateRepositoryCount($extensions, $this->repositoryUid);
     return $this->sumRecords;
 }
 /**
  * @test
  */
 public function getMainRepositoryStatusReturnsOkIfUpdatedLessThanSevenDaysAgo()
 {
     /** @var $mockRepositoryRepository \TYPO3\CMS\Extensionmanager\Domain\Model\Repository|\PHPUnit_Framework_MockObject_MockObject */
     $mockRepository = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository');
     $mockRepository->expects($this->once())->method('getLastUpdate')->will($this->returnValue(new \DateTime('-6 days')));
     $this->mockRepositoryRepository->expects($this->once())->method('findOneTypo3OrgRepository')->will($this->returnValue($mockRepository));
     /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
     $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
     $mockReport->_set('objectManager', $this->mockObjectManager);
     $statusMock = $this->getMock('TYPO3\\CMS\\Reports\\Status', array(), array(), '', FALSE);
     $this->mockObjectManager->expects($this->once())->method('get')->with($this->anything(), $this->anything(), $this->anything(), $this->anything(), \TYPO3\CMS\Reports\Status::OK)->will($this->returnValue($statusMock));
     $mockReport->_set('repositoryRepository', $this->mockRepositoryRepository);
     $mockReport->_set('languageService', $this->mockLanguageService);
     /** @var $result \TYPO3\CMS\Reports\Status */
     $result = $mockReport->_call('getMainRepositoryStatus');
     $this->assertSame($statusMock, $result);
 }
Example #9
0
	/**
	 * @test
	 * @return void
	 */
	public function updateExtensionListFromTerCallsUpdateExtListIfForceUpdateCheckIsSet() {
		$controllerMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Controller\UpdateFromTerController::class, array('dummy'));
		$repositoryModelMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Repository::class, array('getLastUpdate'));
		$viewMock = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, array('assign'), array(), '', FALSE);
		$requestMock = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Request::class, array('hasArgument', 'getArgument'));
		$viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
		$this->repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
		$this->repositoryHelperMock->expects($this->once())->method('updateExtList');
		$this->extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(100));
		$controllerMock->_set('extensionRepository', $this->extensionRepositoryMock);
		$controllerMock->_set('repositoryRepository', $this->repositoryRepositoryMock);
		$controllerMock->_set('repositoryHelper', $this->repositoryHelperMock);
		$controllerMock->_set('settings', array('repositoryUid' => 1));
		$controllerMock->_set('view', $viewMock);
		$controllerMock->_set('request', $requestMock);
		$controllerMock->updateExtensionListFromTerAction(TRUE);
	}
 /**
  * @test
  * @return void
  */
 public function updateExtensionListFromTerCallsUpdateExtListIfForceUpdateCheckIsSet()
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject|AccessibleObjectInterface|UpdateFromTerController $controllerMock */
     $controllerMock = $this->getAccessibleMock(UpdateFromTerController::class, array('getLanguageService'));
     $controllerMock->expects($this->any())->method('getLanguageService')->will($this->returnValue($this->languageServiceMock));
     $repositoryModelMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Repository::class, array('getLastUpdate'));
     $viewMock = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, array('assign'), array(), '', false);
     $requestMock = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Request::class, array('hasArgument', 'getArgument'));
     $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
     $this->repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
     $this->repositoryHelperMock->expects($this->once())->method('updateExtList');
     $this->extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(100));
     $controllerMock->_set('extensionRepository', $this->extensionRepositoryMock);
     $controllerMock->_set('repositoryRepository', $this->repositoryRepositoryMock);
     $controllerMock->_set('repositoryHelper', $this->repositoryHelperMock);
     $controllerMock->_set('settings', array('repositoryUid' => 1));
     $controllerMock->_set('view', $viewMock);
     $controllerMock->_set('request', $requestMock);
     $controllerMock->updateExtensionListFromTerAction(true);
 }
 /**
  * Check main repository status: existance, has extensions, last update younger than 7 days
  *
  * @return \TYPO3\CMS\Reports\Report\Status\Status
  */
 protected function getMainRepositoryStatus()
 {
     /** @var $mainRepository \TYPO3\CMS\Extensionmanager\Domain\Model\Repository */
     $mainRepository = $this->repositoryRepository->findOneTypo3OrgRepository();
     if (is_null($mainRepository) === TRUE) {
         $value = $GLOBALS['LANG']->sL('LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:report.status.mainRepository.notFound.value');
         $message = $GLOBALS['LANG']->sL('LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:report.status.mainRepository.notFound.message');
         $severity = \TYPO3\CMS\Reports\Status::ERROR;
     } elseif ($mainRepository->getLastUpdate()->getTimestamp() < $GLOBALS['EXEC_TIME'] - 24 * 60 * 60 * 7) {
         $value = $GLOBALS['LANG']->sL('LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:report.status.mainRepository.notUpToDate.value');
         $message = $GLOBALS['LANG']->sL('LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:report.status.mainRepository.notUpToDate.message');
         $severity = \TYPO3\CMS\Reports\Status::NOTICE;
     } else {
         $value = $GLOBALS['LANG']->sL('LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:report.status.mainRepository.upToDate.value');
         $message = '';
         $severity = \TYPO3\CMS\Reports\Status::OK;
     }
     /** @var $status \TYPO3\CMS\Reports\Status */
     $status = $this->objectManager->get('TYPO3\\CMS\\Reports\\Status', $GLOBALS['LANG']->sL('LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:report.status.mainRepository.title'), $value, $message, $severity);
     return $status;
 }
Example #12
0
 /**
  * Update extension list from TER
  *
  * @param bool $forceUpdateCheck
  * @return void
  */
 public function updateExtensionListFromTerAction($forceUpdateCheck = false)
 {
     $updated = false;
     $errorMessage = '';
     if ($this->extensionRepository->countAll() === 0 || $forceUpdateCheck) {
         try {
             $updated = $this->repositoryHelper->updateExtList();
         } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
             $errorMessage = $e->getMessage();
         }
     }
     /** @var $repository \TYPO3\CMS\Extensionmanager\Domain\Model\Repository */
     $repository = $this->repositoryRepository->findByUid((int) $this->settings['repositoryUid']);
     $timeFormat = $this->getLanguageService()->sL('LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:extensionList.updateFromTer.lastUpdate.fullTimeFormat');
     $lastUpdateTime = $repository->getLastUpdate();
     if (null === $lastUpdateTime) {
         $lastUpdatedSince = $this->getLanguageService()->sL('LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:extensionList.updateFromTer.never');
         $lastUpdateTime = date($timeFormat);
     } else {
         $lastUpdatedSince = \TYPO3\CMS\Backend\Utility\BackendUtility::calcAge(time() - $lastUpdateTime->format('U'), $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears'));
         $lastUpdateTime = $lastUpdateTime->format($timeFormat);
     }
     $this->view->assign('value', ['updated' => $updated, 'lastUpdateTime' => $lastUpdateTime, 'timeSinceLastUpdate' => $lastUpdatedSince, 'errorMessage' => $errorMessage]);
 }