diff options
author | Robin McCorkell <rmccorkell@owncloud.com> | 2015-08-29 17:36:21 +0100 |
---|---|---|
committer | Robin McCorkell <rmccorkell@owncloud.com> | 2015-08-30 23:30:56 +0100 |
commit | a0dfaf9be36d35192cb797489740ec1008258e64 (patch) | |
tree | 0ac58fb868064b16d06689b073952f5a2d26c1a8 /tests/lib | |
parent | acae208f2fc6b80fbf9af615661e3905f9cab0a0 (diff) | |
download | nextcloud-server-a0dfaf9be36d35192cb797489740ec1008258e64.tar.gz nextcloud-server-a0dfaf9be36d35192cb797489740ec1008258e64.zip |
Clean up TempManager to follow code guidelines
tmpBaseDir can be overridden for unit testing purposes
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/tempmanager.php | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/tests/lib/tempmanager.php b/tests/lib/tempmanager.php index 89625ac62f2..04e14c335bd 100644 --- a/tests/lib/tempmanager.php +++ b/tests/lib/tempmanager.php @@ -23,10 +23,12 @@ class NullLogger extends Log { class TempManager extends \Test\TestCase { + protected $baseDir = null; + protected function setUp() { parent::setUp(); - $this->baseDir = $this->getManager()->t_get_temp_dir() . $this->getUniqueID('/oc_tmp_test'); + $this->baseDir = $this->getManager()->getTempBaseDir() . $this->getUniqueID('/oc_tmp_test'); if (!is_dir($this->baseDir)) { mkdir($this->baseDir); } @@ -34,18 +36,27 @@ class TempManager extends \Test\TestCase { protected function tearDown() { \OC_Helper::rmdirr($this->baseDir); + $this->baseDir = null; parent::tearDown(); } /** * @param \OCP\ILogger $logger + * @param \OCP\IConfig $config * @return \OC\TempManager */ - protected function getManager($logger = null) { + protected function getManager($logger = null, $config = null) { if (!$logger) { $logger = new NullLogger(); } - return new \OC\TempManager($logger); + if (!$config) { + $config = \OC::$server->getConfig(); + } + $manager = new \OC\TempManager($logger, $config); + if ($this->baseDir) { + $manager->overrideTempBaseDir($this->baseDir); + } + return $manager; } public function testGetFile() { |