/** * @test */ public function setCacheDirectoryAllowsToSetTheCurrentCacheDirectory() { $mockCache = $this->getMock('TYPO3\\Flow\\Cache\\Frontend\\AbstractFrontend', array(), array(), '', FALSE); $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('SomeCache')); $mockEnvironment = $this->getMock('TYPO3\\Flow\\Utility\\Environment', array(), array(), '', FALSE); $mockEnvironment->expects($this->any())->method('getPathToTemporaryDirectory')->will($this->returnValue('vfs://Foo/')); $mockEnvironment->expects($this->any())->method('getMaximumPathLength')->will($this->returnValue(1024)); // We need to create the directory here because vfs doesn't support touch() which is used by // createDirectoryRecursively() in the setCache method. mkdir('vfs://Foo/Cache'); mkdir('vfs://Foo/OtherDirectory'); $context = new ApplicationContext('Testing'); $backend = new FileBackend($context, array('cacheDirectory' => 'vfs://Foo/OtherDirectory')); $backend->injectEnvironment($mockEnvironment); $backend->setCache($mockCache); $this->assertEquals('vfs://Foo/OtherDirectory/', $backend->getCacheDirectory()); }
/** * @test */ public function setCacheDirectoryAllowsToSetTheCurrentCacheDirectory() { $mockCache = $this->getMockBuilder(\TYPO3\Flow\Cache\Frontend\AbstractFrontend::class)->disableOriginalConstructor()->getMock(); $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('SomeCache')); $mockEnvironment = $this->getMockBuilder(\TYPO3\Flow\Utility\Environment::class)->disableOriginalConstructor()->getMock(); $mockEnvironment->expects($this->any())->method('getPathToTemporaryDirectory')->will($this->returnValue('vfs://Foo/')); $mockEnvironment->expects($this->any())->method('getMaximumPathLength')->will($this->returnValue(1024)); $mockCacheManager = $this->getMockBuilder(\TYPO3\Flow\Cache\CacheManager::class)->disableOriginalConstructor()->getMock(); $mockCacheManager->expects($this->any())->method('isCachePersistent')->will($this->returnValue(false)); // We need to create the directory here because vfs doesn't support touch() which is used by // createDirectoryRecursively() in the setCache method. mkdir('vfs://Foo/Cache'); mkdir('vfs://Foo/OtherDirectory'); $context = new ApplicationContext('Testing'); $backend = new FileBackend($context, array('cacheDirectory' => 'vfs://Foo/OtherDirectory')); $backend->injectCacheManager($mockCacheManager); $backend->injectEnvironment($mockEnvironment); $backend->setCache($mockCache); $this->assertEquals('vfs://Foo/OtherDirectory/', $backend->getCacheDirectory()); }