mirror of
https://github.com/nextcloud/server.git
synced 2026-11-03 21:12:20 +01:00
apps/viewer becomes a minimal, always enabled app again, the server side of the viewer. It keeps the user's viewer settings the way the Files app keeps its own: a config lexicon declaring them, a UserConfig service holding what the lexicon cannot say, an OCS endpoint to change one, and the settings handed to the viewer as initial state. They are the slideshow delay, and the volume of videos and audio and whether they start muted. Core keeps loading the viewer itself. It is no longer an abandoned app to clean up after, and continues the old app's versions at 9.0.0-dev.0, after 8.0.0 in 35. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
46 lines
1.4 KiB
PHP
46 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
namespace OCA\Viewer\Tests\Controller;
|
|
|
|
use OCA\Viewer\Controller\ConfigController;
|
|
use OCA\Viewer\Service\UserConfig;
|
|
use OCP\AppFramework\Http;
|
|
use Test\TestCase;
|
|
|
|
class ConfigControllerTest extends TestCase {
|
|
private ConfigController $controller;
|
|
|
|
protected function setUp(): void {
|
|
parent::setUp();
|
|
$this->controller = $this->createInstanceWithMocks(ConfigController::class, ['appName' => 'viewer']);
|
|
}
|
|
|
|
public function testSavesTheSetting(): void {
|
|
$this->getAutoMock(UserConfig::class)->expects($this->once())
|
|
->method('setConfig')
|
|
->with('slideshow_delay', 10);
|
|
|
|
$response = $this->controller->setConfig('slideshow_delay', 10);
|
|
|
|
$this->assertSame(Http::STATUS_OK, $response->getStatus());
|
|
$this->assertSame(['key' => 'slideshow_delay', 'value' => 10], $response->getData());
|
|
}
|
|
|
|
public function testAnswersBadRequestForWhatTheSettingRefuses(): void {
|
|
$this->getAutoMock(UserConfig::class)->method('setConfig')
|
|
->willThrowException(new \InvalidArgumentException('Invalid config value'));
|
|
|
|
$response = $this->controller->setConfig('slideshow_delay', 0);
|
|
|
|
$this->assertSame(Http::STATUS_BAD_REQUEST, $response->getStatus());
|
|
$this->assertSame(['message' => 'Invalid config value'], $response->getData());
|
|
}
|
|
}
|