@@ -1716,6 +1716,28 @@ public function testRpopLpush() {
1716
1716
$ this ->assertTrue (array () === $ this ->redis ->lgetRange ('x ' , 0 , -1 ));
1717
1717
$ this ->assertTrue (array () === $ this ->redis ->lgetRange ('y ' , 0 , -1 ));
1718
1718
1719
+ }
1720
+
1721
+ public function testBRpopLpush () {
1722
+
1723
+ // standard case.
1724
+ $ this ->redis ->delete ('x ' , 'y ' );
1725
+ $ this ->redis ->lpush ('x ' , 'abc ' );
1726
+ $ this ->redis ->lpush ('x ' , 'def ' ); // x = [def, abc]
1727
+
1728
+ $ this ->redis ->lpush ('y ' , '123 ' );
1729
+ $ this ->redis ->lpush ('y ' , '456 ' ); // y = [456, 123]
1730
+
1731
+ $ this ->assertEquals ($ this ->redis ->brpoplpush ('x ' , 'y ' , 1 ), 'abc ' ); // we RPOP x, yielding abc.
1732
+ $ this ->assertEquals ($ this ->redis ->lgetRange ('x ' , 0 , -1 ), array ('def ' )); // only def remains in x.
1733
+ $ this ->assertEquals ($ this ->redis ->lgetRange ('y ' , 0 , -1 ), array ('abc ' , '456 ' , '123 ' )); // abc has been lpushed to y.
1734
+
1735
+ // with an empty source, expecting no change.
1736
+ $ this ->redis ->delete ('x ' , 'y ' );
1737
+ $ this ->assertTrue (FALSE === $ this ->redis ->brpoplpush ('x ' , 'y ' , 1 ));
1738
+ $ this ->assertTrue (array () === $ this ->redis ->lgetRange ('x ' , 0 , -1 ));
1739
+ $ this ->assertTrue (array () === $ this ->redis ->lgetRange ('y ' , 0 , -1 ));
1740
+
1719
1741
}
1720
1742
1721
1743
public function testZAddFirstArg () {
0 commit comments