From 502ba9defc9f99ae1b3ae2334fdac2f0a8bf728f Mon Sep 17 00:00:00 2001 From: MarvelBR Date: Tue, 3 Nov 2026 00:13:03 -0300 Subject: [PATCH 1/2] feat: add internal experimental features switch Signed-off-by: MarvelBR --- lib/Service/ExperimentalFeaturesService.php | 25 +++++++++++++ .../ExperimentalFeaturesServiceTest.php | 37 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 lib/Service/ExperimentalFeaturesService.php create mode 100644 tests/php/Unit/Service/ExperimentalFeaturesServiceTest.php diff --git a/lib/Service/ExperimentalFeaturesService.php b/lib/Service/ExperimentalFeaturesService.php new file mode 100644 index 0000000000..62272b48f2 --- /dev/null +++ b/lib/Service/ExperimentalFeaturesService.php @@ -0,0 +1,25 @@ +appConfig->getValueBool(Application::APP_ID, self::APP_CONFIG_KEY, false); + } +} diff --git a/tests/php/Unit/Service/ExperimentalFeaturesServiceTest.php b/tests/php/Unit/Service/ExperimentalFeaturesServiceTest.php new file mode 100644 index 0000000000..c32f293075 --- /dev/null +++ b/tests/php/Unit/Service/ExperimentalFeaturesServiceTest.php @@ -0,0 +1,37 @@ +assertFalse($service->isEnabled()); + } + + public function testExperimentalFeaturesAreDisabledWhenConfigurationIsFalse(): void { + $appConfig = self::getMockAppConfig(); + $appConfig->setValueBool(Application::APP_ID, ExperimentalFeaturesService::APP_CONFIG_KEY, false); + $service = new ExperimentalFeaturesService($appConfig); + + $this->assertFalse($service->isEnabled()); + } + + public function testExperimentalFeaturesAreEnabledWhenConfigurationIsTrue(): void { + $appConfig = self::getMockAppConfig(); + $appConfig->setValueBool(Application::APP_ID, ExperimentalFeaturesService::APP_CONFIG_KEY, true); + $service = new ExperimentalFeaturesService($appConfig); + + $this->assertTrue($service->isEnabled()); + } +} From 4d48e8b44cd7fa5f5d3d0e0a6f8b402dc77e6431 Mon Sep 17 00:00:00 2001 From: MarvelBR Date: Tue, 17 Nov 2026 10:15:54 -0300 Subject: [PATCH 2/2] test: consolidate experimental features tests with a data provider Signed-off-by: MarvelBR --- .../ExperimentalFeaturesServiceTest.php | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/tests/php/Unit/Service/ExperimentalFeaturesServiceTest.php b/tests/php/Unit/Service/ExperimentalFeaturesServiceTest.php index c32f293075..313ec35fad 100644 --- a/tests/php/Unit/Service/ExperimentalFeaturesServiceTest.php +++ b/tests/php/Unit/Service/ExperimentalFeaturesServiceTest.php @@ -11,27 +11,34 @@ 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 { - public function testExperimentalFeaturesAreDisabledWhenConfigurationIsMissing(): void { - $service = new ExperimentalFeaturesService(self::getMockAppConfig()); - - $this->assertFalse($service->isEnabled()); + /** + * @return array + */ + public static function provideExperimentalFeatureStates(): array { + return [ + 'missing configuration' => [null, false], + 'explicitly disabled' => [false, false], + 'explicitly enabled' => [true, true], + ]; } - public function testExperimentalFeaturesAreDisabledWhenConfigurationIsFalse(): void { + #[DataProvider('provideExperimentalFeatureStates')] + public function testExperimentalFeaturesSwitch(?bool $configuredValue, bool $expected): void { $appConfig = self::getMockAppConfig(); - $appConfig->setValueBool(Application::APP_ID, ExperimentalFeaturesService::APP_CONFIG_KEY, false); - $service = new ExperimentalFeaturesService($appConfig); - $this->assertFalse($service->isEnabled()); - } + if ($configuredValue !== null) { + $appConfig->setValueBool( + Application::APP_ID, + ExperimentalFeaturesService::APP_CONFIG_KEY, + $configuredValue, + ); + } - public function testExperimentalFeaturesAreEnabledWhenConfigurationIsTrue(): void { - $appConfig = self::getMockAppConfig(); - $appConfig->setValueBool(Application::APP_ID, ExperimentalFeaturesService::APP_CONFIG_KEY, true); $service = new ExperimentalFeaturesService($appConfig); - $this->assertTrue($service->isEnabled()); + $this->assertSame($expected, $service->isEnabled()); } }