/**
  * This test indeed messes with some of the static stuff concerning our
  * StreamWrapperAdapter setup. But since the dummy stream wrapper is removed again,
  * this does not do any harm. And registering the "real" wrappers a second
  * time doesn't do harm, either.
  *
  * What is an issue is the static object factory being set to a mocked one,
  * be careful...
  *
  * @test
  * @author Karsten Dambekalns <*****@*****.**>
  */
 public function initializeRegistersFoundStreamWrappers()
 {
     $wrapperClassName = uniqid('MockWrapper');
     $wrapperSchemeName = $wrapperClassName . 'scheme';
     eval('class ' . $wrapperClassName . ' extends \\F3\\FLOW3\\Resource\\Streams\\PackageResourceStreamWrapper { static public function getScheme() { return \'' . $wrapperSchemeName . '\'; } }');
     $mockStreamWrapperAdapter = new $wrapperClassName();
     $mockObjectFactory = $this->getMock('F3\\FLOW3\\Object\\ObjectFactoryInterface');
     $mockReflectionService = $this->getMock('F3\\FLOW3\\Reflection\\ReflectionService');
     $mockReflectionService->expects($this->once())->method('getAllImplementationClassNamesForInterface')->with('F3\\FLOW3\\Resource\\Streams\\StreamWrapperInterface')->will($this->returnValue(array(get_class($mockStreamWrapperAdapter))));
     $resourceManager = new \F3\FLOW3\Resource\ResourceManager();
     $resourceManager->injectObjectFactory($mockObjectFactory);
     $resourceManager->injectReflectionService($mockReflectionService);
     $resourceManager->initialize();
     $this->assertContains(get_class($mockStreamWrapperAdapter), \F3\FLOW3\Resource\Streams\StreamWrapperAdapter::getRegisteredStreamWrappers());
     $this->assertArrayHasKey($wrapperSchemeName, \F3\FLOW3\Resource\Streams\StreamWrapperAdapter::getRegisteredStreamWrappers());
     $this->assertContains($wrapperSchemeName, stream_get_wrappers());
     stream_wrapper_unregister($wrapperSchemeName);
     // set the real object factory again...
     \F3\FLOW3\Resource\Streams\StreamWrapperAdapter::setObjectFactory($this->objectFactory);
 }
 /**
  * Check for implementations of F3\FLOW3\Resource\Streams\StreamWrapperInterface and
  * register them.
  *
  * @return void
  * @author Karsten Dambekalns <*****@*****.**>
  */
 public function initialize()
 {
     \F3\FLOW3\Resource\Streams\StreamWrapperAdapter::setObjectFactory($this->objectFactory);
     $streamWrapperClassNames = $this->reflectionService->getAllImplementationClassNamesForInterface('F3\\FLOW3\\Resource\\Streams\\StreamWrapperInterface');
     foreach ($streamWrapperClassNames as $streamWrapperClassName) {
         $scheme = $streamWrapperClassName::getScheme();
         if (in_array($scheme, stream_get_wrappers())) {
             stream_wrapper_unregister($scheme);
         }
         stream_wrapper_register($scheme, '\\F3\\FLOW3\\Resource\\Streams\\StreamWrapperAdapter');
         \F3\FLOW3\Resource\Streams\StreamWrapperAdapter::registerStreamWrapper($scheme, $streamWrapperClassName);
     }
     // For now this URI is hardcoded, but might be manageable in the future
     // if additional persistent resources storages are supported.
     $this->persistentResourcesStorageBaseUri = FLOW3_PATH_DATA . 'Persistent/Resources/';
 }