Skip to content

Commit a9c1cbe

Browse files
committed
fixed a flag decisions scenario
1 parent 96ab364 commit a9c1cbe

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Diff for: src/Optimizely/Optimizely.php

+3
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,9 @@ public function isFeatureEnabled($featureFlagKey, $userId, $attributes = null)
556556
$variation = $decision->getVariation();
557557

558558
if ($config->getSendFlagDecisions() && ($decision->getSource() == FeatureDecision::DECISION_SOURCE_ROLLOUT || !$variation)) {
559+
if ($variation) {
560+
$featureEnabled = $variation->getFeatureEnabled();
561+
}
559562
$ruleKey = $decision->getExperiment() ? $decision->getExperiment()->getKey() : '';
560563
$this->sendImpressionEvent($config, $ruleKey, $variation ? $variation->getKey() : '', $featureFlagKey, $ruleKey, $decision->getSource(), $featureEnabled, $userId, $attributes);
561564
}

Diff for: tests/OptimizelyTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5000,7 +5000,7 @@ public function testRolloutSendImpressionWhenSendFlagDecisionFlagInDatafile()
50005000
// Verify that sendImpressionEvent is called with expected attributes
50015001
$optimizelyMock->expects($this->exactly(1))
50025002
->method('sendImpressionEvent')
5003-
->with($this->anything(), 'rollout_1_exp_1', '177771', 'boolean_single_variable_feature', 'rollout_1_exp_1', 'rollout', false, 'user_id', []);
5003+
->with($this->anything(), 'rollout_1_exp_1', '177771', 'boolean_single_variable_feature', 'rollout_1_exp_1', 'rollout', true, 'user_id', []);
50045004

50055005
$this->assertTrue($optimizelyMock->isFeatureEnabled('boolean_single_variable_feature', 'user_id', []));
50065006
}

0 commit comments

Comments
 (0)