As a developer,
I want to be sure my A/B testing configuration is correctly implemented,
so that I can safely develop new A/B tests
The configuration file campaigns.yml makes no assumptions about how (and if) the A/B tests are implemented and if all code paths exist. Therefore, the configuration file should be checked against the actual code. The central reference point of that is the ChoiceFactory class, where each group of each campaign should be present.
AC:
- Create a validation class that analyzes the factory code and checks the 1st parameter of calls to the feature toggle library against the current campaigns.yaml configuration from T196337. If the code contains calls for campaigns or group names that don't exist, exit the script with an error message listing all mismatches between code and configuration. In that case, the console should return a non-zero exit code. To be discussed: Issue warnings or errors for entries that are in campaigns.yml but not in the code?
- Add the validation to our CI checks (make ci). This can be either a standalone console command or as a custom PHPStan rule
Background:
The easiest way to check this would be checking the code with regular expressions. However, this can be brittle and unprofessional. A better way would be to use either a custom PHPStan rule or at least using the PHP Tokenizer.