diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-04-26 23:54:11 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-04-26 23:54:11 +0200 |
commit | aff5fe68b31c3663be2a114666650d2f8723a22b (patch) | |
tree | c5cf285d2f360ef4e44387d996dc89b6476b4d46 /tests | |
parent | b841a477c6b96a13ea061df3fc622c3067514bf2 (diff) | |
download | nextcloud-server-aff5fe68b31c3663be2a114666650d2f8723a22b.tar.gz nextcloud-server-aff5fe68b31c3663be2a114666650d2f8723a22b.zip |
use SystemConfig, less dependencies, and not publicly needed
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Log/FileTest.php | 20 | ||||
-rw-r--r-- | tests/lib/Log/LogFactoryTest.php | 25 |
2 files changed, 20 insertions, 25 deletions
diff --git a/tests/lib/Log/FileTest.php b/tests/lib/Log/FileTest.php index 0c50c6c08ba..d5e550a7e8d 100644 --- a/tests/lib/Log/FileTest.php +++ b/tests/lib/Log/FileTest.php @@ -36,24 +36,24 @@ class FileTest extends TestCase protected function setUp() { parent::setUp(); - $config = \OC::$server->getConfig(); - $this->restore_logfile = $config->getSystemValue("logfile"); - $this->restore_logdateformat = $config->getSystemValue('logdateformat'); + $config = \OC::$server->getSystemConfig(); + $this->restore_logfile = $config->getValue("logfile"); + $this->restore_logdateformat = $config->getValue('logdateformat'); - $config->setSystemValue("logfile", $config->getSystemValue('datadirectory') . "/logtest"); - $this->logFile = new File($config->getSystemValue('datadirectory') . '/logtest', '', $config); + $config->setValue("logfile", $config->getValue('datadirectory') . "/logtest.log"); + $this->logFile = new File($config->getValue('datadirectory') . '/logtest.log', '', $config); } protected function tearDown() { - $config = \OC::$server->getConfig(); + $config = \OC::$server->getSystemConfig(); if (isset($this->restore_logfile)) { - $config->getSystemValue("logfile", $this->restore_logfile); + $config->getValue("logfile", $this->restore_logfile); } else { - $config->deleteSystemValue("logfile"); + $config->deleteValue("logfile"); } if (isset($this->restore_logdateformat)) { - $config->getSystemValue("logdateformat", $this->restore_logdateformat); + $config->getValue("logdateformat", $this->restore_logdateformat); } else { - $config->deleteSystemValue("logdateformat"); + $config->deleteValue("logdateformat"); } $this->logFile = new File($this->restore_logfile, '', $config); parent::tearDown(); diff --git a/tests/lib/Log/LogFactoryTest.php b/tests/lib/Log/LogFactoryTest.php index 8c1b7f08c74..08139f54df4 100644 --- a/tests/lib/Log/LogFactoryTest.php +++ b/tests/lib/Log/LogFactoryTest.php @@ -26,6 +26,7 @@ use OC\Log\Errorlog; use OC\Log\File; use OC\Log\LogFactory; use OC\Log\Syslog; +use OC\SystemConfig; use OCP\IConfig; use OCP\IServerContainer; use Test\TestCase; @@ -42,12 +43,16 @@ class LogFactoryTest extends TestCase { /** @var LogFactory */ protected $factory; + /** @var SystemConfig|\PHPUnit_Framework_MockObject_MockObject */ + protected $systemConfig; + protected function setUp() { parent::setUp(); $this->c = $this->createMock(IServerContainer::class); + $this->systemConfig = $this->createMock(SystemConfig::class); - $this->factory = new LogFactory($this->c); + $this->factory = new LogFactory($this->c, $this->systemConfig); } public function fileTypeProvider(): array { @@ -76,16 +81,11 @@ class LogFactoryTest extends TestCase { $datadir = \OC::$SERVERROOT.'/data'; $defaultLog = $datadir . '/nextcloud.log'; - $config = $this->createMock(IConfig::class); - $config->expects($this->exactly(2)) - ->method('getSystemValue') + $this->systemConfig->expects($this->exactly(2)) + ->method('getValue') ->withConsecutive(['datadirectory', $datadir], ['logfile', $defaultLog]) ->willReturnOnConsecutiveCalls($datadir, $defaultLog); - $this->c->expects($this->any()) - ->method('getConfig') - ->willReturn($config); - $log = $this->factory->get($type); $this->assertInstanceOf(File::class, $log); } @@ -111,16 +111,11 @@ class LogFactoryTest extends TestCase { $datadir = \OC::$SERVERROOT.'/data'; $defaultLog = $datadir . '/nextcloud.log'; - $config = $this->createMock(IConfig::class); - $config->expects($this->exactly(2)) - ->method('getSystemValue') + $this->systemConfig->expects($this->exactly(2)) + ->method('getValue') ->withConsecutive(['datadirectory', $datadir], ['logfile', $defaultLog]) ->willReturnOnConsecutiveCalls($datadir, $path); - $this->c->expects($this->any()) - ->method('getConfig') - ->willReturn($config); - $log = $this->factory->get('file'); $this->assertInstanceOf(File::class, $log); $this->assertSame($expected, $log->getLogFilePath()); |