@@ -1457,15 +1457,15 @@ public function testHashes() {
1457
1457
$ this ->redis ->delete ('h ' , 'key ' );
1458
1458
1459
1459
$ this ->assertTrue (0 === $ this ->redis ->hLen ('h ' ));
1460
- $ this ->assertTrue (TRUE === $ this ->redis ->hSet ('h ' , 'a ' , 'a-value ' ));
1460
+ $ this ->assertTrue (1 === $ this ->redis ->hSet ('h ' , 'a ' , 'a-value ' ));
1461
1461
$ this ->assertTrue (1 === $ this ->redis ->hLen ('h ' ));
1462
- $ this ->assertTrue (TRUE === $ this ->redis ->hSet ('h ' , 'b ' , 'b-value ' ));
1462
+ $ this ->assertTrue (1 === $ this ->redis ->hSet ('h ' , 'b ' , 'b-value ' ));
1463
1463
$ this ->assertTrue (2 === $ this ->redis ->hLen ('h ' ));
1464
1464
1465
1465
$ this ->assertTrue ('a-value ' === $ this ->redis ->hGet ('h ' , 'a ' )); // simple get
1466
1466
$ this ->assertTrue ('b-value ' === $ this ->redis ->hGet ('h ' , 'b ' )); // simple get
1467
1467
1468
- $ this ->assertTrue (FALSE === $ this ->redis ->hSet ('h ' , 'a ' , 'another-value ' )); // replacement
1468
+ $ this ->assertTrue (0 === $ this ->redis ->hSet ('h ' , 'a ' , 'another-value ' )); // replacement
1469
1469
$ this ->assertTrue ('another-value ' === $ this ->redis ->hGet ('h ' , 'a ' )); // get the new value
1470
1470
1471
1471
$ this ->assertTrue ('b-value ' === $ this ->redis ->hGet ('h ' , 'b ' )); // simple get
@@ -1508,7 +1508,6 @@ public function testHashes() {
1508
1508
$ this ->assertTrue (FALSE === $ this ->redis ->hIncrBy ('h ' , 'y ' , 1 ));
1509
1509
}
1510
1510
1511
-
1512
1511
public function testMultiExec () {
1513
1512
$ this ->sequence (Redis::MULTI );
1514
1513
}
@@ -1997,24 +1996,35 @@ protected function sequence($mode) {
1997
1996
->hexists ('hkey1 ' , 'key2 ' )
1998
1997
->hkeys ('hkey1 ' )
1999
1998
->hvals ('hkey1 ' )
2000
- // ->hgetall('hkey1')
2001
- //->hincrby()
1999
+ ->hgetall ('hkey1 ' )
2000
+ ->hset ('hkey1 ' , 'valn ' , 1 )
2001
+ ->hincrby ('hkey1 ' , 'valn ' , 4 )
2002
+ ->hincrby ('hkey1 ' , 'val-fail ' , 42 )
2003
+ ->hset ('hkey1 ' , 'val-fail ' , 'non-string ' )
2004
+ ->hget ('hkey1 ' , 'val-fail ' )
2005
+ ->hincrby ('hkey1 ' , 'val-fail ' , 42 )
2002
2006
->exec ();
2003
2007
2004
2008
$ i = 0 ;
2005
2009
$ this ->assertTrue (is_array ($ ret ));
2006
2010
$ this ->assertTrue ($ ret [$ i ++] <= 1 ); // delete
2007
- $ this ->assertTrue ($ ret [$ i ++] === TRUE ); // added 1 element
2008
- $ this ->assertTrue ($ ret [$ i ++] === TRUE ); // added 1 element
2009
- $ this ->assertTrue ($ ret [$ i ++] === TRUE ); // added 1 element
2011
+ $ this ->assertTrue ($ ret [$ i ++] === 1 ); // added 1 element
2012
+ $ this ->assertTrue ($ ret [$ i ++] === 1 ); // added 1 element
2013
+ $ this ->assertTrue ($ ret [$ i ++] === 1 ); // added 1 element
2010
2014
$ this ->assertTrue ($ ret [$ i ++] === 'value1 ' ); // hget
2011
2015
$ this ->assertTrue ($ ret [$ i ++] === 3 ); // hlen
2012
2016
$ this ->assertTrue ($ ret [$ i ++] === TRUE ); // hdel succeeded
2013
2017
$ this ->assertTrue ($ ret [$ i ++] === FALSE ); // hdel failed
2014
2018
$ this ->assertTrue ($ ret [$ i ++] === FALSE ); // hexists didn't find the deleted key
2015
2019
$ this ->assertTrue ($ ret [$ i ] === array ('key1 ' , 'key3 ' ) || $ ret [$ i ] === array ('key3 ' , 'key1 ' )); $ i ++; // hkeys
2016
2020
$ this ->assertTrue ($ ret [$ i ] === array ('value1 ' , 'value3 ' ) || $ ret [$ i ] === array ('value3 ' , 'value1 ' )); $ i ++; // hvals
2017
- //$this->assertTrue($ret[$i] === array('key1' => 'value1', 'key3' => 'value3') || $ret[$i] === array('key3' => 'value3', 'key1' => 'value1')); $i++; // hgetall
2021
+ $ this ->assertTrue ($ ret [$ i ] === array ('key1 ' => 'value1 ' , 'key3 ' => 'value3 ' ) || $ ret [$ i ] === array ('key3 ' => 'value3 ' , 'key1 ' => 'value1 ' )); $ i ++; // hgetall
2022
+ $ this ->assertTrue ($ ret [$ i ++] === 1 ); // added 1 element
2023
+ $ this ->assertTrue ($ ret [$ i ++] === 5 ); // added 4 to value 1 → 5
2024
+ $ this ->assertTrue ($ ret [$ i ++] === 42 ); // member doesn't exist → assume 0, and then add.
2025
+ $ this ->assertTrue ($ ret [$ i ++] === 0 ); // didn't add the element, already present, so 0.
2026
+ $ this ->assertTrue ($ ret [$ i ++] === 'non-string ' ); // hset succeeded
2027
+ $ this ->assertTrue ($ ret [$ i ++] === FALSE ); // member isn't a number → fail.
2018
2028
$ this ->assertTrue (count ($ ret ) === $ i );
2019
2029
2020
2030
}
0 commit comments