Skip to content

Commit ebfed83

Browse files
fix(ForcedDecision): remove config-ready check from forced-decision apis (#236)
Co-authored-by: mnoman09 <[email protected]>
1 parent e5bfc38 commit ebfed83

File tree

2 files changed

+0
-42
lines changed

2 files changed

+0
-42
lines changed

src/Optimizely/OptimizelyUserContext.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ public function __construct(Optimizely $optimizelyClient, $userId, array $attrib
3737

3838
public function setForcedDecision($context, $decision)
3939
{
40-
// check if SDK is ready
41-
if (!$this->optimizelyClient->isValid()) {
42-
return false;
43-
}
4440
$flagKey = $context->getFlagKey();
4541
if (!isset($flagKey)) {
4642
return false;
@@ -59,19 +55,11 @@ public function setForcedDecision($context, $decision)
5955

6056
public function getForcedDecision($context)
6157
{
62-
// check if SDK is ready
63-
if (!$this->optimizelyClient->isValid()) {
64-
return null;
65-
}
6658
return $this->findForcedDecision($context);
6759
}
6860

6961
public function removeForcedDecision($context)
7062
{
71-
// check if SDK is ready
72-
if (!$this->optimizelyClient->isValid()) {
73-
return false;
74-
}
7563
$index = $this->findExistingRuleAndFlagKey($context);
7664
if ($index != -1) {
7765
array_splice($this->forcedDecisions, $index, 1);
@@ -82,11 +70,6 @@ public function removeForcedDecision($context)
8270

8371
public function removeAllForcedDecisions()
8472
{
85-
// check if SDK is ready
86-
if (!$this->optimizelyClient->isValid()) {
87-
return false;
88-
}
89-
9073
$this->forcedDecisions = [];
9174
return true;
9275
}

tests/OptimizelyUserContextTest.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -264,31 +264,6 @@ public function testJsonSerialize()
264264

265265
// Forced decision tests
266266

267-
public function testForcedDecisionInvalidDatafileReturnStatus()
268-
{
269-
$userId = 'test_user';
270-
$attributes = [ "browser" => "chrome"];
271-
272-
$invalidOptlyObject = new Optimizely("Invalid datafile");
273-
274-
$optUserContext = new OptimizelyUserContext($invalidOptlyObject, $userId, $attributes);
275-
276-
$context = new OptimizelyDecisionContext("flag1", "targeted_delivery");
277-
$decision = new OptimizelyForcedDecision("variation1");
278-
279-
$setForcedDecision = $optUserContext->setForcedDecision($context, $decision);
280-
$this->assertFalse($setForcedDecision);
281-
282-
$getForcedDecision = $optUserContext->getForcedDecision($context);
283-
$this->assertNull($getForcedDecision);
284-
285-
$removeForcedDecision = $optUserContext->removeForcedDecision($context);
286-
$this->assertFalse($removeForcedDecision);
287-
288-
$removeAllForcedDecision = $optUserContext->removeAllForcedDecisions();
289-
$this->assertFalse($removeAllForcedDecision);
290-
}
291-
292267
public function testForcedDecisionValidDatafileReturnStatus()
293268
{
294269
$userId = 'test_user';

0 commit comments

Comments
 (0)