Example #1
0
	/**
	 * Sets up this test case
	 *
	 */
	protected function setUp() {
		vfsStream::setup('Test');
		$mockBootstrap = $this->getMock(\TYPO3\CMS\Core\Core\Bootstrap::class, array(), array(), '', FALSE);
		$mockCache = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\PhpFrontend::class, array('has', 'set', 'getBackend'), array(), '', FALSE);
		$mockCacheBackend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::class, array('has', 'set', 'getBackend'), array(), '', FALSE);
		$mockCache->expects($this->any())->method('has')->will($this->returnValue(FALSE));
		$mockCache->expects($this->any())->method('set')->will($this->returnValue(TRUE));
		$mockCache->expects($this->any())->method('getBackend')->will($this->returnValue($mockCacheBackend));
		$mockCacheBackend->expects($this->any())->method('getCacheDirectory')->will($this->returnValue('vfs://Test/Cache'));
		$this->packageManager = $this->getAccessibleMock(\TYPO3\CMS\Core\Package\PackageManager::class, array('sortAndSavePackageStates', 'sortAvailablePackagesByDependencies', 'registerAutoloadInformationInClassLoader'));

		mkdir('vfs://Test/Packages/Application', 0700, TRUE);
		mkdir('vfs://Test/Configuration');
		file_put_contents('vfs://Test/Configuration/PackageStates.php', "<?php return array ('packages' => array(), 'version' => 4); ");

		$composerNameToPackageKeyMap = array(
			'typo3/flow' => 'TYPO3.Flow'
		);

		$this->packageManager->injectCoreCache($mockCache);
		$this->inject($this->packageManager, 'composerNameToPackageKeyMap', $composerNameToPackageKeyMap);
		$this->packageManager->_set('packagesBasePath', 'vfs://Test/Packages/');
		$this->packageManager->_set('packageStatesPathAndFilename', 'vfs://Test/Configuration/PackageStates.php');
		$this->packageManager->initialize($mockBootstrap);
	}
 /**
  * Warm up essential caches such as class and core caches
  *
  * @param bool $triggerRequire
  * @return bool
  */
 public function warmupEssentialCaches($triggerRequire = FALSE)
 {
     try {
         $this->cacheManager->getCache('cache_classes');
     } catch (NoSuchCacheException $e) {
         $this->logger->warning('Warmup skipped due to lack of classes cache');
         return FALSE;
     }
     // TODO: This currently only builds the classes cache! Find a way to build other system caches as well (like reflection caches, datamap caches …)
     // package namespace and aliases caches are implicitly built in extended bootstrap before we reach this point
     $phpParser = new PhpParser();
     foreach ($this->packageManager->getActivePackages() as $package) {
         $classFiles = GeneralUtility::getAllFilesAndFoldersInPath(array(), $package->getClassesPath(), 'php');
         foreach ($classFiles as $classFile) {
             try {
                 $parsedResult = $phpParser->parseClassFile($classFile);
                 $this->writeCacheEntryForClass($parsedResult->getFullyQualifiedClassName(), $classFile);
             } catch (ParsingException $e) {
                 $this->logger->warning('Class file "' . PathUtility::stripPathSitePrefix($classFile) . '" does not contain a class definition. Skipping …');
             }
         }
     }
     $this->packageManager->injectCoreCache($this->cacheManager->getCache('cache_core'));
     $this->packageManager->populatePackageCache();
     return TRUE;
 }
Example #3
0
 /**
  * Sets up this test case
  *
  */
 protected function setUp()
 {
     vfsStream::setup('Test');
     /** @var PhpFrontend|\PHPUnit_Framework_MockObject_MockObject $mockCache */
     $mockCache = $this->getMock(PhpFrontend::class, array('has', 'set', 'getBackend'), array(), '', false);
     $mockCacheBackend = $this->getMock(SimpleFileBackend::class, array('has', 'set', 'getBackend'), array(), '', false);
     $mockCache->expects($this->any())->method('has')->will($this->returnValue(false));
     $mockCache->expects($this->any())->method('set')->will($this->returnValue(true));
     $mockCache->expects($this->any())->method('getBackend')->will($this->returnValue($mockCacheBackend));
     $mockCacheBackend->expects($this->any())->method('getCacheDirectory')->will($this->returnValue('vfs://Test/Cache'));
     $this->packageManager = $this->getAccessibleMock(PackageManager::class, array('sortAndSavePackageStates', 'sortAvailablePackagesByDependencies', 'registerTransientClassLoadingInformationForPackage'));
     mkdir('vfs://Test/Packages/Application', 0700, true);
     mkdir('vfs://Test/Configuration');
     file_put_contents('vfs://Test/Configuration/PackageStates.php', "<?php return array ('packages' => array(), 'version' => 4); ");
     $composerNameToPackageKeyMap = array('typo3/flow' => 'TYPO3.Flow');
     $this->packageManager->injectCoreCache($mockCache);
     $this->inject($this->packageManager, 'composerNameToPackageKeyMap', $composerNameToPackageKeyMap);
     $this->packageManager->_set('packagesBasePath', 'vfs://Test/Packages/');
     $this->packageManager->_set('packageStatesPathAndFilename', 'vfs://Test/Configuration/PackageStates.php');
 }