-
Notifications
You must be signed in to change notification settings - Fork 30
refact: return decide reasons instead of appending to a reference parameter #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good!
Can we add a few more tests validating reasons collecting for decision hierarchical paths. No need for validating all messages.
} | ||
|
||
$userExperimentId = $this->findBucket($bucketingId, $userId, $group->getId(), $group->getTrafficAllocation()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we have a bug before? "reasons" were not passed down? :)
@@ -599,23 +611,23 @@ public function testGetVariationUserWithSetForcedVariation() | |||
$optlyObject->activate($experimentKey, $userId, $userAttributes); | |||
|
|||
// confirm normal bucketing occurs before setting the forced variation | |||
$forcedVariationKey = $optlyObject->getVariation($experimentKey, $userId, $userAttributes); | |||
$forcedVariationKey = $optlyObject->getVariation($experimentKey, $userId, $userAttributes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove space
// test valid experiment | ||
$this->assertTrue($optlyObject->setForcedVariation($experimentKey, $userId, $forcedVariationKey), sprintf('Set variation to "%s" failed.', $forcedVariationKey)); | ||
$forcedVariationKey = $optlyObject->getVariation($experimentKey, $userId, $userAttributes); | ||
$this->assertEquals($forcedVariationKey, $forcedVariationKey); | ||
// // test valid experiment | ||
// $this->assertTrue($optlyObject->setForcedVariation($experimentKey, $userId, $forcedVariationKey), sprintf('Set variation to "%s" failed.', $forcedVariationKey)); | ||
// $forcedVariationKey = $optlyObject->getVariation($experimentKey, $userId, $userAttributes); | ||
// $this->assertEquals($forcedVariationKey, $forcedVariationKey); | ||
|
||
// clear forced variation and confirm that normal bucketing occurs | ||
$this->assertTrue($optlyObject->setForcedVariation($experimentKey, $userId, null), sprintf('Set variation to "%s" failed.', $forcedVariationKey)); | ||
$forcedVariationKey = $optlyObject->getVariation($experimentKey, $userId, $userAttributes); | ||
$this->assertEquals($bucketedVariationKey, $forcedVariationKey); | ||
// // clear forced variation and confirm that normal bucketing occurs | ||
// $this->assertTrue($optlyObject->setForcedVariation($experimentKey, $userId, null), sprintf('Set variation to "%s" failed.', $forcedVariationKey)); | ||
// $forcedVariationKey = $optlyObject->getVariation($experimentKey, $userId, $userAttributes); | ||
// $this->assertEquals($bucketedVariationKey, $forcedVariationKey); | ||
|
||
// check that a paused experiment returns null | ||
$this->assertTrue($optlyObject->setForcedVariation($pausedExperimentKey, $userId, 'variation'), sprintf('Set variation to "%s" failed.', $forcedVariationKey)); | ||
$forcedVariationKey = $optlyObject->getVariation($pausedExperimentKey, $userId, $userAttributes); | ||
$this->assertNull($forcedVariationKey); | ||
// // check that a paused experiment returns null | ||
// $this->assertTrue($optlyObject->setForcedVariation($pausedExperimentKey, $userId, 'variation'), sprintf('Set variation to "%s" failed.', $forcedVariationKey)); | ||
// $forcedVariationKey = $optlyObject->getVariation($pausedExperimentKey, $userId, $userAttributes); | ||
// $this->assertNull($forcedVariationKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why these tests commented out? Intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. Probably was trying to test something and forgot to revert it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary
This PR refactors the way we collect logs for decideReasons. Previously, an array was being passed as reference to each method and each method appended it's log in the passed array. Now, each method returns it's logs along with it's response.
Test plan
Issues