Unit test getting temp dir from config
This commit is contained in:
parent
a0dfaf9be3
commit
5a1619d80d
|
@ -50,7 +50,10 @@ class TempManager extends \Test\TestCase {
|
||||||
$logger = new NullLogger();
|
$logger = new NullLogger();
|
||||||
}
|
}
|
||||||
if (!$config) {
|
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);
|
$manager = new \OC\TempManager($logger, $config);
|
||||||
if ($this->baseDir) {
|
if ($this->baseDir) {
|
||||||
|
@ -195,4 +198,19 @@ class TempManager extends \Test\TestCase {
|
||||||
$this->assertStringEndsNotWith('./Traversal\\../FileName', $tmpManager);
|
$this->assertStringEndsNotWith('./Traversal\\../FileName', $tmpManager);
|
||||||
$this->assertStringEndsWith('.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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue