RedisClusterSessionHandlerTest.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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\HttpFoundation\Tests\Session\Storage\Handler;
  11. use PHPUnit\Framework\SkippedTestSuiteError;
  12. /**
  13. * @group integration
  14. */
  15. class RedisClusterSessionHandlerTest extends AbstractRedisSessionHandlerTestCase
  16. {
  17. public static function setUpBeforeClass(): void
  18. {
  19. if (!class_exists(\RedisCluster::class)) {
  20. throw new SkippedTestSuiteError('The RedisCluster class is required.');
  21. }
  22. if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) {
  23. throw new SkippedTestSuiteError('REDIS_CLUSTER_HOSTS env var is not defined.');
  24. }
  25. }
  26. /**
  27. * @return \RedisCluster
  28. */
  29. protected function createRedisClient(string $host): object
  30. {
  31. return new \RedisCluster(null, explode(' ', getenv('REDIS_CLUSTER_HOSTS')));
  32. }
  33. }