From ad5f23f845a32eb45d4ab1a3795200a9a3f650f5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 24 Nov 2025 18:02:27 +0100 Subject: [PATCH 1/2] test: add test for theming config casting Signed-off-by: Robin Appelman --- apps/theming/tests/ThemingDefaultsTest.php | 36 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php index 5682798f3f1..86907b4b31c 100644 --- a/apps/theming/tests/ThemingDefaultsTest.php +++ b/apps/theming/tests/ThemingDefaultsTest.php @@ -7,6 +7,7 @@ declare(strict_types=1); */ namespace OCA\Theming\Tests; +use OCA\Theming\ConfigLexicon; use OCA\Theming\ImageManager; use OCA\Theming\Service\BackgroundService; use OCA\Theming\ThemingDefaults; @@ -728,7 +729,7 @@ class ThemingDefaultsTest extends TestCase { 'theming-favicon-mime' => '\'jpeg\'', 'image-logoheader' => "url('custom-logoheader?v=0')", 'image-favicon' => "url('custom-favicon?v=0')", - 'has-legal-links' => 'false' + 'has-legal-links' => 'false', ]; $this->assertEquals($expected, $this->template->getScssVariables()); } @@ -798,7 +799,7 @@ class ThemingDefaultsTest extends TestCase { ['core', 'test.png', false], ['core', 'manifest.json'], ['core', 'favicon.ico'], - ['core', 'favicon-touch.png'] + ['core', 'favicon-touch.png'], ]; } @@ -825,4 +826,35 @@ class ThemingDefaultsTest extends TestCase { } $this->assertEquals($result, $this->template->replaceImagePath($app, $image)); } + + public static function setTypesProvider(): array { + return [ + [ConfigLexicon::BASE_URL, 'example.com', 'example.com'], + [ConfigLexicon::USER_THEMING_DISABLED, 'no', false], + [ConfigLexicon::USER_THEMING_DISABLED, 'true', true], + ]; + } + + #[\PHPUnit\Framework\Attributes\DataProvider('setTypesProvider')] + public function testSetTypes(string $setting, string $value, mixed $expected): void { + $setValue = null; + $cb = function ($setting, $value) use (&$setValue) { + if ($setting !== ConfigLexicon::CACHE_BUSTER) { + $setValue = $value; + } + return true; + }; + $this->appConfig + ->method('setAppValueBool') + ->willReturnCallback($cb); + $this->appConfig + ->method('setAppValueString') + ->willReturnCallback($cb); + $this->appConfig + ->method('setAppValueInt') + ->willReturnCallback($cb); + + $this->template->set($setting, $value); + $this->assertEquals($expected, $setValue); + } } From 561d3ded2311c6f532f84d20b7bd96ea77dcc325 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 24 Nov 2025 18:03:08 +0100 Subject: [PATCH 2/2] fix: fix theming config value casting Signed-off-by: Robin Appelman --- apps/theming/lib/ThemingDefaults.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 885155c9d63..da92f31903b 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -431,12 +431,12 @@ class ThemingDefaults extends \OC_Defaults { * @param string $value */ public function set($setting, $value): void { - switch ($value) { + switch ($setting) { case ConfigLexicon::CACHE_BUSTER: $this->appConfig->setAppValueInt(ConfigLexicon::CACHE_BUSTER, (int)$value); break; case ConfigLexicon::USER_THEMING_DISABLED: - $value = $value === 'true' || $value === 'yes' || $value === '1'; + $value = in_array($value, ['1', 'true', 'yes', 'on']); $this->appConfig->setAppValueBool(ConfigLexicon::USER_THEMING_DISABLED, $value); break; default: