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..313ec35fad --- /dev/null +++ b/tests/php/Unit/Service/ExperimentalFeaturesServiceTest.php @@ -0,0 +1,44 @@ + + */ + 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()); + } +}