mirror of
https://github.com/predis/predis.git
synced 2026-08-27 00:39:38 +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>
71 lines
1.7 KiB
PHP
71 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Predis\Command\Traits\To;
|
|
|
|
use Predis\Command\Argument\Server\To;
|
|
use PredisTestCase;
|
|
use Predis\Command\Command as RedisCommand;
|
|
|
|
class ServerToTest extends PredisTestCase
|
|
{
|
|
private $testClass;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->testClass = new class extends RedisCommand {
|
|
use ServerTo;
|
|
|
|
public static $toArgumentPositionOffset = 0;
|
|
|
|
public function getId()
|
|
{
|
|
return 'test';
|
|
}
|
|
};
|
|
}
|
|
|
|
/**
|
|
* @dataProvider argumentsProvider
|
|
* @param int $offset
|
|
* @param array $arguments
|
|
* @param array $expectedResponse
|
|
* @return void
|
|
*/
|
|
public function testReturnsCorrectArguments(int $offset, array $arguments, array $expectedResponse): void
|
|
{
|
|
$this->testClass::$toArgumentPositionOffset = $offset;
|
|
|
|
$this->testClass->setArguments($arguments);
|
|
|
|
$this->assertSameValues($expectedResponse, $this->testClass->getArguments());
|
|
}
|
|
|
|
public function argumentsProvider(): array
|
|
{
|
|
return [
|
|
'with TO argument - no FORCE' => [
|
|
0,
|
|
[new To('host', 9999)],
|
|
['TO', 'host', 9999]
|
|
],
|
|
'with TO argument - with FORCE' => [
|
|
0,
|
|
[new To('host', 9999, true)],
|
|
['TO', 'host', 9999, 'FORCE']
|
|
],
|
|
'with wrong offset given' => [
|
|
1,
|
|
[],
|
|
[]
|
|
],
|
|
'with default value' => [
|
|
0,
|
|
[null],
|
|
[false]
|
|
]
|
|
];
|
|
}
|
|
}
|