public function testClearExpired() { if (!$this->_storage instanceof ClearExpiredInterface) { $this->markTestSkipped("Storage doesn't implement ClearExpiredInterface"); } $capabilities = $this->_storage->getCapabilities(); $ttl = $capabilities->getTtlPrecision(); $this->_options->setTtl($ttl); $this->assertTrue($this->_storage->setItem('key1', 'value1')); // wait until the first item expired $wait = $ttl + $capabilities->getTtlPrecision(); usleep($wait * 2000000); $this->assertTrue($this->_storage->setItem('key2', 'value2')); $this->assertTrue($this->_storage->clearExpired()); if ($capabilities->getUseRequestTime()) { $this->assertTrue($this->_storage->hasItem('key1')); } else { $this->assertFalse($this->_storage->hasItem('key1', array('ttl' => 0))); } $this->assertTrue($this->_storage->hasItem('key2')); }