@@ -2506,6 +2506,52 @@ public function testGetEnabledFeaturesGivenFeaturesAreEnabledForUser()
2506
2506
);
2507
2507
}
2508
2508
2509
+ public function testGetEnabledFeaturesReturnsSortedFeatureKeys ()
2510
+ {
2511
+ $ optimizelyMock = $ this ->getMockBuilder (Optimizely::class)
2512
+ ->setConstructorArgs (array ($ this ->datafile ))
2513
+ ->setMethods (array ('isFeatureEnabled ' ))
2514
+ ->getMock ();
2515
+
2516
+ // Mock isFeatureEnabled and assert that isFeatureEnabled does get called in an unsorted order
2517
+ $ optimizelyMock ->expects ($ this ->at (0 ))
2518
+ ->method ('isFeatureEnabled ' )
2519
+ ->with ('boolean_feature ' , 'user_id ' , [])
2520
+ ->willReturn (true );
2521
+ $ optimizelyMock ->expects ($ this ->at (1 ))
2522
+ ->method ('isFeatureEnabled ' )
2523
+ ->with ('double_single_variable_feature ' , 'user_id ' , [])
2524
+ ->willReturn (true );
2525
+ $ optimizelyMock ->expects ($ this ->at (2 ))
2526
+ ->method ('isFeatureEnabled ' )
2527
+ ->with ('integer_single_variable_feature ' , 'user_id ' , [])
2528
+ ->willReturn (true );
2529
+ $ optimizelyMock ->expects ($ this ->at (3 ))
2530
+ ->method ('isFeatureEnabled ' )
2531
+ ->with ('boolean_single_variable_feature ' , 'user_id ' , [])
2532
+ ->willReturn (true );
2533
+ $ optimizelyMock ->expects ($ this ->at (4 ))
2534
+ ->method ('isFeatureEnabled ' )
2535
+ ->with ('string_single_variable_feature ' , 'user_id ' , [])
2536
+ ->willReturn (true );
2537
+ $ optimizelyMock ->expects ($ this ->at (5 ))
2538
+ ->method ('isFeatureEnabled ' )
2539
+ ->with ('multi_variate_feature ' , 'user_id ' , [])
2540
+ ->willReturn (true );
2541
+
2542
+ $ this ->assertEquals (
2543
+ [
2544
+ 'boolean_feature ' ,
2545
+ 'boolean_single_variable_feature ' ,
2546
+ 'double_single_variable_feature ' ,
2547
+ 'integer_single_variable_feature ' ,
2548
+ 'multi_variate_feature ' ,
2549
+ 'string_single_variable_feature '
2550
+ ],
2551
+ $ optimizelyMock ->getEnabledFeatures ("user_id " , [])
2552
+ );
2553
+ }
2554
+
2509
2555
public function testGetEnabledFeaturesWithUserAttributes ()
2510
2556
{
2511
2557
$ optimizelyMock = $ this ->getMockBuilder (Optimizely::class)
0 commit comments