AbstractRedisCacheTest.php 1.3 KB

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