AbstractRedisCacheTest.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 Symfony\Component\Cache\Simple\RedisCache;
  12. /**
  13. * @group legacy
  14. */
  15. abstract class AbstractRedisCacheTest extends CacheTestCase
  16. {
  17. protected $skippedTests = [
  18. 'testSetTtl' => 'Testing expiration slows down the test suite',
  19. 'testSetMultipleTtl' => 'Testing expiration slows down the test suite',
  20. 'testDefaultLifeTime' => 'Testing expiration slows down the test suite',
  21. ];
  22. protected static $redis;
  23. public function createSimpleCache($defaultLifetime = 0)
  24. {
  25. return new RedisCache(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime);
  26. }
  27. public static function setUpBeforeClass(): void
  28. {
  29. if (!\extension_loaded('redis')) {
  30. self::markTestSkipped('Extension redis required.');
  31. }
  32. if (!@((new \Redis())->connect(getenv('REDIS_HOST')))) {
  33. $e = error_get_last();
  34. self::markTestSkipped($e['message']);
  35. }
  36. }
  37. public static function tearDownAfterClass(): void
  38. {
  39. self::$redis = null;
  40. }
  41. }