/**
  * @test
  */
 public function url_statTest()
 {
     $path = 'mockScheme1://foo/bar';
     $flags = STREAM_URL_STAT_LINK;
     $this->streamWrapperAdapter->expects($this->once())->method('createStreamWrapper')->with($path);
     $this->mockStreamWrapper->expects($this->once())->method('pathStat')->with($path, $flags)->will($this->returnValue(true));
     $this->assertTrue($this->streamWrapperAdapter->url_stat($path, $flags));
 }
コード例 #2
0
 /**
  * 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 manager being set to a mocked one,
  * be careful...
  *
  * @test
  */
 public function initializeRegistersFoundStreamWrappers()
 {
     $wrapperClassName = 'MockWrapper' . md5(uniqid(mt_rand(), TRUE));
     $wrapperSchemeName = $wrapperClassName . 'scheme';
     eval('class ' . $wrapperClassName . ' extends \\TYPO3\\Flow\\Resource\\Streams\\ResourceStreamWrapper { static public function getScheme() { return \'' . $wrapperSchemeName . '\'; } }');
     $mockStreamWrapperAdapter = new $wrapperClassName();
     $mockReflectionService = $this->getMock('TYPO3\\Flow\\Reflection\\ReflectionService');
     $mockReflectionService->expects($this->once())->method('getAllImplementationClassNamesForInterface')->with('TYPO3\\Flow\\Resource\\Streams\\StreamWrapperInterface')->will($this->returnValue(array(get_class($mockStreamWrapperAdapter))));
     $mockObjectManager = $this->getMock('TYPO3\\Flow\\Object\\ObjectManagerInterface');
     $mockObjectManager->expects($this->any())->method('get')->with('TYPO3\\Flow\\Reflection\\ReflectionService')->will($this->returnValue($mockReflectionService));
     $resourceManager = new \TYPO3\Flow\Resource\ResourceManager();
     $this->inject($resourceManager, 'objectManager', $mockObjectManager);
     $resourceManager->initialize();
     $this->assertContains(get_class($mockStreamWrapperAdapter), \TYPO3\Flow\Resource\Streams\StreamWrapperAdapter::getRegisteredStreamWrappers());
     $this->assertArrayHasKey($wrapperSchemeName, \TYPO3\Flow\Resource\Streams\StreamWrapperAdapter::getRegisteredStreamWrappers());
     $this->assertContains($wrapperSchemeName, stream_get_wrappers());
     stream_wrapper_unregister($wrapperSchemeName);
 }
コード例 #3
0
 /**
  * Registers a Stream Wrapper Adapter for the resource:// scheme.
  *
  * @return void
  */
 protected function initializeStreamWrapper()
 {
     $streamWrapperClassNames = static::getStreamWrapperImplementationClassNames($this->objectManager);
     foreach ($streamWrapperClassNames as $streamWrapperClassName) {
         $scheme = $streamWrapperClassName::getScheme();
         if (in_array($scheme, stream_get_wrappers())) {
             stream_wrapper_unregister($scheme);
         }
         stream_wrapper_register($scheme, \TYPO3\Flow\Resource\Streams\StreamWrapperAdapter::class);
         StreamWrapperAdapter::registerStreamWrapper($scheme, $streamWrapperClassName);
     }
 }
コード例 #4
0
 /**
  * Initialize the stream wrappers.
  *
  * @param Bootstrap $bootstrap
  * @return void
  */
 public static function initializeResources(Bootstrap $bootstrap)
 {
     StreamWrapperAdapter::initializeStreamWrapper($bootstrap->getObjectManager());
 }
コード例 #5
0
 /**
  * Check for implementations of TYPO3\Flow\Resource\Streams\StreamWrapperInterface and
  * register them.
  *
  * @return void
  */
 public function initialize()
 {
     $streamWrapperClassNames = static::getStreamWrapperImplementationClassNames($this->objectManager);
     foreach ($streamWrapperClassNames as $streamWrapperClassName) {
         $scheme = $streamWrapperClassName::getScheme();
         if (in_array($scheme, stream_get_wrappers())) {
             stream_wrapper_unregister($scheme);
         }
         stream_wrapper_register($scheme, '\\TYPO3\\Flow\\Resource\\Streams\\StreamWrapperAdapter');
         \TYPO3\Flow\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 = FLOW_PATH_DATA . 'Persistent/Resources/';
     \TYPO3\Flow\Utility\Files::createDirectoryRecursively($this->persistentResourcesStorageBaseUri);
     $this->importedResources = new \SplObjectStorage();
 }