Unit test getting temp dir from config

This commit is contained in:
Robin McCorkell 2015-08-29 17:42:20 +01:00
parent a0dfaf9be3
commit 5a1619d80d
1 changed files with 19 additions and 1 deletions

View File

@ -50,7 +50,10 @@ class TempManager extends \Test\TestCase {
$logger = new NullLogger();
}
if (!$config) {
$config = \OC::$server->getConfig();
$config = $this->getMock('\OCP\IConfig');
$config->method('getSystemValue')
->with('tempdirectory', null)
->willReturn('/tmp');
}
$manager = new \OC\TempManager($logger, $config);
if ($this->baseDir) {
@ -195,4 +198,19 @@ class TempManager extends \Test\TestCase {
$this->assertStringEndsNotWith('./Traversal\\../FileName', $tmpManager);
$this->assertStringEndsWith('.Traversal..FileName', $tmpManager);
}
public function testGetTempBaseDirFromConfig() {
$dir = $this->getManager()->getTemporaryFolder();
$config = $this->getMock('\OCP\IConfig');
$config->expects($this->once())
->method('getSystemValue')
->with('tempdirectory', null)
->willReturn($dir);
$this->baseDir = null; // prevent override
$tmpManager = $this->getManager(null, $config);
$this->assertEquals($dir, $tmpManager->getTempBaseDir());
}
}