1
1
<?php
2
- require_once 'PHPUnit/Framework/TestCase .php ' ;
2
+ require_once 'PHPUnit.php ' ;
3
3
4
4
echo "Note: these tests might take up to a minute. Don't worry :-) \n" ;
5
5
6
- class Redis_Test extends PHPUnit_Framework_TestCase
6
+ class Redis_Test extends PHPUnit_TestCase
7
7
{
8
8
const HOST = '127.0.0.1 ' ;
9
9
const PORT = 6379 ;
@@ -34,7 +34,7 @@ public function tearDown()
34
34
if ($ this ->redis ) {
35
35
$ this ->redis ->close ();
36
36
}
37
- unset($ this ->redis );
37
+ // unset($this->redis);
38
38
}
39
39
40
40
public function reset ()
@@ -52,7 +52,6 @@ public function testPing()
52
52
while ($ count --) {
53
53
$ this ->assertEquals ('+PONG ' , $ this ->redis ->ping ());
54
54
}
55
-
56
55
}
57
56
58
57
public function testBitsets () {
@@ -416,27 +415,27 @@ public function testDelete()
416
415
$ this ->redis ->set ($ key , 'val ' );
417
416
$ this ->assertEquals ('val ' , $ this ->redis ->get ($ key ));
418
417
$ this ->assertEquals (1 , $ this ->redis ->delete ($ key ));
419
- $ this ->assertEquals (null , $ this ->redis ->get ($ key ));
418
+ $ this ->assertEquals (false , $ this ->redis ->get ($ key ));
420
419
421
420
// multiple, all existing
422
421
$ this ->redis ->set ('x ' , 0 );
423
422
$ this ->redis ->set ('y ' , 1 );
424
423
$ this ->redis ->set ('z ' , 2 );
425
424
$ this ->assertEquals (3 , $ this ->redis ->delete ('x ' , 'y ' , 'z ' ));
426
- $ this ->assertEquals (NULL , $ this ->redis ->get ('x ' ));
427
- $ this ->assertEquals (NULL , $ this ->redis ->get ('y ' ));
428
- $ this ->assertEquals (NULL , $ this ->redis ->get ('z ' ));
425
+ $ this ->assertEquals (false , $ this ->redis ->get ('x ' ));
426
+ $ this ->assertEquals (false , $ this ->redis ->get ('y ' ));
427
+ $ this ->assertEquals (false , $ this ->redis ->get ('z ' ));
429
428
430
429
// multiple, none existing
431
430
$ this ->assertEquals (0 , $ this ->redis ->delete ('x ' , 'y ' , 'z ' ));
432
- $ this ->assertEquals (NULL , $ this ->redis ->get ('x ' ));
433
- $ this ->assertEquals (NULL , $ this ->redis ->get ('y ' ));
434
- $ this ->assertEquals (NULL , $ this ->redis ->get ('z ' ));
431
+ $ this ->assertEquals (false , $ this ->redis ->get ('x ' ));
432
+ $ this ->assertEquals (false , $ this ->redis ->get ('y ' ));
433
+ $ this ->assertEquals (false , $ this ->redis ->get ('z ' ));
435
434
436
435
// multiple, some existing
437
436
$ this ->redis ->set ('y ' , 1 );
438
437
$ this ->assertEquals (1 , $ this ->redis ->delete ('x ' , 'y ' , 'z ' ));
439
- $ this ->assertEquals (NULL , $ this ->redis ->get ('y ' ));
438
+ $ this ->assertEquals (false , $ this ->redis ->get ('y ' ));
440
439
441
440
$ this ->redis ->set ('x ' , 0 );
442
441
$ this ->redis ->set ('y ' , 1 );
@@ -1682,10 +1681,10 @@ public function testZX() {
1682
1681
$ this ->assertTrue (0 === $ this ->redis ->zUnion ('keyU ' , array ('X ' , 'Y ' )));
1683
1682
$ this ->assertTrue (array () === $ this ->redis ->zRange ('keyU ' , 0 , -1 ));
1684
1683
1685
- // !Exist U Exist
1686
- $ this ->redis ->delete ('keyU ' );
1687
- $ this -> assertTrue ( 2 === $ this ->redis ->zUnion ('keyU ' , array ('key1 ' , 'X ' )));
1688
- $ this ->assertTrue ($ this -> redis -> zRange ( ' key1 ' , 0 , - 1 ) === $ this ->redis ->zRange ('keyU ' , 0 , - 1 ));
1684
+ // !Exist U Exist → 0
1685
+ $ this ->redis ->delete ('keyU ' , ' X ' );
1686
+ var_dump ( $ this ->redis ->zUnion ('keyU ' , array ('key1 ' , 'X ' )));
1687
+ $ this ->assertTrue (0 === $ this ->redis ->zUnion ('keyU ' , array ( ' key1 ' , ' X ' ) ));
1689
1688
1690
1689
// test weighted zUnion
1691
1690
$ this ->redis ->delete ('keyZ ' );
@@ -2733,7 +2732,12 @@ private function checkSerializer($mode) {
2733
2732
$ this ->assertTrue ($ this ->redis ->setOption (Redis::OPT_SERIALIZER , Redis::SERIALIZER_NONE ) === TRUE ); // set ok
2734
2733
$ this ->assertTrue ($ this ->redis ->getOption (Redis::OPT_SERIALIZER ) === Redis::SERIALIZER_NONE ); // get ok
2735
2734
}
2736
-
2737
2735
}
2738
2736
2737
+ $ suite = new PHPUnit_TestSuite ("Redis_Test " );
2738
+ $ result = PHPUnit::run ($ suite );
2739
+
2740
+ echo $ result ->toString ();
2741
+
2742
+
2739
2743
?>
0 commit comments