aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Log/LogFactoryTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Log/LogFactoryTest.php')
-rw-r--r--tests/lib/Log/LogFactoryTest.php25
1 files changed, 10 insertions, 15 deletions
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());