Relay example

/** * @requires extension relay * * @group time-sensitive * @group integration */
class RelayExtIntegrationTest extends RedisExtIntegrationTest
{
    protected function createRedisClient(): \Redis|Relay
    {
        return new Relay();
    }

    public function testConnectionSendAndGetDelayed()
    {
        self::markTestSkipped('This test doesn\'t work with relay.');
    }

    public function testConnectionSendDelayedMessagesWithSameContent()
    {
        self::markTestSkipped('This test doesn\'t work with relay.');
    }

    
/** * @requires extension relay * * @group integration */
class RelayAdapterTest extends AbstractRedisAdapterTestCase
{
    public static function setUpBeforeClass(): void
    {
        try {
            new Relay(...explode(':', getenv('REDIS_HOST')));
        } catch (\Relay\Exception $e) {
            throw new SkippedTestSuiteError(getenv('REDIS_HOST').': '.$e->getMessage());
        }
        self::$redis = AbstractAdapter::createConnection('redis://'.getenv('REDIS_HOST')['lazy' => true, 'class' => Relay::class]);
        self::assertInstanceOf(RelayProxy::class, self::$redis);
    }

    public function testCreateHostConnection()
    {
        $redis = RedisAdapter::createConnection('redis://'.getenv('REDIS_HOST').'?class=Relay\Relay');
        $this->assertInstanceOf(Relay::class$redis);
        
$host$port] = $address;
                            }
                        } catch (\RedisException|\Relay\Exception $redisException) {
                        }
                    } while (++$hostIndex < \count($hosts) && !$address);

                    if (!$address) {
                        throw new InvalidArgumentException(sprintf('Failed to retrieve master information from sentinel "%s".', $sentinelMaster), previous: $redisException ?? null);
                    }
                }

                return self::initializeRedis($redis ?? (\extension_loaded('redis') ? new \Redis() : new Relay())$host$port$auth$options);
            };
        }

        if (!$options['lazy']) {
            $this->getRedis();
        }

        foreach (['stream', 'group', 'consumer'] as $key) {
            if ('' === $options[$key]) {
                throw new InvalidArgumentException(sprintf('"%s" should be configured, got an empty string.', $key));
            }
        }

class RelayStoreTest extends AbstractRedisStoreTestCase
{
    use SharedLockStoreTestTrait;

    public static function setUpBeforeClass(): void
    {
        try {
            new Relay(...explode(':', getenv('REDIS_HOST')));
        } catch (\Relay\Exception $e) {
            throw new SkippedTestSuiteError($e->getMessage());
        }
    }

    protected function getRedisConnection(): Relay
    {
        return new Relay(...explode(':', getenv('REDIS_HOST')));
    }
}
use Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler\AbstractRedisSessionHandlerTestCase;

/** * @requires extension relay * * @group integration */
class RelaySessionHandlerTest extends AbstractRedisSessionHandlerTestCase
{
    protected function createRedisClient(string $host): Relay
    {
        return new Relay(...explode(':', $host));
    }
}

class RelayStoreTest extends AbstractRedisStoreTestCase
{
    protected function setUp(): void
    {
        $this->getRedisConnection()->flushDB();
    }

    public static function setUpBeforeClass(): void
    {
        try {
            new Relay(...explode(':', getenv('REDIS_HOST')));
        } catch (\Relay\Exception $e) {
            throw new SkippedTestSuiteError($e->getMessage());
        }
    }

    protected function getRedisConnection(): Relay
    {
        return new Relay(...explode(':', getenv('REDIS_HOST')));
    }
}
Home | Imprint | This part of the site doesn't use cookies.