PdoCacheTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Cache\Tests\Simple;
  11. use Symfony\Component\Cache\Simple\PdoCache;
  12. use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
  13. /**
  14. * @group time-sensitive
  15. */
  16. class PdoCacheTest extends CacheTestCase
  17. {
  18. use PdoPruneableTrait;
  19. protected static $dbFile;
  20. public static function setupBeforeClass()
  21. {
  22. if (!\extension_loaded('pdo_sqlite')) {
  23. self::markTestSkipped('Extension pdo_sqlite required.');
  24. }
  25. self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache');
  26. $pool = new PdoCache('sqlite:'.self::$dbFile);
  27. $pool->createTable();
  28. }
  29. public static function tearDownAfterClass()
  30. {
  31. @unlink(self::$dbFile);
  32. }
  33. public function createSimpleCache($defaultLifetime = 0)
  34. {
  35. return new PdoCache('sqlite:'.self::$dbFile, 'ns', $defaultLifetime);
  36. }
  37. }