AbstractRedisAdapterTest.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\Adapter;
  11. use Symfony\Component\Cache\Adapter\RedisAdapter;
  12. abstract class AbstractRedisAdapterTest extends AdapterTestCase
  13. {
  14. protected $skippedTests = [
  15. 'testExpiration' => 'Testing expiration slows down the test suite',
  16. 'testHasItemReturnsFalseWhenDeferredItemIsExpired' => 'Testing expiration slows down the test suite',
  17. 'testDefaultLifeTime' => 'Testing expiration slows down the test suite',
  18. ];
  19. protected static $redis;
  20. public function createCachePool($defaultLifetime = 0)
  21. {
  22. return new RedisAdapter(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. }