-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathAppConfigTest.php
More file actions
102 lines (79 loc) · 3.08 KB
/
AppConfigTest.php
File metadata and controls
102 lines (79 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Richdocuments;
use OCA\Richdocuments\AppConfig;
use OCP\App\IAppManager;
use OCP\AppFramework\Services\IAppConfig;
use OCP\GlobalScale\IConfig as IGlobalScaleConfig;
use OCP\IConfig;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class AppConfigTest extends TestCase {
/** @var IConfig|MockObject */
private $config;
/** @var IAppConfig */
private $appConfig;
public function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
$this->appManager = $this->createMock(IAppManager::class);
$this->appConfig = $this->createMock(IAppConfig::class);
$this->gsConfig = $this->createMock(IGlobalScaleConfig::class);
$this->appConfig = new AppConfig($this->config, $this->appConfig, $this->appManager, $this->gsConfig);
}
public function testGetAppValueArrayWithValues() {
$this->config->expects($this->once())
->method('getAppValue')
->with('files', 'watermark_allGroupsList', [])
->willReturn('1,2,3');
$result = $this->appConfig->getAppValueArray('watermark_allGroupsList');
$this->assertSame(['1', '2', '3'], $result);
}
public function testGetAppValueArrayWithSingleValue() {
$this->config->expects($this->once())
->method('getAppValue')
->with('files', 'watermark_allTagsList', [])
->willReturn('1');
$result = $this->appConfig->getAppValueArray('watermark_allTagsList');
$this->assertSame(['1'], $result);
}
public function testGetAppValueArrayWithNoneValue() {
$this->config->expects($this->once())
->method('getAppValue')
->with('files', 'watermark_allTagsList', [])
->willReturn('');
$result = $this->appConfig->getAppValueArray('watermark_allTagsList');
$this->assertSame([], $result);
}
public function testGetPreviewConversionTimeoutReturnsDefault(): void {
$this->config->expects($this->once())
->method('getAppValue')
->with('richdocuments', 'preview_conversion_timeout', 5)
->willReturn(5);
$this->assertSame(5, $this->appConfig->getPreviewConversionTimeout());
}
public function testGetPreviewConversionTimeoutReturnsConfiguredValue(): void {
$this->config->expects($this->once())
->method('getAppValue')
->with('richdocuments', 'preview_conversion_timeout', 5)
->willReturn(30);
$this->assertSame(30, $this->appConfig->getPreviewConversionTimeout());
}
public function testGetPreviewConversionMaxFileSizeReturnsDefault(): void {
$this->config->expects($this->once())
->method('getAppValue')
->with('richdocuments', 'preview_conversion_max_filesize', 104857600)
->willReturn(104857600);
$this->assertSame(104857600, $this->appConfig->getPreviewConversionMaxFileSize());
}
public function testGetPreviewConversionMaxFileSizeReturnsConfiguredValue(): void {
$this->config->expects($this->once())
->method('getAppValue')
->with('richdocuments', 'preview_conversion_max_filesize', 104857600)
->willReturn(52428800);
$this->assertSame(52428800, $this->appConfig->getPreviewConversionMaxFileSize());
}
}