@@ -2333,11 +2333,60 @@ public function testZRangeByLex() {
23332333 $ this ->assertEquals ($ this ->redis ->zRangeByLex ('key ' , '- ' , '[c ' ), Array ('a ' , 'b ' , 'c ' ));
23342334 $ this ->assertEquals ($ this ->redis ->zRangeByLex ('key ' , '(e ' , '+ ' ), Array ('f ' , 'g ' ));
23352335
2336- // with limit offset
2336+ // with limit offset
23372337 $ this ->assertEquals ($ this ->redis ->zRangeByLex ('key ' , '- ' , '[c ' , 1 , 2 ), Array ('b ' , 'c ' ) );
23382338 $ this ->assertEquals ($ this ->redis ->zRangeByLex ('key ' , '- ' , '(c ' , 1 , 2 ), Array ('b ' ));
23392339 }
23402340
2341+ public function testZLexCount () {
2342+ if (version_compare ($ this ->version , "2.8.9 " , "lt " )) {
2343+ $ this ->MarkTestSkipped ();
2344+ return ;
2345+ }
2346+
2347+ $ this ->redis ->del ('key ' );
2348+ foreach (range ('a ' , 'g ' ) as $ c ) {
2349+ $ entries [] = $ c ;
2350+ $ this ->redis ->zAdd ('key ' , 0 , $ c );
2351+ }
2352+
2353+ /* Special -/+ values */
2354+ $ this ->assertEquals ($ this ->redis ->zLexCount ('key ' , '- ' , '- ' ), 0 );
2355+ $ this ->assertEquals ($ this ->redis ->zLexCount ('key ' , '- ' , '+ ' ), count ($ entries ));
2356+
2357+ /* Verify invalid arguments return FALSE */
2358+ $ this ->assertFalse (@$ this ->redis ->zLexCount ('key ' , '[a ' , 'bad ' ));
2359+ $ this ->assertFalse (@$ this ->redis ->zLexCount ('key ' , 'bad ' , '[a ' ));
2360+
2361+ /* Now iterate through */
2362+ $ start = $ entries [0 ];
2363+ for ($ i = 1 ; $ i < count ($ entries ); $ i ++) {
2364+ $ end = $ entries [$ i ];
2365+ $ this ->assertEquals ($ this ->redis ->zLexCount ('key ' , "[ $ start " , "[ $ end " ), $ i + 1 );
2366+ $ this ->assertEquals ($ this ->redis ->zLexCount ('key ' , "[ $ start " , "( $ end " ), $ i );
2367+ $ this ->assertEquals ($ this ->redis ->zLexCount ('key ' , "( $ start " , "( $ end " ), $ i - 1 );
2368+ }
2369+ }
2370+
2371+ public function testZRemRangeByLex () {
2372+ if (version_compare ($ this ->version , "2.8.9 " , "lt " )) {
2373+ $ this ->MarkTestSkipped ();
2374+ return ;
2375+ }
2376+
2377+ $ this ->redis ->del ('key ' );
2378+ $ this ->redis ->zAdd ('key ' , 0 , 'a ' , 0 , 'b ' , 0 , 'c ' );
2379+ $ this ->assertEquals ($ this ->redis ->zRemRangeByLex ('key ' , '- ' , '+ ' ), 3 );
2380+
2381+ $ this ->redis ->zAdd ('key ' , 0 , 'a ' , 0 , 'b ' , 0 , 'c ' );
2382+ $ this ->assertEquals ($ this ->redis ->zRemRangeByLex ('key ' , '[a ' , '[c ' ), 3 );
2383+
2384+ $ this ->redis ->zAdd ('key ' , 0 , 'a ' , 0 , 'b ' , 0 , 'c ' );
2385+ $ this ->assertEquals ($ this ->redis ->zRemRangeByLex ('key ' , '[a ' , '(a ' ), 0 );
2386+ $ this ->assertEquals ($ this ->redis ->zRemRangeByLex ('key ' , '(a ' , '(c ' ), 1 );
2387+ $ this ->assertEquals ($ this ->redis ->zRemRangeByLex ('key ' , '[a ' , '[c ' ), 2 );
2388+ }
2389+
23412390 public function testHashes () {
23422391 $ this ->redis ->del ('h ' , 'key ' );
23432392 $ this ->assertTrue (0 === $ this ->redis ->hLen ('h ' ));
0 commit comments