Skip to content

Commit 045dc79

Browse files
authored
Merge pull request #56626 from nextcloud/fix/fix/theming-legacy-app-config
Fix/fix/theming legacy app config
2 parents 7435125 + 561d3de commit 045dc79

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

apps/theming/lib/ThemingDefaults.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,12 +431,12 @@ public function increaseCacheBuster(): void {
431431
* @param string $value
432432
*/
433433
public function set($setting, $value): void {
434-
switch ($value) {
434+
switch ($setting) {
435435
case ConfigLexicon::CACHE_BUSTER:
436436
$this->appConfig->setAppValueInt(ConfigLexicon::CACHE_BUSTER, (int)$value);
437437
break;
438438
case ConfigLexicon::USER_THEMING_DISABLED:
439-
$value = $value === 'true' || $value === 'yes' || $value === '1';
439+
$value = in_array($value, ['1', 'true', 'yes', 'on']);
440440
$this->appConfig->setAppValueBool(ConfigLexicon::USER_THEMING_DISABLED, $value);
441441
break;
442442
default:

apps/theming/tests/ThemingDefaultsTest.php

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
namespace OCA\Theming\Tests;
99

10+
use OCA\Theming\ConfigLexicon;
1011
use OCA\Theming\ImageManager;
1112
use OCA\Theming\Service\BackgroundService;
1213
use OCA\Theming\ThemingDefaults;
@@ -728,7 +729,7 @@ public function testGetScssVariables(): void {
728729
'theming-favicon-mime' => '\'jpeg\'',
729730
'image-logoheader' => "url('custom-logoheader?v=0')",
730731
'image-favicon' => "url('custom-favicon?v=0')",
731-
'has-legal-links' => 'false'
732+
'has-legal-links' => 'false',
732733
];
733734
$this->assertEquals($expected, $this->template->getScssVariables());
734735
}
@@ -798,7 +799,7 @@ public static function dataReplaceImagePath(): array {
798799
['core', 'test.png', false],
799800
['core', 'manifest.json'],
800801
['core', 'favicon.ico'],
801-
['core', 'favicon-touch.png']
802+
['core', 'favicon-touch.png'],
802803
];
803804
}
804805

@@ -825,4 +826,35 @@ public function testReplaceImagePath(string $app, string $image, string|bool $re
825826
}
826827
$this->assertEquals($result, $this->template->replaceImagePath($app, $image));
827828
}
829+
830+
public static function setTypesProvider(): array {
831+
return [
832+
[ConfigLexicon::BASE_URL, 'example.com', 'example.com'],
833+
[ConfigLexicon::USER_THEMING_DISABLED, 'no', false],
834+
[ConfigLexicon::USER_THEMING_DISABLED, 'true', true],
835+
];
836+
}
837+
838+
#[\PHPUnit\Framework\Attributes\DataProvider('setTypesProvider')]
839+
public function testSetTypes(string $setting, string $value, mixed $expected): void {
840+
$setValue = null;
841+
$cb = function ($setting, $value) use (&$setValue) {
842+
if ($setting !== ConfigLexicon::CACHE_BUSTER) {
843+
$setValue = $value;
844+
}
845+
return true;
846+
};
847+
$this->appConfig
848+
->method('setAppValueBool')
849+
->willReturnCallback($cb);
850+
$this->appConfig
851+
->method('setAppValueString')
852+
->willReturnCallback($cb);
853+
$this->appConfig
854+
->method('setAppValueInt')
855+
->willReturnCallback($cb);
856+
857+
$this->template->set($setting, $value);
858+
$this->assertEquals($expected, $setValue);
859+
}
828860
}

0 commit comments

Comments
 (0)