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
25 changes: 25 additions & 0 deletions lib/Service/ExperimentalFeaturesService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Libresign\Service;

use OCA\Libresign\AppInfo\Application;
use OCP\IAppConfig;

class ExperimentalFeaturesService {
public const APP_CONFIG_KEY = 'experimental_features';

public function __construct(
private IAppConfig $appConfig,
) {
}

public function isEnabled(): bool {
return $this->appConfig->getValueBool(Application::APP_ID, self::APP_CONFIG_KEY, false);
}
}
44 changes: 44 additions & 0 deletions tests/php/Unit/Service/ExperimentalFeaturesServiceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Libresign\Tests\Unit\Service;

use OCA\Libresign\AppInfo\Application;
use OCA\Libresign\Service\ExperimentalFeaturesService;
use OCA\Libresign\Tests\Unit\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;

final class ExperimentalFeaturesServiceTest extends TestCase {
/**
* @return array<string, array{?bool, bool}>
*/
public static function provideExperimentalFeatureStates(): array {
return [
'missing configuration' => [null, false],
'explicitly disabled' => [false, false],
'explicitly enabled' => [true, true],
];
}

#[DataProvider('provideExperimentalFeatureStates')]
public function testExperimentalFeaturesSwitch(?bool $configuredValue, bool $expected): void {
$appConfig = self::getMockAppConfig();

if ($configuredValue !== null) {
$appConfig->setValueBool(
Application::APP_ID,
ExperimentalFeaturesService::APP_CONFIG_KEY,
$configuredValue,
);
}

$service = new ExperimentalFeaturesService($appConfig);

$this->assertSame($expected, $service->isEnabled());
}
}