mirror of
https://github.com/predis/predis.git
synced 2026-10-11 14:27:44 +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>
77 lines
1.8 KiB
PHP
77 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Predis\Command\Traits;
|
|
|
|
use PredisTestCase;
|
|
use Predis\Command\Command as RedisCommand;
|
|
use UnexpectedValueException;
|
|
|
|
class TimeoutTest extends PredisTestCase
|
|
{
|
|
private $testClass;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->testClass = new class extends RedisCommand {
|
|
use Timeout;
|
|
|
|
public static $timeoutArgumentPositionOffset = 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::$timeoutArgumentPositionOffset = $offset;
|
|
|
|
$this->testClass->setArguments($arguments);
|
|
|
|
$this->assertSameValues($expectedResponse, $this->testClass->getArguments());
|
|
}
|
|
|
|
/**
|
|
* @return void
|
|
*/
|
|
public function testThrowsExceptionOnUnexpectedValueGiven(): void
|
|
{
|
|
$this->expectException(UnexpectedValueException::class);
|
|
$this->expectExceptionMessage('Wrong timeout argument value or position offset');
|
|
|
|
$this->testClass->setArguments([0]);
|
|
}
|
|
|
|
public function argumentsProvider(): array
|
|
{
|
|
return [
|
|
'with TIMEOUT argument' => [
|
|
0,
|
|
[10],
|
|
['TIMEOUT', 10]
|
|
],
|
|
'with wrong offset given' => [
|
|
1,
|
|
[],
|
|
[]
|
|
],
|
|
'with default value' => [
|
|
0,
|
|
[-1],
|
|
[false]
|
|
]
|
|
];
|
|
}
|
|
}
|