AbstractRedisAdapterTest.php 1.3 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 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. try {
  30. (new \Redis())->connect(getenv('REDIS_HOST'));
  31. } catch (\Exception $e) {
  32. self::markTestSkipped($e->getMessage());
  33. }
  34. }
  35. public static function tearDownAfterClass()
  36. {
  37. self::$redis = null;
  38. }
  39. }