PdoDbalAdapterTest.php 1.1 KB

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