Repository navigation
Conversation
Signed-off-by: MarvelBR <erickmg2005@gmail.com>
vitormattos
left a comment
There was a problem hiding this comment.
Please address the inline suggestion to consolidate the three equivalent configuration tests with a named PHPUnit data provider. The production service implementation otherwise aligns with issue #8333.
| use OCA\Libresign\Tests\Unit\TestCase; | ||
|
|
||
| final class ExperimentalFeaturesServiceTest extends TestCase { | ||
| public function testExperimentalFeaturesAreDisabledWhenConfigurationIsMissing(): void { |
There was a problem hiding this comment.
Could you consolidate these three tests using a #[DataProvider] with named datasets?
For example:
use PHPUnit\Framework\Attributes\DataProvider;
/**
* @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());
}Here, null represents a missing configuration key, not a stored value. This preserves the distinction between an absent configuration and an explicit false.
The three cases will remain independently reported by PHPUnit, while sharing the same setup and assertion. This also follows the existing testing conventions in LibreSign.
There was a problem hiding this comment.
Thanks for the review! I consolidated the three tests into a single one using a named #[DataProvider], as suggested.
Signed-off-by: MarvelBR <erickmg2005@gmail.com>
f981243 to
4d48e8b
Compare
Resolves: #8333
Summary
Adds
ExperimentalFeaturesService, a small internal switch backed by theexperimental_featuresapp config key. It is disabled by default (also when the key is missing) and has no UI, so future experimental features can be gated behind a single, tested check.This PR does not gate any feature yet and does not change existing behavior.
How to test
vendor/bin/phpunit -c tests/php/phpunit.xml --filter ExperimentalFeaturesServiceTest --no-coverageoccand check thatExperimentalFeaturesService::isEnabled()follows it:occ config:app:set libresign experimental_features --value=true --type=booleanI also verified that the value is read correctly when set without
--type=boolean.Validation evidence
composer cs:check,composer psalm)composer test:unit)API / Back-end changes
OCA\Libresign\Service\ExperimentalFeaturesServicereadingexperimental_featuresthroughIAppConfig, defaulting tofalsefalseandtruevaluesChecklist
AI (if applicable)
AI assistance was used to locate existing test helpers and to review the code and PR text. The implementation and tests were written and verified by me.