@@ -561,22 +561,30 @@ public function testSortAsc() {
561561 // sort by age and get IDs
562562 $ byAgeAsc = array ('3 ' ,'1 ' ,'2 ' ,'4 ' );
563563 $ this ->assertEquals ($ byAgeAsc , $ this ->redis ->sortAsc ('person:id ' , 'person:age_* ' ));
564+ $ this ->assertEquals ($ byAgeAsc , $ this ->redis ->sort ('person:id ' , array ('by ' => 'person:age_* ' , 'sort ' => 'asc ' )));
564565 $ this ->assertEquals (array ('1 ' , '2 ' , '3 ' , '4 ' ), $ this ->redis ->sortAsc ('person:id ' , NULL )); // check that NULL works.
565566 $ this ->assertEquals (array ('1 ' , '2 ' , '3 ' , '4 ' ), $ this ->redis ->sortAsc ('person:id ' , NULL , NULL )); // for all fields.
567+ $ this ->assertEquals (array ('1 ' , '2 ' , '3 ' , '4 ' ), $ this ->redis ->sort ('person:id ' , array ('sort ' => 'asc ' )));
566568
567569 // sort by age and get names
568570 $ byAgeAsc = array ('Carol ' ,'Alice ' ,'Bob ' ,'Dave ' );
569571 $ this ->assertEquals ($ byAgeAsc , $ this ->redis ->sortAsc ('person:id ' , 'person:age_* ' , 'person:name_* ' ));
572+ $ this ->assertEquals ($ byAgeAsc , $ this ->redis ->sort ('person:id ' , array ('by ' => 'person:age_* ' , 'get ' => 'person:name_* ' , 'sort ' => 'asc ' )));
570573
571574 $ this ->assertEquals (array_slice ($ byAgeAsc , 0 , 2 ), $ this ->redis ->sortAsc ('person:id ' , 'person:age_* ' , 'person:name_* ' , 0 , 2 ));
575+ $ this ->assertEquals (array_slice ($ byAgeAsc , 0 , 2 ), $ this ->redis ->sort ('person:id ' , array ('by ' => 'person:age_* ' , 'get ' => 'person:name_* ' , 'limit ' => array (0 , 2 ), 'sort ' => 'asc ' )));
576+ return ;
572577 $ this ->assertEquals (array_slice ($ byAgeAsc , 1 , 2 ), $ this ->redis ->sortAsc ('person:id ' , 'person:age_* ' , 'person:name_* ' , 1 , 2 ));
578+ $ this ->assertEquals (array_slice ($ byAgeAsc , 1 , 2 ), $ this ->redis ->sort ('person:id ' , array ('by ' => 'person:age_* ' , 'get ' => 'person:name_* ' , 'limit ' => array (1 , 2 ), 'sort ' => 'asc ' )));
573579 $ this ->assertEquals (array_slice ($ byAgeAsc , 0 , 3 ), $ this ->redis ->sortAsc ('person:id ' , 'person:age_* ' , 'person:name_* ' , NULL , 3 )); // NULL is transformed to 0 if there is something after it.
574580 $ this ->assertEquals ($ byAgeAsc , $ this ->redis ->sortAsc ('person:id ' , 'person:age_* ' , 'person:name_* ' , 0 , 4 ));
581+ $ this ->assertEquals ($ byAgeAsc , $ this ->redis ->sort ('person:id ' , array ('by ' => 'person:age_* ' , 'get ' => 'person:name_* ' , 'limit ' => array (0 , 4 ))));
575582 $ this ->assertEquals (array (), $ this ->redis ->sortAsc ('person:id ' , 'person:age_* ' , 'person:name_* ' , NULL , NULL )); // NULL, NULL is the same as (0,0). That returns no element.
576583
577584 // sort by salary and get ages
578585 $ agesBySalaryAsc = array ('34 ' , '27 ' , '25 ' , '41 ' );
579586 $ this ->assertEquals ($ agesBySalaryAsc , $ this ->redis ->sortAsc ('person:id ' , 'person:salary_* ' , 'person:age_* ' ));
587+ $ this ->assertEquals ($ agesBySalaryAsc , $ this ->redis ->sort ('person:id ' , array ('by ' => 'person:salary_* ' , 'get ' => 'person:age_* ' , 'sort ' => 'asc ' )));
580588
581589
582590 // sort non-alpha doesn't change all-string lists
@@ -589,9 +597,11 @@ public function testSortAsc() {
589597
590598 // SORT list → [ghi, def, abc]
591599 $ this ->assertEquals (array_reverse ($ list ), $ this ->redis ->sortAsc ('list ' ));
600+ $ this ->assertEquals (array_reverse ($ list ), $ this ->redis ->sort ('list ' , array ('sort ' => 'asc ' )));
592601
593602 // SORT list ALPHA → [abc, def, ghi]
594603 $ this ->assertEquals ($ list , $ this ->redis ->sortAscAlpha ('list ' ));
604+ $ this ->assertEquals ($ list , $ this ->redis ->sort ('list ' , array ('sort ' => 'asc ' , 'alpha ' => TRUE )));
595605 }
596606
597607 public function testSortDesc () {
0 commit comments