2222require_once 'Google/Cache/File.php ' ;
2323require_once 'Google/Cache/Memcache.php ' ;
2424require_once 'Google/Cache/Apc.php ' ;
25+ require_once 'Google/Cache/Null.php ' ;
2526
2627class CacheTest extends BaseTest {
27-
28+
2829 public function testFile () {
2930 $ dir = sys_get_temp_dir () . '/google-api-php-client/tests ' ;
3031 $ client = $ this ->getClient ();
@@ -36,10 +37,34 @@ public function testFile() {
3637 $ cache = new Google_Cache_File ($ client );
3738 $ cache ->set ('foo ' , 'bar ' );
3839 $ this ->assertEquals ($ cache ->get ('foo ' ), 'bar ' );
39-
40+
4041 $ this ->getSetDelete ($ cache );
4142 }
4243
44+ public function testNull ()
45+ {
46+ if (!function_exists ('memcache_connect ' )) {
47+ $ this ->markTestSkipped ('Test requires memcache ' );
48+ }
49+ $ client = $ this ->getClient ();
50+ $ cache = new Google_Cache_Null ($ client );
51+ $ client ->setCache ($ cache );
52+
53+ $ cache ->set ('foo ' , 'bar ' );
54+ $ cache ->delete ('foo ' );
55+ $ this ->assertEquals (false , $ cache ->get ('foo ' ));
56+
57+ $ cache ->set ('foo.1 ' , 'bar.1 ' );
58+ $ this ->assertEquals ($ cache ->get ('foo.1 ' ), false );
59+
60+ $ cache ->set ('foo ' , 'baz ' );
61+ $ this ->assertEquals ($ cache ->get ('foo ' ), false );
62+
63+ $ cache ->set ('foo ' , null );
64+ $ cache ->delete ('foo ' );
65+ $ this ->assertEquals ($ cache ->get ('foo ' ), false );
66+ }
67+
4368 public function testMemcache () {
4469 if (!function_exists ('memcache_connect ' )) {
4570 $ this ->markTestSkipped ('Test requires memcache ' );
@@ -48,12 +73,12 @@ public function testMemcache() {
4873 if (!$ client ->getClassConfig ('Google_Cache_Memcache ' , 'host ' )) {
4974 $ this ->markTestSkipped ('Test requires memcache host specified ' );
5075 }
51-
76+
5277 $ cache = new Google_Cache_Memcache ($ client );
53-
54- $ this ->getSetDelete ($ cache );
78+
79+ $ this ->getSetDelete ($ cache );
5580 }
56-
81+
5782 public function testAPC () {
5883 if (!function_exists ('apc_add ' )) {
5984 $ this ->markTestSkipped ('Test requires APC ' );
@@ -63,15 +88,15 @@ public function testAPC() {
6388 }
6489 $ client = $ this ->getClient ();
6590 $ cache = new Google_Cache_APC ($ client );
66-
91+
6792 $ this ->getSetDelete ($ cache );
6893 }
69-
94+
7095 public function getSetDelete ($ cache ) {
7196 $ cache ->set ('foo ' , 'bar ' );
7297 $ cache ->delete ('foo ' );
7398 $ this ->assertEquals (false , $ cache ->get ('foo ' ));
74-
99+
75100 $ cache ->set ('foo.1 ' , 'bar.1 ' );
76101 $ cache ->delete ('foo.1 ' );
77102 $ this ->assertEquals ($ cache ->get ('foo.1 ' ), false );
@@ -89,7 +114,7 @@ public function getSetDelete($cache) {
89114 $ cache ->set ('foo ' , $ obj );
90115 $ cache ->delete ('foo ' );
91116 $ this ->assertEquals ($ cache ->get ('foo ' ), false );
92-
117+
93118 $ cache ->set ('foo.1 ' , 'bar.1 ' );
94119 $ this ->assertEquals ($ cache ->get ('foo.1 ' ), 'bar.1 ' );
95120
0 commit comments