PdoDbalCacheTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 Doctrine\DBAL\DriverManager;
  12. use Symfony\Component\Cache\Simple\PdoCache;
  13. use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
  14. /**
  15. * @group time-sensitive
  16. * @group legacy
  17. */
  18. class PdoDbalCacheTest extends CacheTestCase
  19. {
  20. use PdoPruneableTrait;
  21. protected static $dbFile;
  22. public static function setUpBeforeClass(): void
  23. {
  24. if (!\extension_loaded('pdo_sqlite')) {
  25. self::markTestSkipped('Extension pdo_sqlite required.');
  26. }
  27. self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache');
  28. $pool = new PdoCache(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]));
  29. $pool->createTable();
  30. }
  31. public static function tearDownAfterClass(): void
  32. {
  33. @unlink(self::$dbFile);
  34. }
  35. public function createSimpleCache($defaultLifetime = 0)
  36. {
  37. return new PdoCache(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]), '', $defaultLifetime);
  38. }
  39. }