Skip to content

Commit cf16c18

Browse files
authored
Merge 60afd81 into 930400f
2 parents 930400f + 60afd81 commit cf16c18

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/Optimizely/OptimizelyConfig/OptimizelyFeature.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,14 @@ public function getDeliveryRules()
9999
}
100100

101101
/**
102+
* @deprecated. Use 'experimentRules' and 'deliveryRules' instead.
103+
*
102104
* @return array Map of Experiment Keys to OptimizelyExperiments.
103105
*/
104106
public function getExperimentsMap()
105107
{
106-
# This experimentsMap is deprecated. Use experimentRules and deliveryRules instead.
108+
trigger_error('Method ' . __METHOD__ . ' is deprecated. Use experimentRules and deliveryRules instead.', E_USER_WARNING);
109+
107110
return $this->experimentsMap;
108111
}
109112

tests/OptimizelyConfigTests/OptimizelyEntitiesTest.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ public function testOptimizelyFeatureEntity()
9696

9797
$this->assertEquals("id", $optFeature->getId());
9898
$this->assertEquals("key", $optFeature->getKey());
99-
$this->assertEquals(["a" => "apple"], $optFeature->getExperimentsMap());
99+
# Suppressing warning in getExperimentMap to pass testcase
100+
$this->assertEquals(["a" => "apple"], @$optFeature->getExperimentsMap());
100101
$this->assertEquals(["o" => "orange"], $optFeature->getVariablesMap());
101102
$this->assertEquals([], $optFeature->getExperimentRules());
102103
$this->assertEquals([], $optFeature->getDeliveryRules());
@@ -115,6 +116,26 @@ public function testOptimizelyFeatureEntity()
115116
$this->assertEquals($expectedJson, json_encode($optFeature));
116117
}
117118

119+
/**
120+
* @expectedException PHPUnit_Framework_Error
121+
*/
122+
public function testOptimizelyFeatureGetExperimentsMapEmitsWarning()
123+
{
124+
$optFeature = new OptimizelyFeature(
125+
"id",
126+
"key",
127+
["a" => "apple"],
128+
["o" => "orange"],
129+
[],
130+
[]
131+
);
132+
133+
$this->assertEquals("id", $optFeature->getId());
134+
$this->assertEquals("key", $optFeature->getKey());
135+
136+
$this->assertEquals(["a" => "apple"], $optFeature->getExperimentsMap());
137+
}
138+
118139
public function testOptimizelyVariableEntity()
119140
{
120141
$optVariable = new OptimizelyVariable(

0 commit comments

Comments
 (0)