@@ -275,6 +275,40 @@ public function testActivateInvalidAttributes()
275275 $ this ->assertNull ($ optlyObject ->activate ('test_experiment ' , 'test_user ' , 42 ));
276276 }
277277
278+ public function testActivateUserInNoVariation ()
279+ {
280+ $ userAttributes = [
281+ 'device_type ' => 'iPhone ' ,
282+ 'company ' => 'Optimizely ' ,
283+ 'location ' => 'San Francisco '
284+ ];
285+
286+ $ this ->eventBuilderMock ->expects ($ this ->never ())
287+ ->method ('createImpressionEvent ' );
288+
289+ $ this ->loggerMock ->expects ($ this ->exactly (3 ))
290+ ->method ('log ' );
291+ $ this ->loggerMock ->expects ($ this ->at (0 ))
292+ ->method ('log ' )
293+ ->with (Logger::DEBUG , 'Assigned bucket 8495 to user "not_in_variation_user". ' );
294+ $ this ->loggerMock ->expects ($ this ->at (1 ))
295+ ->method ('log ' )
296+ ->with (Logger::INFO ,
297+ 'User "not_in_variation_user" is in no variation. ' );
298+ $ this ->loggerMock ->expects ($ this ->at (2 ))
299+ ->method ('log ' )
300+ ->with (Logger::INFO , 'Not activating user "not_in_variation_user". ' );
301+
302+ $ optlyObject = new Optimizely ($ this ->datafile , new ValidEventDispatcher (), $ this ->loggerMock );
303+
304+ $ eventBuilder = new \ReflectionProperty (Optimizely::class, '_eventBuilder ' );
305+ $ eventBuilder ->setAccessible (true );
306+ $ eventBuilder ->setValue ($ optlyObject , $ this ->eventBuilderMock );
307+
308+ // Call activate
309+ $ this ->assertNull ($ optlyObject ->activate ('test_experiment ' , 'not_in_variation_user ' , $ userAttributes ));
310+ }
311+
278312 public function testActivateNoAudienceNoAttributes ()
279313 {
280314 $ this ->eventBuilderMock ->expects ($ this ->once ())
0 commit comments