PhpFilesAdapterTest.php 1.2 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\Adapter;
  11. use Psr\Cache\CacheItemPoolInterface;
  12. use Symfony\Component\Cache\Adapter\PhpFilesAdapter;
  13. /**
  14. * @group time-sensitive
  15. */
  16. class PhpFilesAdapterTest extends AdapterTestCase
  17. {
  18. protected $skippedTests = [
  19. 'testDefaultLifeTime' => 'PhpFilesAdapter does not allow configuring a default lifetime.',
  20. ];
  21. public function createCachePool()
  22. {
  23. if (!PhpFilesAdapter::isSupported()) {
  24. $this->markTestSkipped('OPcache extension is not enabled.');
  25. }
  26. return new PhpFilesAdapter('sf-cache');
  27. }
  28. public static function tearDownAfterClass()
  29. {
  30. FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache');
  31. }
  32. protected function isPruned(CacheItemPoolInterface $cache, $name)
  33. {
  34. $getFileMethod = (new \ReflectionObject($cache))->getMethod('getFile');
  35. $getFileMethod->setAccessible(true);
  36. return !file_exists($getFileMethod->invoke($cache, $name));
  37. }
  38. }