/**
  * @return ReflectionServiceInterface
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $typo3Refl = new ReflectionService();
     // Create and inject a bunch of dependencies.
     $typo3Context = new ApplicationContext($this->getAppEnv());
     $typo3Env = new Environment($typo3Context);
     $typo3Refl->injectEnvironment($typo3Env);
     //$typo3CacheBackend = new NullBackend($typo3Context);
     $typo3CacheBackend = new FileBackend($typo3Context);
     $typo3CacheBackend->setCacheDirectory($this->findFlowRootPath() . '/cache');
     $typo3CacheBackend->injectEnvironment($typo3Env);
     $typo3Cache = new VariableFrontend('reflection', $typo3CacheBackend);
     $typo3Refl->setClassSchemataRuntimeCache($typo3Cache);
     $typo3Refl->setReflectionDataCompiletimeCache($typo3Cache);
     $typo3Refl->setReflectionDataRuntimeCache($typo3Cache);
     defined('FLOW_PATH_ROOT') or define('FLOW_PATH_ROOT', $this->findFlowRootPath() . DIRECTORY_SEPARATOR);
     defined('FLOW_PATH_PACKAGES') or define('FLOW_PATH_PACKAGES', $this->findFlowPkgPath() . DIRECTORY_SEPARATOR);
     $typo3PackageManager = new PackageManager();
     $typo3Refl->injectPackageManager($typo3PackageManager);
     // TODO load our custom annotations classes.
     $typo3ClassLoader = new ClassLoader($typo3Context);
     $typo3Refl->injectClassLoader($typo3ClassLoader);
     $typo3Logger = new Logger();
     $typo3Refl->injectSystemLogger($typo3Logger);
     // Inject settings.
     // TODO get settings from config via service manager
     $typo3Settings = array('reflection' => array('ignoredTags' => array('api', 'package', 'subpackage', 'license', 'copyright', 'author', 'const', 'see', 'todo', 'scope', 'fixme', 'test', 'expectedException', 'expectedExceptionCode', 'depends', 'dataProvider', 'group', 'codeCoverageIgnore'), 'logIncorrectDocCommentHints' => true));
     $typo3Refl->injectSettings($typo3Settings);
     return $typo3Refl;
 }
Example #2
0
 /**
  * Creates a cache for testing
  *
  * @param string $name
  * @return VariableFrontend
  */
 protected function createCache($name)
 {
     $mockEnvironment = $this->getMock('TYPO3\\Flow\\Utility\\Environment', array(), array(), '', FALSE);
     $mockEnvironment->expects($this->any())->method('getMaximumPathLength')->will($this->returnValue(255));
     $mockEnvironment->expects($this->any())->method('getPathToTemporaryDirectory')->will($this->returnValue('vfs://Foo/'));
     $backend = new FileBackend(new ApplicationContext('Testing'));
     $backend->injectEnvironment($mockEnvironment);
     $cache = new VariableFrontend($name, $backend);
     $cache->flush();
     return $cache;
 }
Example #3
0
 /**
  * @test
  */
 public function backendAllowsForIteratingOverEntries()
 {
     $mockEnvironment = $this->getMock('TYPO3\\Flow\\Utility\\Environment', array(), array(), '', FALSE);
     $mockEnvironment->expects($this->any())->method('getMaximumPathLength')->will($this->returnValue(255));
     $mockEnvironment->expects($this->any())->method('getPathToTemporaryDirectory')->will($this->returnValue('vfs://Foo/'));
     $mockCacheManager = $this->getMock('TYPO3\\Flow\\Cache\\CacheManager', array(), array(), '', FALSE);
     $mockCacheManager->expects($this->any())->method('isCachePersistent')->will($this->returnValue(FALSE));
     $backend = new FileBackend(new ApplicationContext('Testing'));
     $backend->injectCacheManager($mockCacheManager);
     $backend->injectEnvironment($mockEnvironment);
     $cache = new VariableFrontend('UnitTestCache', $backend);
     $backend->setCache($cache);
     for ($i = 0; $i < 100; $i++) {
         $entryIdentifier = sprintf('entry-%s', $i);
         $data = 'some data ' . $i;
         $cache->set($entryIdentifier, $data);
     }
     $entries = array();
     foreach ($cache->getIterator() as $entryIdentifier => $data) {
         $entries[$entryIdentifier] = $data;
     }
     natsort($entries);
     $i = 0;
     foreach ($entries as $entryIdentifier => $data) {
         $this->assertEquals(sprintf('entry-%s', $i), $entryIdentifier);
         $this->assertEquals('some data ' . $i, $data);
         $i++;
     }
     $this->assertEquals(100, $i);
 }
 /**
  * Creates a cache for testing
  *
  * @param string $name
  * @return VariableFrontend
  */
 protected function createCache($name)
 {
     $mockEnvironment = $this->getMock(\TYPO3\Flow\Utility\Environment::class, array(), array(), '', FALSE);
     $mockEnvironment->expects($this->any())->method('getMaximumPathLength')->will($this->returnValue(255));
     $mockEnvironment->expects($this->any())->method('getPathToTemporaryDirectory')->will($this->returnValue('vfs://Foo/'));
     $mockCacheManager = $this->getMock(\TYPO3\Flow\Cache\CacheManager::class, array(), array(), '', FALSE);
     $mockCacheManager->expects($this->any())->method('isCachePersistent')->will($this->returnValue(FALSE));
     $backend = new FileBackend(new ApplicationContext('Testing'));
     $backend->injectCacheManager($mockCacheManager);
     $backend->injectEnvironment($mockEnvironment);
     $cache = new VariableFrontend($name, $backend);
     $cache->initializeObject();
     $cache->flush();
     return $cache;
 }