/** * @test */ public function checkAutoloaderSetsNamespacedClassnamesInExtAutoloadAreWrittenToCache() { $extKey = $this->createFakeExtension(); $extPath = PATH_site . 'typo3temp/' . $extKey . '/'; $pathSegment = 'Foo' . uniqid(); $fileName = 'Bar' . uniqid(); $autoloaderFile = $extPath . 'ext_autoload.php'; // A case sensitive key (FooBar) in ext_autoload file $namespacedClass = '\\Tx\\' . $extKey . '\\' . $pathSegment . '\\' . $fileName; file_put_contents($autoloaderFile, '<?php' . LF . 'return array(\'' . $namespacedClass . '\' => \'EXT:someExt/Classes/Foo/bar.php\');' . LF . '?>'); // Inject a dummy for the core_phpcode cache to force the autoloader // to re calculate the registry $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag', 'requireOnce'), array(), '', FALSE); $GLOBALS['typo3CacheManager'] = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('getCache')); $GLOBALS['typo3CacheManager']->expects($this->any())->method('getCache')->will($this->returnValue($mockCache)); // Expect that the lower case version of the class name is written to cache $mockCache->expects($this->at(2))->method('set')->with($this->anything(), $this->stringContains(strtolower($namespacedClass), FALSE)); // Re-initialize autoloader registry to force it to recognize the new extension \TYPO3\CMS\Core\Autoloader::unregisterAutoloader(); \TYPO3\CMS\Core\Autoloader::registerAutoloader(); \TYPO3\CMS\Core\Autoloader::unregisterAutoloader(); }
/** * Returns the class name for a new instance, taking into account the * class-extension API. * * @param string $className Base class name to evaluate * @return string Final class name to instantiate with "new [classname] */ protected static function getClassName($className) { if (class_exists($className)) { while (\TYPO3\CMS\Core\Autoloader::getClassPathByRegistryLookup('ux_' . $className) !== NULL) { $className = 'ux_' . $className; } } return \TYPO3\CMS\Core\Autoloader::getClassNameForAlias($className); }
/** * Things that should be performed to shut down the framework. * This method is called in all important scripts for a clean * shut down of the system. * * @return \TYPO3\CMS\Core\Core\Bootstrap */ public function shutdown() { \TYPO3\CMS\Core\Autoloader::unregisterAutoloader(); return $this; }