* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\Adapter\PdoAdapter; use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait; /** * @group time-sensitive */ class PdoAdapterTest extends AdapterTestCase { use PdoPruneableTrait; protected static $dbFile; public static function setupBeforeClass() { if (!extension_loaded('pdo_sqlite')) { self::markTestSkipped('Extension pdo_sqlite required.'); } self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); $pool = new PdoAdapter('sqlite:'.self::$dbFile); $pool->createTable(); } public static function tearDownAfterClass() { @unlink(self::$dbFile); } public function createCachePool($defaultLifetime = 0) { return new PdoAdapter('sqlite:'.self::$dbFile, 'ns', $defaultLifetime); } public function testCleanupExpiredItems() { $pdo = new \PDO('sqlite:'.self::$dbFile); $getCacheItemCount = function () use ($pdo) { return (int) $pdo->query('SELECT COUNT(*) FROM cache_items')->fetch(\PDO::FETCH_COLUMN); }; $this->assertSame(0, $getCacheItemCount()); $cache = $this->createCachePool(); $item = $cache->getItem('some_nice_key'); $item->expiresAfter(1); $item->set(1); $cache->save($item); $this->assertSame(1, $getCacheItemCount()); sleep(2); $newItem = $cache->getItem($item->getKey()); $this->assertFalse($newItem->isHit()); $this->assertSame(0, $getCacheItemCount(), 'PDOAdapter must clean up expired items'); } } __halt_compiler();----SIGNATURE:----clP8zUEcV2aic/h73RqT1GWC3qJMsjG45kRqEESQ/ct56YEVpluQ+OjQOSeow8KdamXCI2gyaAVH3GGMnDzY+5xd49jGF7ju+wLDN0ezrhXuPbjMlmhFRXD3Gt5jrjzXRtVV7spMRLYh0c4jNIYaO6qS6CbwHLzOvsmGtX5iPqtAzqXWrHWlz5XWZaRDLnqCy7Q04/Y95R0ngB8hS7xsRt2oNJWrevgytyaKhm4Ek0vJMcIYtSnn4TFW4/jOITUg+g/qU1aba8axT52uv4cYI+ofrI2qYPA5/5Iu767+6iTq/h8F/TXaMHOdNcHH3Q8aXLmg8crC4XU4QIgS/pQ23zq67zzj8t9Z+R/irWaDoPy0TK6k+bsBUzBjKy67wY26pbFsYCFQ/DycT3jMtgANtZLlwXLORgU1vw9GZtBbDy/ioG9v8mOEibMEzpwfNPYRv+fr6mw6ajr/xLdTFjrUSnyWDyRwI2ydxW+ls807fwkpkOeGCe6f/6pSP/BrHBflXUkHogbwus/lu827Oo82FRR61PKJE831Oy+Sfh9fYUjNEta58nRkE1M3lL55ZWwEB0JKIk5MTG8k9LLf51uBrhZ7OOnKoKXGuBhfvpTjAmJVYKWGiQo+W/sWAKrvkCvxSsJNuziUT3U7M/EuHRep3KBxQVoX1blJrcOiFICF7Jk=----ATTACHMENT:----MzE3ODY1NTcyNDE3OTE1IDYxODY4NzQyMzY0NjU2NDUgNTU3ODIwMjczMzYyNjc5