Changeset 280 in tests
- Timestamp:
- 12/22/2009 04:11:03 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-testcase/test_includes_cache.php
r170 r280 33 33 } 34 34 35 function test_add_get_0() { 36 $key = rand_str(); 37 $val = 0; 38 39 // you can store zero in the cache 40 $this->cache->add($key, $val); 41 $this->assertEquals($val, $this->cache->get($key)); 42 } 43 44 function test_add_get_null() { 45 $key = rand_str(); 46 $val = null; 47 48 // you can't store null in the cache 49 $this->assertFalse($this->cache->add($key, $val)); 50 $this->assertFalse($this->cache->get($key)); 51 } 52 53 function test_add() { 54 $key = rand_str(); 55 $val1 = rand_str(); 56 $val2 = rand_str(); 57 58 // add $key to the cache 59 $this->assertTrue($this->cache->add($key, $val1)); 60 $this->assertEquals($val1, $this->cache->get($key)); 61 // $key is in the cache, so reject new calls to add() 62 $this->assertFalse($this->cache->add($key, $val2)); 63 $this->assertEquals($val1, $this->cache->get($key)); 64 } 65 66 function test_replace() { 67 $key = rand_str(); 68 $val = rand_str(); 69 70 // memcached rejects replace() if the key does not exist 71 $this->assertFalse($this->cache->replace($key, $val)); 72 $this->assertFalse($this->cache->get($key)); 73 } 74 75 function test_set() { 76 $key = rand_str(); 77 $val = rand_str(); 78 79 // memcached accepts set() if the key does not exist 80 $this->assertTrue($this->cache->set($key, $val)); 81 $this->assertEquals($val, $this->cache->get($key)); 82 } 83 35 84 function test_flush() { 36 85 $key = rand_str(); … … 41 90 $this->assertEquals($val, $this->cache->get($key)); 42 91 $this->cache->flush(); 43 $this->assertEquals(NULL, $this->cache->get($key)); 92 // If there is no value get returns false. 93 $this->assertFalse($this->cache->get($key)); 44 94 } 45 95
Note: See TracChangeset
for help on using the changeset viewer.