|
23 | 23 | use Optimizely\Entity\Audience; |
24 | 24 | use Optimizely\Entity\Event; |
25 | 25 | use Optimizely\Entity\Experiment; |
| 26 | +use Optimizely\Entity\FeatureFlag; |
| 27 | +use Optimizely\Entity\Rollout; |
26 | 28 | use Optimizely\Entity\Group; |
27 | 29 | use Optimizely\Entity\Variation; |
28 | 30 | use Optimizely\ErrorHandler\NoOpErrorHandler; |
29 | 31 | use Optimizely\Exceptions\InvalidAttributeException; |
30 | 32 | use Optimizely\Exceptions\InvalidAudienceException; |
31 | 33 | use Optimizely\Exceptions\InvalidEventException; |
32 | 34 | use Optimizely\Exceptions\InvalidExperimentException; |
| 35 | +use Optimizely\Exceptions\InvalidFeatureFlagException; |
| 36 | +use Optimizely\Exceptions\InvalidRolloutException; |
33 | 37 | use Optimizely\Exceptions\InvalidGroupException; |
34 | 38 | use Optimizely\Exceptions\InvalidVariationException; |
35 | 39 | use Optimizely\Logger\DefaultLogger; |
@@ -315,6 +319,30 @@ public function testGetExperimentInvalidId() |
315 | 319 | $this->assertEquals(new Experiment(), $this->config->getExperimentFromId('42')); |
316 | 320 | } |
317 | 321 |
|
| 322 | + public function testGetFeatureFlagInvalidKey() |
| 323 | + { |
| 324 | + $this->loggerMock->expects($this->once()) |
| 325 | + ->method('log') |
| 326 | + ->with(Logger::ERROR, 'FeatureFlag Key "42" is not in datafile.'); |
| 327 | + $this->errorHandlerMock->expects($this->once()) |
| 328 | + ->method('handleError') |
| 329 | + ->with(new InvalidFeatureFlagException('Provided feature flag is not in datafile.')); |
| 330 | + |
| 331 | + $this->assertEquals(new FeatureFlag(), $this->config->getFeatureFlagFromKey('42')); |
| 332 | + } |
| 333 | + |
| 334 | + public function testGetRolloutInvalidId() |
| 335 | + { |
| 336 | + $this->loggerMock->expects($this->once()) |
| 337 | + ->method('log') |
| 338 | + ->with(Logger::ERROR, 'Rollout ID "42" is not in datafile.'); |
| 339 | + $this->errorHandlerMock->expects($this->once()) |
| 340 | + ->method('handleError') |
| 341 | + ->with(new InvalidRolloutException('Provided rollout is not in datafile.')); |
| 342 | + |
| 343 | + $this->assertEquals(new Rollout(), $this->config->getRolloutFromId('42')); |
| 344 | + } |
| 345 | + |
318 | 346 | public function testGetEventValidKey() |
319 | 347 | { |
320 | 348 | $event = $this->config->getEvent('purchase'); |
|
0 commit comments