Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: add test for theming config casting
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 authored and AndyScherzinger committed Nov 30, 2025
commit 5fe4c73f0bbda8c1bff7c1b72a968c75ce375c9b
36 changes: 34 additions & 2 deletions apps/theming/tests/ThemingDefaultsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
namespace OCA\Theming\Tests;

use OCA\Theming\ConfigLexicon;
use OCA\Theming\ImageManager;
use OCA\Theming\Service\BackgroundService;
use OCA\Theming\ThemingDefaults;
Expand Down Expand Up @@ -728,7 +729,7 @@ public function testGetScssVariables(): void {
'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());
}
Expand Down Expand Up @@ -798,7 +799,7 @@ public static function dataReplaceImagePath(): array {
['core', 'test.png', false],
['core', 'manifest.json'],
['core', 'favicon.ico'],
['core', 'favicon-touch.png']
['core', 'favicon-touch.png'],
];
}

Expand All @@ -825,4 +826,35 @@ public function testReplaceImagePath(string $app, string $image, string|bool $re
}
$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);
}
}