Exemple #1
0
 function testSetCacheFilename_DestructorSaves()
 {
     $filename = tempnam('/tmp', 'foo');
     // create some cache data.
     $cache = new Phlickr_Cache();
     $cache->set('a key', 'value');
     $cache->saveAs($filename);
     unset($cache);
     // load the cache and then delete the cache file
     $this->api->setCacheFilename($filename);
     unlink($filename);
     $this->assertFalse(file_exists($filename), 'the file should not exist');
     // unsetting the api should call the destructor and writeout the file.
     unset($this->api);
     $this->assertTrue(file_exists($filename), 'the file should exist');
     $cache = Phlickr_Cache::createFrom($filename);
     $this->assertType('Phlickr_Cache', $cache);
     $this->assertTrue($cache->has('a key'), 'value should exist');
 }