/** * @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)); }
/** * 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\\FLOW3\\Resource\\Streams\\ResourceStreamWrapper { static public function getScheme() { return \'' . $wrapperSchemeName . '\'; } }'); $mockStreamWrapperAdapter = new $wrapperClassName(); $mockReflectionService = $this->getMock('TYPO3\\FLOW3\\Reflection\\ReflectionService'); $mockReflectionService->expects($this->once())->method('getAllImplementationClassNamesForInterface')->with('TYPO3\\FLOW3\\Resource\\Streams\\StreamWrapperInterface')->will($this->returnValue(array(get_class($mockStreamWrapperAdapter)))); $resourceManager = new \TYPO3\FLOW3\Resource\ResourceManager(); $resourceManager->injectReflectionService($mockReflectionService); $resourceManager->initialize(); $this->assertContains(get_class($mockStreamWrapperAdapter), \TYPO3\FLOW3\Resource\Streams\StreamWrapperAdapter::getRegisteredStreamWrappers()); $this->assertArrayHasKey($wrapperSchemeName, \TYPO3\FLOW3\Resource\Streams\StreamWrapperAdapter::getRegisteredStreamWrappers()); $this->assertContains($wrapperSchemeName, stream_get_wrappers()); stream_wrapper_unregister($wrapperSchemeName); }
/** * Check for implementations of TYPO3\FLOW3\Resource\Streams\StreamWrapperInterface and * register them. * * @return void */ public function initialize() { $streamWrapperClassNames = $this->reflectionService->getAllImplementationClassNamesForInterface('TYPO3\\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, '\\TYPO3\\FLOW3\\Resource\\Streams\\StreamWrapperAdapter'); \TYPO3\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/'; \TYPO3\FLOW3\Utility\Files::createDirectoryRecursively($this->persistentResourcesStorageBaseUri); $this->importedResources = new \SplObjectStorage(); }