@@ -21,6 +21,22 @@ public function testFallthroughReasonSerialization()
2121 $ this ->assertEquals ('FALLTHROUGH ' , (string )$ reason );
2222 }
2323
24+ public function testFallthroughReasonNotInExperimentSerialization ()
25+ {
26+ $ reason = EvaluationReason::fallthrough (false );
27+ $ json = json_encode ($ reason );
28+ $ this ->assertEquals (array ('kind ' => 'FALLTHROUGH ' ), json_decode ($ json , true ));
29+ $ this ->assertEquals ('FALLTHROUGH ' , (string )$ reason );
30+ }
31+
32+ public function testFallthroughReasonInExperimentSerialization ()
33+ {
34+ $ reason = EvaluationReason::fallthrough (true );
35+ $ json = json_encode ($ reason );
36+ $ this ->assertEquals (array ('kind ' => 'FALLTHROUGH ' , 'inExperiment ' => true ), json_decode ($ json , true ));
37+ $ this ->assertEquals ('FALLTHROUGH ' , (string )$ reason );
38+ }
39+
2440 public function testTargetMatchReasonSerialization ()
2541 {
2642 $ reason = EvaluationReason::targetMatch ();
@@ -33,17 +49,43 @@ public function testRuleMatchReasonSerialization()
3349 {
3450 $ reason = EvaluationReason::ruleMatch (0 , 'id ' );
3551 $ json = json_encode ($ reason );
36- $ this ->assertEquals (array ('kind ' => 'RULE_MATCH ' , 'ruleIndex ' => 0 , 'ruleId ' => 'id ' ),
37- json_decode ($ json , true ));
52+ $ this ->assertEquals (
53+ array ('kind ' => 'RULE_MATCH ' , 'ruleIndex ' => 0 , 'ruleId ' => 'id ' ),
54+ json_decode ($ json , true )
55+ );
56+ $ this ->assertEquals ('RULE_MATCH(0,id) ' , (string )$ reason );
57+ }
58+
59+ public function testRuleMatchReasonNotInExperimentSerialization ()
60+ {
61+ $ reason = EvaluationReason::ruleMatch (0 , 'id ' , false );
62+ $ json = json_encode ($ reason );
63+ $ this ->assertEquals (
64+ array ('kind ' => 'RULE_MATCH ' , 'ruleIndex ' => 0 , 'ruleId ' => 'id ' ),
65+ json_decode ($ json , true )
66+ );
67+ $ this ->assertEquals ('RULE_MATCH(0,id) ' , (string )$ reason );
68+ }
69+
70+ public function testRuleMatchReasonInExperimentSerialization ()
71+ {
72+ $ reason = EvaluationReason::ruleMatch (0 , 'id ' , true );
73+ $ json = json_encode ($ reason );
74+ $ this ->assertEquals (
75+ array ('kind ' => 'RULE_MATCH ' , 'ruleIndex ' => 0 , 'ruleId ' => 'id ' , 'inExperiment ' => true ),
76+ json_decode ($ json , true )
77+ );
3878 $ this ->assertEquals ('RULE_MATCH(0,id) ' , (string )$ reason );
3979 }
4080
4181 public function testPrerequisiteFailedReasonSerialization ()
4282 {
4383 $ reason = EvaluationReason::prerequisiteFailed ('key ' );
4484 $ json = json_encode ($ reason );
45- $ this ->assertEquals (array ('kind ' => 'PREREQUISITE_FAILED ' , 'prerequisiteKey ' => 'key ' ),
46- json_decode ($ json , true ));
85+ $ this ->assertEquals (
86+ array ('kind ' => 'PREREQUISITE_FAILED ' , 'prerequisiteKey ' => 'key ' ),
87+ json_decode ($ json , true )
88+ );
4789 $ this ->assertEquals ('PREREQUISITE_FAILED(key) ' , (string )$ reason );
4890 }
4991
0 commit comments