/**
  * @depends SweepTest::testCreatingNewObject
  */
 public function testCleanTheGarbageCollectionByNotSuitableExpirationTime()
 {
     // prepare data.
     $stdClass = new \stdClass();
     $stdClass->title = 'I am cached.';
     $stdClass->from = 'Mike';
     $stdClass->to = 'Gates';
     $stdClass->body = 'Yes, it works fine!';
     // put some data to the cache.
     $this->cache->put(md5('stdClass'), $stdClass);
     $this->cache->put(md5('ZipArchive'), new \ZipArchive());
     $this->cache->put(md5('XMLReader'), new \XMLReader());
     // wait one second to force the expiration-time-calculation.
     sleep(1);
     $sweep = new \Sweep($this->cache);
     $sweep->old();
     $this->assertInstanceOf('\\PhpDbaCache\\stdClass', $this->cache->get(md5('stdClass')));
     $this->assertInstanceOf('\\PhpDbaCache\\ZipArchive', $this->cache->get(md5('ZipArchive')));
     $this->assertInstanceOf('\\PhpDbaCache\\XMLReader', $this->cache->get(md5('XMLReader')));
 }
Example #2
0
/**
 * create an test-entry for two seconds.
 *
 * @param \PhpDbaCache\Cache $cache
 *
 * @return bool
 */
function put(\PhpDbaCache\Cache $cache)
{
    return $cache->put(uniqid('test_'), (object) array(rand(1, 100)), 2);
}