@@ -453,9 +453,9 @@ public function testStr() {
453
453
$ this ->assertTrue ($ this ->redis ->get ('keyNotExist ' ) === 'value ' );
454
454
455
455
$ this ->redis ->set ('key ' , 'This is a string ' ) ;
456
- $ this ->assertTrue ($ this ->redis ->substr ('key ' , 0 , 3 ) === 'This ' );
457
- $ this ->assertTrue ($ this ->redis ->substr ('key ' , -6 , -1 ) === 'string ' );
458
- $ this ->assertTrue ($ this ->redis ->substr ('key ' , -6 , 100000 ) === 'string ' );
456
+ $ this ->assertTrue ($ this ->redis ->getRange ('key ' , 0 , 3 ) === 'This ' );
457
+ $ this ->assertTrue ($ this ->redis ->getRange ('key ' , -6 , -1 ) === 'string ' );
458
+ $ this ->assertTrue ($ this ->redis ->getRange ('key ' , -6 , 100000 ) === 'string ' );
459
459
$ this ->assertTrue ($ this ->redis ->get ('key ' ) === 'This is a string ' );
460
460
461
461
$ this ->redis ->set ('key ' , 'This is a string ' ) ;
@@ -1778,6 +1778,25 @@ public function testHashes() {
1778
1778
1779
1779
}
1780
1780
1781
+ public function testSetRange () {
1782
+
1783
+ $ this ->redis ->delete ('key ' );
1784
+ $ this ->redis ->set ('key ' , 'hello world ' );
1785
+ $ this ->redis ->setRange ('key ' , 6 , 'redis ' );
1786
+ $ this ->assertTrue ('hello redis ' === $ this ->redis ->get ('key ' ));
1787
+ $ this ->redis ->setRange ('key ' , 6 , 'you ' ); // don't cut off the end
1788
+ $ this ->assertTrue ('hello youis ' === $ this ->redis ->get ('key ' ));
1789
+
1790
+ $ this ->assertTrue (FALSE === $ this ->redis ->setRange ('key ' , -1 , 'plop ' )); // doesn't work with negative offsets
1791
+
1792
+ // fill with zeros if needed
1793
+ $ this ->redis ->delete ('key ' );
1794
+ $ this ->redis ->setRange ('key ' , 6 , 'foo ' );
1795
+ $ this ->assertTrue ("\x00\x00\x00\x00\x00\x00foo " === $ this ->redis ->get ('key ' ));
1796
+
1797
+
1798
+ }
1799
+
1781
1800
public function testMultiExec () {
1782
1801
$ this ->sequence (Redis::MULTI );
1783
1802
0 commit comments