Skip to content

Commit

Permalink
Unit test getting temp dir from config
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin McCorkell committed Aug 30, 2015
1 parent a0dfaf9 commit 5a1619d
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/lib/tempmanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ protected function getManager($logger = null, $config = null) {
$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) {
Expand Down Expand Up @@ -195,4 +198,19 @@ public function testBuildFileNameWithSuffixPathTraversal() {
$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());
}
}

0 comments on commit 5a1619d

Please sign in to comment.