PdoDbalAdapterTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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()
  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. $pool = new PdoAdapter(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]));
  28. $pool->createTable();
  29. }
  30. public static function tearDownAfterClass()
  31. {
  32. @unlink(self::$dbFile);
  33. }
  34. public function createCachePool($defaultLifetime = 0)
  35. {
  36. return new PdoAdapter(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]), '', $defaultLifetime);
  37. }
  38. }