mirror of
https://github.com/predis/predis.git
synced 2026-10-17 01:06:20 +00:00
721c829042
* Added arrayable arguments classes * Updated count trait to accept additional modifier argument * Added new With traits, moved into separate directory * Added traits for geo command arguments resolving * Remove BaseWith trait, not working with traits nesting * Added AscDesc trait * Rename AscDesc traint into Sorting * Fixed trait keyword * Removed unnecessary traits * Updated count trait to handle default argument value * Fixed With traits offset check condition * Added GeoFrom, GeoBy traits * Fixes for Count and Sorting traits * Fixed variable names in with traits * [WIP] Added GEOSEARCH command support, without test coverage * Changed functionality to support only lower case units (Redis 6.0 support) * Changed namespace for WITHSCORES trait * Added more test coverage, added response parsing * Added test coverage for tratis * Added support for FAILOVER command Co-authored-by: Vladyslav Vildanov <vladyslavvildanov@Vladyslav-Vildanov-MacBook-Pro.local>
117 lines
2.9 KiB
PHP
117 lines
2.9 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Predis package.
|
|
*
|
|
* (c) Daniele Alessandri <suppakilla@gmail.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Predis\Command\Redis;
|
|
|
|
use Predis\Command\Argument\Server\To;
|
|
use UnexpectedValueException;
|
|
|
|
/**
|
|
* @group commands
|
|
* @group realm-server
|
|
*/
|
|
class FAILOVER_Test extends PredisCommandTestCase
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function getExpectedCommand(): string
|
|
{
|
|
return FAILOVER::class;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function getExpectedId(): string
|
|
{
|
|
return 'FAILOVER';
|
|
}
|
|
|
|
/**
|
|
* @group disconnected
|
|
* @dataProvider argumentsProvider
|
|
*/
|
|
public function testFilterArguments(array $actualArguments, array $expectedArguments): void
|
|
{
|
|
$command = $this->getCommand();
|
|
$command->setArguments($actualArguments);
|
|
|
|
$this->assertSameValues($expectedArguments, $command->getArguments());
|
|
}
|
|
|
|
/**
|
|
* @group disconnected
|
|
*/
|
|
public function testParseResponse(): void
|
|
{
|
|
$this->assertSame(1, $this->getCommand()->parseResponse(1));
|
|
}
|
|
|
|
/**
|
|
* @group connected
|
|
* @return void
|
|
* @requiresRedisVersion >= 6.2.0
|
|
*/
|
|
public function testPerformFailoverOfConnectedReplica(): void
|
|
{
|
|
$this->markTestSkipped('Test requires configured replica node connected to master');
|
|
}
|
|
|
|
/**
|
|
* @group connected
|
|
* @return void
|
|
* @requiresRedisVersion >= 6.2.0
|
|
*/
|
|
public function testThrowsExceptionOnUnexpectedValueGiven(): void
|
|
{
|
|
$redis = $this->getClient();
|
|
$this->expectException(UnexpectedValueException::class);
|
|
$this->expectExceptionMessage('Wrong timeout argument value or position offset');
|
|
|
|
$redis->failover(null, false, 0);
|
|
}
|
|
|
|
public function argumentsProvider(): array
|
|
{
|
|
return [
|
|
'without optional arguments - no arguments' => [
|
|
[],
|
|
[]
|
|
],
|
|
'without optional arguments - default arguments' => [
|
|
[null, false, -1],
|
|
[]
|
|
],
|
|
'with TO argument - no FORCE' => [
|
|
[new To('test', 9999)],
|
|
['TO', 'test', 9999]
|
|
],
|
|
'with TO argument - with FORCE' => [
|
|
[new To('test', 9999, true)],
|
|
['TO', 'test', 9999, 'FORCE']
|
|
],
|
|
'with ABORT modifier' => [
|
|
[null, true],
|
|
['ABORT']
|
|
],
|
|
'with TIMEOUT argument' => [
|
|
[null, false, 10],
|
|
['TIMEOUT', 10]
|
|
],
|
|
'with all arguments' => [
|
|
[new To('test', 9999, true), true, 10],
|
|
['TO', 'test', 9999, 'FORCE', 'ABORT', 'TIMEOUT', 10]
|
|
]
|
|
];
|
|
}
|
|
}
|