Skip to content

Commit 2a59b1f

Browse files
committed
refactor(isValid): Adds getter to access isValid attribute
1 parent fbf5499 commit 2a59b1f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Diff for: src/Optimizely/Optimizely.php

+8
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,14 @@ public function getFeatureVariableString($featureFlagKey, $variableKey, $userId,
771771
return $variableValue;
772772
}
773773

774+
/**
775+
* @return boolean Flag denoting if Optimizely Instance is valid.
776+
*/
777+
public function isValid()
778+
{
779+
return $this->_isValid;
780+
}
781+
774782
/**
775783
* Calls Validator::validateNonEmptyString for each value in array
776784
* Logs for each invalid value

Diff for: tests/OptimizelyTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ public function setUp()
7474
->getMock();
7575
}
7676

77+
public function testIsValidForInvalidOptimizelyObject()
78+
{
79+
$optlyObject = new Optimizely('Random datafile');
80+
$this->assertFalse($optlyObject->isValid());
81+
}
82+
83+
public function testIsValidForValidOptimizelyObject()
84+
{
85+
$optlyObject = new Optimizely($this->datafile);
86+
$this->assertTrue($optlyObject->isValid());
87+
}
88+
7789
public function testInitValidEventDispatcher()
7890
{
7991
$validDispatcher = new ValidEventDispatcher();

0 commit comments

Comments
 (0)