Browse Source
Cover method with unit test
Signed-off-by: Vitor Mattos <vitor@php.rio>
pull/8492/head
Vitor Mattos
3 years ago
No known key found for this signature in database
GPG Key ID: B7AB4B76A7CA7318
2 changed files with
38 additions and
7 deletions
-
lib/Config.php
-
tests/php/ConfigTest.php
|
|
|
@ -44,6 +44,12 @@ class Config { |
|
|
|
public const SIGNALING_TICKET_V1 = 1; |
|
|
|
public const SIGNALING_TICKET_V2 = 2; |
|
|
|
|
|
|
|
public const DEFAULT_ALLOWED_RECORDING_FORMATS = [ |
|
|
|
'audio/ogg' => ['ogg'], |
|
|
|
'video/ogg' => ['ogv'], |
|
|
|
'video/x-matroska' => ['mkv'], |
|
|
|
]; |
|
|
|
|
|
|
|
protected IConfig $config; |
|
|
|
protected ITimeFactory $timeFactory; |
|
|
|
private IGroupManager $groupManager; |
|
|
|
@ -158,14 +164,16 @@ class Config { |
|
|
|
} |
|
|
|
|
|
|
|
public function getRecordingAllowedMimes(): array { |
|
|
|
$defaultMimes = [ |
|
|
|
'audio/ogg' => ['ogg'], |
|
|
|
'video/ogg' => ['ogv'], |
|
|
|
'video/x-matroska' => ['mkv'], |
|
|
|
]; |
|
|
|
$allowedMimes = $this->config->getAppValue('spreed', 'allowed_recording_mimes', json_encode($defaultMimes)); |
|
|
|
$allowedMimes = $this->config->getAppValue( |
|
|
|
'spreed', |
|
|
|
'allowed_recording_mimes', |
|
|
|
json_encode(self::DEFAULT_ALLOWED_RECORDING_FORMATS) |
|
|
|
); |
|
|
|
$allowedMimes = json_decode($allowedMimes, true); |
|
|
|
return is_array($allowedMimes) ? $allowedMimes : $defaultMimes; |
|
|
|
if (is_array($allowedMimes) && count($allowedMimes)) { |
|
|
|
return $allowedMimes; |
|
|
|
} |
|
|
|
return self::DEFAULT_ALLOWED_RECORDING_FORMATS; |
|
|
|
} |
|
|
|
|
|
|
|
public function isDisabledForUser(IUser $user): bool { |
|
|
|
|
|
|
|
@ -454,4 +454,27 @@ class ConfigTest extends TestCase { |
|
|
|
$this->assertEquals($now, $decoded->iat); |
|
|
|
$this->assertEquals('https://domain.invalid/nextcloud', $decoded->iss); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @dataProvider dataGetRecordingAllowedMimes |
|
|
|
*/ |
|
|
|
public function testGetRecordingAllowedMimes($settings, $expected): void { |
|
|
|
/** @var MockObject|IConfig $config */ |
|
|
|
$config = $this->createMock(IConfig::class); |
|
|
|
$config |
|
|
|
->expects($this->once()) |
|
|
|
->method('getAppValue') |
|
|
|
->willReturn(json_encode($settings)); |
|
|
|
$helper = $this->createConfig($config); |
|
|
|
$actual = $helper->getRecordingAllowedMimes(); |
|
|
|
$this->assertEquals($expected, $actual); |
|
|
|
} |
|
|
|
|
|
|
|
public function dataGetRecordingAllowedMimes(): array { |
|
|
|
return [ |
|
|
|
['', Config::DEFAULT_ALLOWED_RECORDING_FORMATS], |
|
|
|
[[], Config::DEFAULT_ALLOWED_RECORDING_FORMATS], |
|
|
|
[['audio/ogg' => ['ogg']], ['audio/ogg' => ['ogg']]], |
|
|
|
]; |
|
|
|
} |
|
|
|
} |