Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion apps/theming/lib/Command/UpdateConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

if ($value === null) {
$value = $this->config->getAppValue('theming', $key, '');
$storageKey = in_array($key, ImageManager::SUPPORTED_IMAGE_KEYS, true) ? $key . 'Mime' : $key;
$value = $this->config->getAppValue('theming', $storageKey, '');
Comment thread
shawon9324 marked this conversation as resolved.
if ($value !== '') {
$output->writeln('<info>' . $key . ' is currently set to ' . $value . '</info>');
} else {
Expand Down
70 changes: 70 additions & 0 deletions apps/theming/tests/Command/UpdateConfigTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Theming\Tests\Command;

use OCA\Theming\Command\UpdateConfig;
use OCA\Theming\ImageManager;
use OCA\Theming\ThemingDefaults;
use OCP\IConfig;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Console\Tester\CommandTester;
use Test\TestCase;

class UpdateConfigTest extends TestCase {
private ThemingDefaults&MockObject $themingDefaults;
private ImageManager&MockObject $imageManager;
private IConfig&MockObject $config;
private CommandTester $cmd;

#[\Override]
protected function setUp(): void {
parent::setUp();

$this->themingDefaults = $this->createMock(ThemingDefaults::class);
$this->imageManager = $this->createMock(ImageManager::class);
$this->config = $this->createMock(IConfig::class);

$command = new UpdateConfig($this->themingDefaults, $this->imageManager, $this->config);
$this->cmd = new CommandTester($command);
}

public function testReadRegularKeyThatIsSet(): void {
$this->config->expects($this->once())
->method('getAppValue')
->with('theming', 'name', '')
->willReturn('My Cloud');

$this->cmd->execute(['key' => 'name']);

$this->assertStringContainsString('name is currently set to My Cloud', $this->cmd->getDisplay());
}

public function testReadImageKeyThatIsSetReadsFromMimeSuffixedStorageKey(): void {
$this->config->expects($this->once())
->method('getAppValue')
->with('theming', 'logoMime', '')
->willReturn('image/png');

$this->cmd->execute(['key' => 'logo']);

$this->assertStringContainsString('logo is currently set to image/png', $this->cmd->getDisplay());
}

public function testReadImageKeyThatIsNotSet(): void {
$this->config->expects($this->once())
->method('getAppValue')
->with('theming', 'logoMime', '')
->willReturn('');

$this->cmd->execute(['key' => 'logo']);

$this->assertStringContainsString('logo is currently not set', $this->cmd->getDisplay());
}
}