88use DDTrace \FeatureFlags \EvaluationReason ;
99use DDTrace \FeatureFlags \EvaluationType ;
1010use DDTrace \FeatureFlags \Internal \Evaluator ;
11- use DDTrace \FeatureFlags \Internal \NativeEvaluator ;
1211use DDTrace \FeatureFlags \Internal \UnavailableEvaluator ;
1312use DDTrace \Log \LoggerInterface ;
1413use PHPUnit \Framework \TestCase ;
@@ -93,7 +92,7 @@ public function testContextNormalizesTargetingKeyAndPrimitiveAttributes()
9392 public function testUnavailableRuntimeReturnsDefaultWithProviderNotReadyDetailsAndWarning ()
9493 {
9594 $ logger = new RecordingLogger ();
96- $ client = new Client ( $ logger );
95+ $ client = $ this -> clientForEvaluator ( new UnavailableEvaluator (), $ logger );
9796
9897 $ value = $ client ->getBooleanValue ('checkout-redesign ' , true );
9998 $ details = $ client ->getStringDetails ('checkout-copy ' , 'fallback ' );
@@ -102,25 +101,19 @@ public function testUnavailableRuntimeReturnsDefaultWithProviderNotReadyDetailsA
102101 $ this ->assertSame ('fallback ' , $ details ->getValue ());
103102 $ this ->assertSame (EvaluationReason::ERROR , $ details ->getReason ());
104103 $ this ->assertSame (EvaluationErrorCode::PROVIDER_NOT_READY , $ details ->getErrorCode ());
105- $ this ->assertContains ($ details ->getErrorMessage (), array (
106- NativeEvaluator::WARNING_MESSAGE ,
107- UnavailableEvaluator::WARNING_MESSAGE ,
108- ));
104+ $ this ->assertSame (UnavailableEvaluator::WARNING_MESSAGE , $ details ->getErrorMessage ());
109105
110106 $ providerState = $ details ->getProviderState ();
111107 $ this ->assertSame (false , $ providerState ['ready ' ]);
112108 $ this ->assertSame (false , $ providerState ['productionRuntime ' ]);
113- $ this ->assertTrue (in_array ($ providerState ['reason ' ], array (
114- 'configuration_missing ' ,
115- 'runtime_unavailable ' ,
116- ), true ));
109+ $ this ->assertSame ('runtime_unavailable ' , $ providerState ['reason ' ]);
117110 $ this ->assertSame (array ($ details ->getErrorMessage ()), $ logger ->warnings ());
118111 }
119112
120113 public function testWarningIsEmittedOncePerClientNotOncePerEvaluation ()
121114 {
122115 $ logger = new RecordingLogger ();
123- $ client = new Client ( $ logger );
116+ $ client = $ this -> clientForEvaluator ( new ClientTestEvaluator (), $ logger );
124117
125118 $ client ->getBooleanValue ('flag-1 ' , false );
126119 $ client ->getBooleanValue ('flag-2 ' , false );
@@ -129,29 +122,19 @@ public function testWarningIsEmittedOncePerClientNotOncePerEvaluation()
129122 $ this ->assertCount (1 , $ logger ->warnings ());
130123 }
131124
132- public function testThrowingLoggerDoesNotChangeSuccessfulEvaluation ()
125+ public function testThrowingLoggerDoesNotChangeProviderNotReadyEvaluation ()
133126 {
134127 $ evaluator = new ClientTestEvaluator ();
135- $ evaluator ->setSuccess (
136- 'preview.flag ' ,
137- true ,
138- EvaluationReason::STATIC_REASON ,
139- 'on ' ,
140- array (),
141- array (),
142- array ('productionRuntime ' => false )
143- );
144128 $ logger = new ThrowingLogger ();
145129 $ client = $ this ->clientForEvaluator ($ evaluator , $ logger );
146130
147131 $ firstDetails = $ client ->getBooleanDetails ('preview.flag ' , false );
148132 $ secondDetails = $ client ->getBooleanDetails ('preview.flag ' , false );
149133
150- $ this ->assertTrue ($ firstDetails ->getValue ());
151- $ this ->assertSame (EvaluationReason::STATIC_REASON , $ firstDetails ->getReason ());
152- $ this ->assertSame ('on ' , $ firstDetails ->getVariant ());
153- $ this ->assertNull ($ firstDetails ->getErrorCode ());
154- $ this ->assertTrue ($ secondDetails ->getValue ());
134+ $ this ->assertFalse ($ firstDetails ->getValue ());
135+ $ this ->assertSame (EvaluationReason::ERROR , $ firstDetails ->getReason ());
136+ $ this ->assertSame (EvaluationErrorCode::PROVIDER_NOT_READY , $ firstDetails ->getErrorCode ());
137+ $ this ->assertFalse ($ secondDetails ->getValue ());
155138 $ this ->assertSame (1 , $ logger ->warningCount ());
156139 }
157140
0 commit comments