Skip to content

Commit

Permalink
Added more test cases for setForcedVariation.
Browse files Browse the repository at this point in the history
  • Loading branch information
alda-optimizely committed Jul 5, 2017
1 parent b0aa642 commit 88af55f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Optimizely/ProjectConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ public function setForcedVariation($experimentKey, $userId, $variationKey)
}

$this->_preferredVariationMap[$userId] = array($experimentId => $variationId);
$this->_logger->log(Logger::DEBUG, sprintf('Set variation "%s" for experiment "%s" and user "%s" in the preferred variation map.', $variationId, $experimentId, $userId));
$this->_logger->log(Logger::DEBUG, sprintf('Set variation "%s" for experiment "%s" and user "%s" in the preferred variation map.', $variationId, $experimentId, $userId));

return TRUE;
}

Expand Down
6 changes: 5 additions & 1 deletion tests/OptimizelyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,6 @@ public function testSetForcedVariation()

$userAttributes = [
'device_type' => 'iPhone',
'company' => 'Optimizely',
'location' => 'San Francisco'
];

Expand All @@ -1236,5 +1235,10 @@ public function testSetForcedVariation()
$this->assertTrue($optlyObject->setForcedVariation('test_experiment', 'test_user', 'variation'), 'Set variation to "variation" failed.');
$forcedVariationKey = $optlyObject->getVariation('test_experiment', 'test_user', $userAttributes);
$this->assertEquals('variation', $forcedVariationKey);

// make sure another setForcedVariation call sets a new forced variation correctly
$this->assertTrue($optlyObject->setForcedVariation('test_experiment', 'test_user2', 'variation'), 'Set variation to "variation" failed.');
$forcedVariationKey = $optlyObject->getVariation('test_experiment', 'test_user2', $userAttributes);
$this->assertEquals('variation', $forcedVariationKey);
}
}

0 comments on commit 88af55f

Please sign in to comment.