diff options
-rw-r--r-- | core/Command/Config/Preset.php | 10 | ||||
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 1 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 1 | ||||
-rw-r--r-- | lib/private/AppConfig.php | 26 | ||||
-rw-r--r-- | lib/private/AppFramework/App.php | 29 | ||||
-rw-r--r-- | lib/private/Config/ConfigManager.php | 24 | ||||
-rw-r--r-- | lib/private/Config/PresetManager.php | 48 | ||||
-rw-r--r-- | lib/private/Config/UserConfig.php | 19 | ||||
-rw-r--r-- | lib/private/Profile/ProfileManager.php | 29 | ||||
-rw-r--r-- | tests/lib/AppConfigTest.php | 8 | ||||
-rw-r--r-- | tests/lib/Config/LexiconTest.php | 15 | ||||
-rw-r--r-- | tests/lib/Config/UserConfigTest.php | 8 |
12 files changed, 133 insertions, 85 deletions
diff --git a/core/Command/Config/Preset.php b/core/Command/Config/Preset.php index 4f0278896db..ebd8aaa5cdf 100644 --- a/core/Command/Config/Preset.php +++ b/core/Command/Config/Preset.php @@ -8,10 +8,9 @@ declare(strict_types=1); */ namespace OC\Core\Command\Config; -use OC\Config\ConfigManager; +use OC\Config\PresetManager; use OC\Core\Command\Base; use OCP\Config\Lexicon\Preset as ConfigLexiconPreset; -use OCP\IConfig; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -19,8 +18,7 @@ use Symfony\Component\Console\Output\OutputInterface; class Preset extends Base { public function __construct( - private readonly IConfig $config, - private readonly ConfigManager $configManager, + private readonly PresetManager $presetManager, ) { parent::__construct(); } @@ -49,10 +47,10 @@ class Preset extends Base { return self::INVALID; } - $this->configManager->setLexiconPreset($preset); + $this->presetManager->setLexiconPreset($preset); } - $current = ConfigLexiconPreset::tryFrom($this->config->getSystemValueInt(ConfigManager::PRESET_CONFIGKEY, 0)) ?? ConfigLexiconPreset::NONE; + $current = $this->presetManager->getLexiconPreset(); $this->writeArrayInOutputFormat($input, $output, [$current->name], 'current preset: '); return self::SUCCESS; } diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index ab0f12233d4..acded1ed539 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -1219,6 +1219,7 @@ return array( 'OC\\Comments\\ManagerFactory' => $baseDir . '/lib/private/Comments/ManagerFactory.php', 'OC\\Config' => $baseDir . '/lib/private/Config.php', 'OC\\Config\\ConfigManager' => $baseDir . '/lib/private/Config/ConfigManager.php', + 'OC\\Config\\PresetManager' => $baseDir . '/lib/private/Config/PresetManager.php', 'OC\\Config\\UserConfig' => $baseDir . '/lib/private/Config/UserConfig.php', 'OC\\Console\\Application' => $baseDir . '/lib/private/Console/Application.php', 'OC\\Console\\TimestampFormatter' => $baseDir . '/lib/private/Console/TimestampFormatter.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 3d32ee7e567..bb20a68eae3 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -1260,6 +1260,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Comments\\ManagerFactory' => __DIR__ . '/../../..' . '/lib/private/Comments/ManagerFactory.php', 'OC\\Config' => __DIR__ . '/../../..' . '/lib/private/Config.php', 'OC\\Config\\ConfigManager' => __DIR__ . '/../../..' . '/lib/private/Config/ConfigManager.php', + 'OC\\Config\\PresetManager' => __DIR__ . '/../../..' . '/lib/private/Config/PresetManager.php', 'OC\\Config\\UserConfig' => __DIR__ . '/../../..' . '/lib/private/Config/UserConfig.php', 'OC\\Console\\Application' => __DIR__ . '/../../..' . '/lib/private/Console/Application.php', 'OC\\Console\\TimestampFormatter' => __DIR__ . '/../../..' . '/lib/private/Console/TimestampFormatter.php', diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php index 2280ac1a79f..cef612536d6 100644 --- a/lib/private/AppConfig.php +++ b/lib/private/AppConfig.php @@ -13,9 +13,9 @@ use InvalidArgumentException; use JsonException; use OC\AppFramework\Bootstrap\Coordinator; use OC\Config\ConfigManager; +use OC\Config\PresetManager; use OCP\Config\Lexicon\Entry; use OCP\Config\Lexicon\ILexicon; -use OCP\Config\Lexicon\Preset; use OCP\Config\Lexicon\Strictness; use OCP\Config\ValueType; use OCP\DB\Exception as DBException; @@ -27,7 +27,6 @@ use OCP\IAppConfig; use OCP\IConfig; use OCP\IDBConnection; use OCP\Security\ICrypto; -use OCP\Server; use Psr\Log\LoggerInterface; /** @@ -66,13 +65,14 @@ class AppConfig implements IAppConfig { /** @var array<string, array{entries: array<string, Entry>, aliases: array<string, string>, strictness: Strictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */ private array $configLexiconDetails = []; private bool $ignoreLexiconAliases = false; - private ?Preset $configLexiconPreset = null; /** @var ?array<string, string> */ private ?array $appVersionsCache = null; public function __construct( protected IDBConnection $connection, protected IConfig $config, + private readonly ConfigManager $configManager, + private readonly PresetManager $presetManager, protected LoggerInterface $logger, protected ICrypto $crypto, ) { @@ -520,8 +520,7 @@ class AppConfig implements IAppConfig { // interested to check options in case a modification of the value is needed // ie inverting value from previous key when using lexicon option RENAME_INVERT_BOOLEAN if ($origKey !== $key && $type === self::VALUE_BOOL) { - $configManager = Server::get(ConfigManager::class); - $value = ($configManager->convertToBool($value, $this->getLexiconEntry($app, $key))) ? '1' : '0'; + $value = ($this->configManager->convertToBool($value, $this->getLexiconEntry($app, $key))) ? '1' : '0'; } return $value; @@ -1108,7 +1107,7 @@ class AppConfig implements IAppConfig { $this->assertParams($app, $key); try { $details = $this->getDetails($app, $key); - } catch (AppConfigUnknownKeyException $e) { + } catch (AppConfigUnknownKeyException) { $details = [ 'app' => $app, 'key' => $key @@ -1129,13 +1128,13 @@ class AppConfig implements IAppConfig { 'valueType' => $lexiconEntry->getValueType(), 'valueTypeName' => $lexiconEntry->getValueType()->name, 'sensitive' => $lexiconEntry->isFlagged(self::FLAG_SENSITIVE), - 'default' => $lexiconEntry->getDefault($this->getLexiconPreset()), + 'default' => $lexiconEntry->getDefault($this->presetManager->getLexiconPreset()), 'definition' => $lexiconEntry->getDefinition(), 'note' => $lexiconEntry->getNote(), ]); } - return array_filter($details); + return array_filter($details, static fn ($v): bool => ($v !== null)); } /** @@ -1228,7 +1227,6 @@ class AppConfig implements IAppConfig { public function clearCache(bool $reload = false): void { $this->lazyLoaded = $this->fastLoaded = false; $this->lazyCache = $this->fastCache = $this->valueTypes = $this->configLexiconDetails = []; - $this->configLexiconPreset = null; if (!$reload) { return; @@ -1714,7 +1712,7 @@ class AppConfig implements IAppConfig { $lazy = $lexiconEntry->isLazy(); // only look for default if needed, default from Lexicon got priority if ($default !== null) { - $default = $lexiconEntry->getDefault($this->getLexiconPreset()) ?? $default; + $default = $lexiconEntry->getDefault($this->presetManager->getLexiconPreset()) ?? $default; } if ($lexiconEntry->isFlagged(self::FLAG_SENSITIVE)) { @@ -1802,14 +1800,6 @@ class AppConfig implements IAppConfig { $this->ignoreLexiconAliases = $ignore; } - private function getLexiconPreset(): Preset { - if ($this->configLexiconPreset === null) { - $this->configLexiconPreset = Preset::tryFrom($this->config->getSystemValueInt(ConfigManager::PRESET_CONFIGKEY, 0)) ?? Preset::NONE; - } - - return $this->configLexiconPreset; - } - /** * Returns the installed versions of all apps * diff --git a/lib/private/AppFramework/App.php b/lib/private/AppFramework/App.php index e790e8b8887..7bf32852209 100644 --- a/lib/private/AppFramework/App.php +++ b/lib/private/AppFramework/App.php @@ -71,7 +71,6 @@ class App { return null; } - /** * Shortcut for calling a controller method and printing the result * @@ -82,7 +81,12 @@ class App { * @param array $urlParams list of URL parameters (optional) * @throws HintException */ - public static function main(string $controllerName, string $methodName, DIContainer $container, ?array $urlParams = null) { + public static function main( + string $controllerName, + string $methodName, + DIContainer $container, + ?array $urlParams = null, + ): void { /** @var IProfiler $profiler */ $profiler = $container->get(IProfiler::class); $eventLogger = $container->get(IEventLogger::class); @@ -210,25 +214,4 @@ class App { } } } - - /** - * Shortcut for calling a controller method and printing the result. - * Similar to App:main except that no headers will be sent. - * - * @param string $controllerName the name of the controller under which it is - * stored in the DI container - * @param string $methodName the method that you want to call - * @param array $urlParams an array with variables extracted from the routes - * @param DIContainer $container an instance of a pimple container. - */ - public static function part(string $controllerName, string $methodName, array $urlParams, - DIContainer $container) { - $container['urlParams'] = $urlParams; - $controller = $container[$controllerName]; - - $dispatcher = $container['Dispatcher']; - - [, , $output] = $dispatcher->dispatch($controller, $methodName); - return $output; - } } diff --git a/lib/private/Config/ConfigManager.php b/lib/private/Config/ConfigManager.php index ed516abdcbf..28397402249 100644 --- a/lib/private/Config/ConfigManager.php +++ b/lib/private/Config/ConfigManager.php @@ -14,10 +14,8 @@ use OCP\App\IAppManager; use OCP\Config\Exceptions\TypeConflictException; use OCP\Config\IUserConfig; use OCP\Config\Lexicon\Entry; -use OCP\Config\Lexicon\Preset; use OCP\Config\ValueType; use OCP\IAppConfig; -use OCP\IConfig; use OCP\Server; use Psr\Log\LoggerInterface; @@ -27,20 +25,23 @@ use Psr\Log\LoggerInterface; * @since 32.0.0 */ class ConfigManager { - /** @since 32.0.0 */ - public const PRESET_CONFIGKEY = 'config_preset'; - /** @var AppConfig|null $appConfig */ private ?IAppConfig $appConfig = null; /** @var UserConfig|null $userConfig */ private ?IUserConfig $userConfig = null; public function __construct( - private readonly IConfig $config, private readonly LoggerInterface $logger, ) { } + public function clearConfigCaches(): void { + $this->loadConfigServices(); + $this->appConfig->clearCache(); + $this->userConfig->clearCacheAll(); + } + + /** * Use the rename values from the list of ConfigLexiconEntry defined in each app ConfigLexicon * to migrate config value to a new config key. @@ -82,17 +83,6 @@ class ConfigManager { } /** - * store in config.php the new preset - * refresh cached preset - */ - public function setLexiconPreset(Preset $preset): void { - $this->config->setSystemValue(self::PRESET_CONFIGKEY, $preset->value); - $this->loadConfigServices(); - $this->appConfig->clearCache(); - $this->userConfig->clearCacheAll(); - } - - /** * config services cannot be load at __construct() or install will fail */ private function loadConfigServices(): void { diff --git a/lib/private/Config/PresetManager.php b/lib/private/Config/PresetManager.php new file mode 100644 index 00000000000..d9c029d15c2 --- /dev/null +++ b/lib/private/Config/PresetManager.php @@ -0,0 +1,48 @@ +<?php + +declare(strict_types=1); +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OC\Config; + +use OCP\Config\Lexicon\Preset; +use OCP\IConfig; + +/** + * tools to maintains configurations + */ +class PresetManager { + private const PRESET_CONFIGKEY = 'config_preset'; + + private ?Preset $configLexiconPreset = null; + + public function __construct( + private readonly IConfig $config, + private readonly ConfigManager $configManager, + ) { + } + + /** + * store in config.php the new preset + * refresh cached preset + */ + public function setLexiconPreset(Preset $preset): void { + $this->config->setSystemValue(self::PRESET_CONFIGKEY, $preset->value); + $this->configLexiconPreset = $preset; + $this->configManager->clearConfigCaches(); + } + + /** + * returns currently selected Preset + */ + public function getLexiconPreset(): Preset { + if ($this->configLexiconPreset === null) { + $this->configLexiconPreset = Preset::tryFrom($this->config->getSystemValueInt(self::PRESET_CONFIGKEY, 0)) ?? Preset::NONE; + } + + return $this->configLexiconPreset; + } +} diff --git a/lib/private/Config/UserConfig.php b/lib/private/Config/UserConfig.php index 04ba0e29db0..4ddad3ec2f2 100644 --- a/lib/private/Config/UserConfig.php +++ b/lib/private/Config/UserConfig.php @@ -18,7 +18,6 @@ use OCP\Config\Exceptions\UnknownKeyException; use OCP\Config\IUserConfig; use OCP\Config\Lexicon\Entry; use OCP\Config\Lexicon\ILexicon; -use OCP\Config\Lexicon\Preset; use OCP\Config\Lexicon\Strictness; use OCP\Config\ValueType; use OCP\DB\Exception as DBException; @@ -27,7 +26,6 @@ use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IConfig; use OCP\IDBConnection; use OCP\Security\ICrypto; -use OCP\Server; use Psr\Log\LoggerInterface; /** @@ -68,11 +66,12 @@ class UserConfig implements IUserConfig { /** @var array<string, array{entries: array<string, Entry>, aliases: array<string, string>, strictness: Strictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */ private array $configLexiconDetails = []; private bool $ignoreLexiconAliases = false; - private ?Preset $configLexiconPreset = null; public function __construct( protected IDBConnection $connection, protected IConfig $config, + private readonly ConfigManager $configManager, + private readonly PresetManager $presetManager, protected LoggerInterface $logger, protected ICrypto $crypto, ) { @@ -772,8 +771,7 @@ class UserConfig implements IUserConfig { // interested to check options in case a modification of the value is needed // ie inverting value from previous key when using lexicon option RENAME_INVERT_BOOLEAN if ($origKey !== $key && $type === ValueType::BOOL) { - $configManager = Server::get(ConfigManager::class); - $value = ($configManager->convertToBool($value, $this->getLexiconEntry($app, $key))) ? '1' : '0'; + $value = ($this->configManager->convertToBool($value, $this->getLexiconEntry($app, $key))) ? '1' : '0'; } return $value; @@ -1636,7 +1634,6 @@ class UserConfig implements IUserConfig { public function clearCacheAll(): void { $this->lazyLoaded = $this->fastLoaded = []; $this->lazyCache = $this->fastCache = $this->valueDetails = $this->configLexiconDetails = []; - $this->configLexiconPreset = null; } /** @@ -1937,7 +1934,7 @@ class UserConfig implements IUserConfig { // only look for default if needed, default from Lexicon got priority if not overwritten by admin if ($default !== null) { - $default = $this->getSystemDefault($app, $configValue) ?? $configValue->getDefault($this->getLexiconPreset()) ?? $default; + $default = $this->getSystemDefault($app, $configValue) ?? $configValue->getDefault($this->presetManager->getLexiconPreset()) ?? $default; } // returning false will make get() returning $default and set() not changing value in database @@ -2039,12 +2036,4 @@ class UserConfig implements IUserConfig { public function ignoreLexiconAliases(bool $ignore): void { $this->ignoreLexiconAliases = $ignore; } - - private function getLexiconPreset(): Preset { - if ($this->configLexiconPreset === null) { - $this->configLexiconPreset = Preset::tryFrom($this->config->getSystemValueInt(ConfigManager::PRESET_CONFIGKEY, 0)) ?? Preset::NONE; - } - - return $this->configLexiconPreset; - } } diff --git a/lib/private/Profile/ProfileManager.php b/lib/private/Profile/ProfileManager.php index 7c15ed614aa..c38412f6bd0 100644 --- a/lib/private/Profile/ProfileManager.php +++ b/lib/private/Profile/ProfileManager.php @@ -10,6 +10,7 @@ declare(strict_types=1); namespace OC\Profile; use OC\AppFramework\Bootstrap\Coordinator; +use OC\Config\PresetManager; use OC\Core\Db\ProfileConfig; use OC\Core\Db\ProfileConfigMapper; use OC\Core\ResponseDefinitions; @@ -25,6 +26,7 @@ use OCP\Accounts\PropertyDoesNotExistException; use OCP\App\IAppManager; use OCP\AppFramework\Db\DoesNotExistException; use OCP\Cache\CappedMemoryCache; +use OCP\Config\Lexicon\Preset; use OCP\IConfig; use OCP\IUser; use OCP\L10N\IFactory; @@ -85,6 +87,7 @@ class ProfileManager implements IProfileManager { private IFactory $l10nFactory, private LoggerInterface $logger, private Coordinator $coordinator, + private readonly PresetManager $presetManager, ) { $this->configCache = new CappedMemoryCache(); } @@ -315,6 +318,7 @@ class ProfileManager implements IProfileManager { // Construct the default config for account properties $propertiesConfig = []; foreach (self::DEFAULT_PROPERTY_VISIBILITY as $property => $visibility) { + $this->applyDefaultProfilePreset($property, $visibility); $propertiesConfig[$property] = ['visibility' => $visibility]; } @@ -322,6 +326,31 @@ class ProfileManager implements IProfileManager { } /** + * modify property visibility, based on current Preset + * + * @psalm-suppress UnhandledMatchCondition if conditions are not met, we do not change $visibility + */ + private function applyDefaultProfilePreset(string $property, string &$visibility): void { + try { + $overwrite = match ($this->presetManager->getLexiconPreset()) { + Preset::SHARED, Preset::SCHOOL, Preset::UNIVERSITY => match ($property) { + IAccountManager::PROPERTY_ADDRESS, IAccountManager::PROPERTY_EMAIL, IAccountManager::PROPERTY_PHONE => self::VISIBILITY_HIDE, + }, + Preset::PRIVATE, Preset::FAMILY, Preset::CLUB => match ($property) { + IAccountManager::PROPERTY_EMAIL => self::VISIBILITY_SHOW, + }, + Preset::SMALL, Preset::MEDIUM, Preset::LARGE => match ($property) { + IAccountManager::PROPERTY_EMAIL, IAccountManager::PROPERTY_PHONE => self::VISIBILITY_SHOW, + }, + }; + } catch (\UnhandledMatchError) { + return; + } + + $visibility = $overwrite; + } + + /** * Return the profile config of the target user, * if a config does not already exist a default config is created and returned */ diff --git a/tests/lib/AppConfigTest.php b/tests/lib/AppConfigTest.php index 03405bf96ca..0ae917a1d9f 100644 --- a/tests/lib/AppConfigTest.php +++ b/tests/lib/AppConfigTest.php @@ -9,6 +9,8 @@ namespace Test; use InvalidArgumentException; use OC\AppConfig; +use OC\Config\ConfigManager; +use OC\Config\PresetManager; use OCP\Exceptions\AppConfigTypeConflictException; use OCP\Exceptions\AppConfigUnknownKeyException; use OCP\IAppConfig; @@ -29,6 +31,8 @@ class AppConfigTest extends TestCase { protected IAppConfig $appConfig; protected IDBConnection $connection; private IConfig $config; + private ConfigManager $configManager; + private PresetManager $presetManager; private LoggerInterface $logger; private ICrypto $crypto; @@ -99,6 +103,8 @@ class AppConfigTest extends TestCase { $this->connection = Server::get(IDBConnection::class); $this->config = Server::get(IConfig::class); + $this->configManager = Server::get(ConfigManager::class); + $this->presetManager = Server::get(PresetManager::class); $this->logger = Server::get(LoggerInterface::class); $this->crypto = Server::get(ICrypto::class); @@ -190,6 +196,8 @@ class AppConfigTest extends TestCase { $config = new AppConfig( $this->connection, $this->config, + $this->configManager, + $this->presetManager, $this->logger, $this->crypto, ); diff --git a/tests/lib/Config/LexiconTest.php b/tests/lib/Config/LexiconTest.php index def9e152853..d7e9b12a1cf 100644 --- a/tests/lib/Config/LexiconTest.php +++ b/tests/lib/Config/LexiconTest.php @@ -10,6 +10,7 @@ namespace Tests\lib\Config; use OC\AppConfig; use OC\AppFramework\Bootstrap\Coordinator; use OC\Config\ConfigManager; +use OC\Config\PresetManager; use OCP\Config\Exceptions\TypeConflictException; use OCP\Config\Exceptions\UnknownKeyException; use OCP\Config\IUserConfig; @@ -32,6 +33,7 @@ class LexiconTest extends TestCase { private IAppConfig $appConfig; private IUserConfig $userConfig; private ConfigManager $configManager; + private PresetManager $presetManager; protected function setUp(): void { parent::setUp(); @@ -45,6 +47,7 @@ class LexiconTest extends TestCase { $this->appConfig = Server::get(IAppConfig::class); $this->userConfig = Server::get(IUserConfig::class); $this->configManager = Server::get(ConfigManager::class); + $this->presetManager = Server::get(PresetManager::class); } protected function tearDown(): void { @@ -206,26 +209,26 @@ class LexiconTest extends TestCase { } public function testAppConfigLexiconPreset() { - $this->configManager->setLexiconPreset(Preset::FAMILY); + $this->presetManager->setLexiconPreset(Preset::FAMILY); $this->assertSame('family', $this->appConfig->getValueString(TestLexicon_E::APPID, 'key3')); } public function testAppConfigLexiconPresets() { - $this->configManager->setLexiconPreset(Preset::MEDIUM); + $this->presetManager->setLexiconPreset(Preset::MEDIUM); $this->assertSame('club+medium', $this->appConfig->getValueString(TestLexicon_E::APPID, 'key3')); - $this->configManager->setLexiconPreset(Preset::FAMILY); + $this->presetManager->setLexiconPreset(Preset::FAMILY); $this->assertSame('family', $this->appConfig->getValueString(TestLexicon_E::APPID, 'key3')); } public function testUserConfigLexiconPreset() { - $this->configManager->setLexiconPreset(Preset::FAMILY); + $this->presetManager->setLexiconPreset(Preset::FAMILY); $this->assertSame('family', $this->userConfig->getValueString('user1', TestLexicon_E::APPID, 'key3')); } public function testUserConfigLexiconPresets() { - $this->configManager->setLexiconPreset(Preset::MEDIUM); + $this->presetManager->setLexiconPreset(Preset::MEDIUM); $this->assertSame('club+medium', $this->userConfig->getValueString('user1', TestLexicon_E::APPID, 'key3')); - $this->configManager->setLexiconPreset(Preset::FAMILY); + $this->presetManager->setLexiconPreset(Preset::FAMILY); $this->assertSame('family', $this->userConfig->getValueString('user1', TestLexicon_E::APPID, 'key3')); } } diff --git a/tests/lib/Config/UserConfigTest.php b/tests/lib/Config/UserConfigTest.php index 5666a441b93..9dd5ab10084 100644 --- a/tests/lib/Config/UserConfigTest.php +++ b/tests/lib/Config/UserConfigTest.php @@ -7,6 +7,8 @@ declare(strict_types=1); */ namespace Test\lib\Config; +use OC\Config\ConfigManager; +use OC\Config\PresetManager; use OC\Config\UserConfig; use OCP\Config\Exceptions\TypeConflictException; use OCP\Config\Exceptions\UnknownKeyException; @@ -29,6 +31,8 @@ use Test\TestCase; class UserConfigTest extends TestCase { protected IDBConnection $connection; private IConfig $config; + private ConfigManager $configManager; + private PresetManager $presetManager; private LoggerInterface $logger; private ICrypto $crypto; private array $originalPreferences; @@ -173,6 +177,8 @@ class UserConfigTest extends TestCase { $this->connection = Server::get(IDBConnection::class); $this->config = Server::get(IConfig::class); + $this->configManager = Server::get(ConfigManager::class); + $this->presetManager = Server::get(PresetManager::class); $this->logger = Server::get(LoggerInterface::class); $this->crypto = Server::get(ICrypto::class); @@ -282,6 +288,8 @@ class UserConfigTest extends TestCase { $userConfig = new UserConfig( $this->connection, $this->config, + $this->configManager, + $this->presetManager, $this->logger, $this->crypto, ); |