mirror of
https://github.com/predis/predis.git
synced 2026-08-17 19:33:44 +00:00
Compare commits
6 Commits
v2.2.0-RC1
...
v2.2.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 33b70b971a | |||
| e46d56c45c | |||
| c57a6744bb | |||
| df83c94bb3 | |||
| a711ef96e2 | |||
| 3c322fc4e3 |
+8
-4
@@ -1,6 +1,6 @@
|
||||
## Changelog
|
||||
|
||||
## v2.2.0-RC1 (2023-05-09)
|
||||
## v2.2.0 (2023-06-14)
|
||||
|
||||
### Added
|
||||
- Added support for [Relay](https://github.com/predis/predis/wiki/Using-Relay) (#1263)
|
||||
@@ -8,11 +8,15 @@
|
||||
- Added support for Redis `JSON`, `Bloom`, `Search` and `TimeSeries` module (#1253)
|
||||
- Added support for `ACL SETUSER, GETUSER, DRYRUN` commands (#1193)
|
||||
|
||||
### Changed
|
||||
- Minor code style and typehint changes (#1311)
|
||||
|
||||
### Fixed
|
||||
- Fixed prefixes for `XTRIM` and `XREVRANGE` commands (#1230)
|
||||
- Fix `fclose()` being called on invalid stream resource (#1199)
|
||||
- Fix `BitByte` and `ExpireOptions` traits skip processing on null values (#1169)
|
||||
- Fix missing `@return` annotations (#1265)
|
||||
- Fixed `fclose()` being called on invalid stream resource (#1199)
|
||||
- Fixed `BitByte` and `ExpireOptions` traits skip processing on null values (#1169)
|
||||
- Fixed missing `@return` annotations (#1265)
|
||||
- Fixed `GETDEL` prefixing (#1306)
|
||||
|
||||
## v2.1.2 (2023-03-02)
|
||||
|
||||
|
||||
+7
-7
@@ -346,29 +346,29 @@ class Client implements ClientInterface, IteratorAggregate
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param string $name
|
||||
* @return ContainerInterface
|
||||
*/
|
||||
public function __get($name)
|
||||
public function __get(string $name)
|
||||
{
|
||||
return ContainerFactory::create($this, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $value
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
public function __set(string $name, $value)
|
||||
{
|
||||
throw new RuntimeException('Not allowed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function __isset($name)
|
||||
public function __isset(string $name)
|
||||
{
|
||||
throw new RuntimeException('Not allowed');
|
||||
}
|
||||
|
||||
@@ -178,7 +178,9 @@ use Predis\Command\Redis\Container\Search\FTCURSOR;
|
||||
* @method $this jsonforget(string $key, string $path = '$')
|
||||
* @method $this jsonget(string $key, string $indent = '', string $newline = '', string $space = '', string ...$paths)
|
||||
* @method $this jsonnumincrby(string $key, string $path, int $value)
|
||||
* @method $this jsonmerge(string $key, string $path, string $value)
|
||||
* @method $this jsonmget(array $keys, string $path)
|
||||
* @method $this jsonmset(string ...$keyPathValue)
|
||||
* @method $this jsonobjkeys(string $key, string $path = '$')
|
||||
* @method $this jsonobjlen(string $key, string $path = '$')
|
||||
* @method $this jsonresp(string $key, string $path = '$')
|
||||
|
||||
@@ -187,7 +187,9 @@ use Predis\Response\Status;
|
||||
* @method int jsonforget(string $key, string $path = '$')
|
||||
* @method string jsonget(string $key, string $indent = '', string $newline = '', string $space = '', string ...$paths)
|
||||
* @method string jsonnumincrby(string $key, string $path, int $value)
|
||||
* @method Status jsonmerge(string $key, string $path, string $value)
|
||||
* @method array jsonmget(array $keys, string $path)
|
||||
* @method Status jsonmset(string ...$keyPathValue)
|
||||
* @method array jsonobjkeys(string $key, string $path = '$')
|
||||
* @method array jsonobjlen(string $key, string $path = '$')
|
||||
* @method array jsonresp(string $key, string $path = '$')
|
||||
|
||||
@@ -186,6 +186,9 @@ class KeyPrefixProcessor implements ProcessorInterface
|
||||
'XLEN' => $prefixFirst,
|
||||
'XACK' => $prefixFirst,
|
||||
'XTRIM' => $prefixFirst,
|
||||
|
||||
/* ---------------- Redis 6.2 ---------------- */
|
||||
'GETDEL' => $prefixFirst,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ abstract class AbstractContainer implements ContainerInterface
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function __call($subcommandID, $arguments)
|
||||
public function __call(string $subcommandID, array $arguments)
|
||||
{
|
||||
array_unshift($arguments, strtoupper($subcommandID));
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ interface ContainerInterface
|
||||
* Creates Redis container command with subcommand as virtual method name
|
||||
* and sends a request to the server.
|
||||
*
|
||||
* @param $subcommandID
|
||||
* @param $arguments
|
||||
* @param string $subcommandID
|
||||
* @param array $arguments
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($subcommandID, $arguments);
|
||||
public function __call(string $subcommandID, array $arguments);
|
||||
|
||||
/**
|
||||
* Returns containerCommandId of specific container command.
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Predis package.
|
||||
*
|
||||
* (c) 2009-2020 Daniele Alessandri
|
||||
* (c) 2021-2023 Till Krüss
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Predis\Command\Redis\Json;
|
||||
|
||||
use Predis\Command\Command as RedisCommand;
|
||||
|
||||
/**
|
||||
* @see https://redis.io/commands/json.merge/
|
||||
*
|
||||
* Merge a given JSON value into matching paths.
|
||||
* Consequently, JSON values at matching paths are updated, deleted, or expanded with new children.
|
||||
*/
|
||||
class JSONMERGE extends RedisCommand
|
||||
{
|
||||
public function getId()
|
||||
{
|
||||
return 'JSON.MERGE';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Predis package.
|
||||
*
|
||||
* (c) 2009-2020 Daniele Alessandri
|
||||
* (c) 2021-2023 Till Krüss
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Predis\Command\Redis\Json;
|
||||
|
||||
use Predis\Command\Command as RedisCommand;
|
||||
|
||||
/**
|
||||
* @see https://redis.io/commands/json.mset/
|
||||
*
|
||||
* Set or update one or more JSON values according to the specified key-path-value triplets.
|
||||
*/
|
||||
class JSONMSET extends RedisCommand
|
||||
{
|
||||
public function getId()
|
||||
{
|
||||
return 'JSON.MSET';
|
||||
}
|
||||
}
|
||||
@@ -60,9 +60,9 @@ class SORT extends RedisCommand
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($sortParams['LIMIT']) &&
|
||||
is_array($sortParams['LIMIT']) &&
|
||||
count($sortParams['LIMIT']) == 2) {
|
||||
if (isset($sortParams['LIMIT'])
|
||||
&& is_array($sortParams['LIMIT'])
|
||||
&& count($sortParams['LIMIT']) == 2) {
|
||||
$query[] = 'LIMIT';
|
||||
$query[] = $sortParams['LIMIT'][0];
|
||||
$query[] = $sortParams['LIMIT'][1];
|
||||
|
||||
@@ -25,8 +25,8 @@ trait Keys
|
||||
$argumentsLength = count($arguments);
|
||||
|
||||
if (
|
||||
static::$keysArgumentPositionOffset > $argumentsLength ||
|
||||
!is_array($arguments[static::$keysArgumentPositionOffset])
|
||||
static::$keysArgumentPositionOffset > $argumentsLength
|
||||
|| !is_array($arguments[static::$keysArgumentPositionOffset])
|
||||
) {
|
||||
throw new UnexpectedValueException('Wrong keys argument type or position offset');
|
||||
}
|
||||
|
||||
@@ -67,8 +67,8 @@ class Options implements OptionsInterface
|
||||
public function defined($option)
|
||||
{
|
||||
return
|
||||
array_key_exists($option, $this->options) ||
|
||||
array_key_exists($option, $this->input)
|
||||
array_key_exists($option, $this->options)
|
||||
|| array_key_exists($option, $this->input)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -78,8 +78,8 @@ class Options implements OptionsInterface
|
||||
public function __isset($option)
|
||||
{
|
||||
return (
|
||||
array_key_exists($option, $this->options) ||
|
||||
array_key_exists($option, $this->input)
|
||||
array_key_exists($option, $this->options)
|
||||
|| array_key_exists($option, $this->input)
|
||||
) && $this->__get($option) !== null;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ trait RelayMethods
|
||||
* @param string $pattern
|
||||
* @return bool
|
||||
*/
|
||||
public function onInvalidated(?callable $callback, ?string $pattern = null)
|
||||
public function onInvalidated(?callable $callback, string $pattern = null)
|
||||
{
|
||||
return $this->client->onInvalidated($callback, $pattern);
|
||||
}
|
||||
@@ -129,7 +129,7 @@ trait RelayMethods
|
||||
* @param ?int $db
|
||||
* @return bool
|
||||
*/
|
||||
public function flushMemory(?string $endpointId = null, int $db = null)
|
||||
public function flushMemory(string $endpointId = null, int $db = null)
|
||||
{
|
||||
return $this->client->flushMemory($endpointId, $db);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ abstract class AbstractConsumer implements Iterator
|
||||
public const STATUS_SUBSCRIBED = 2; // 0b0010
|
||||
public const STATUS_PSUBSCRIBED = 4; // 0b0100
|
||||
|
||||
protected $position = null;
|
||||
protected $position;
|
||||
protected $statusFlags = self::STATUS_VALID;
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,7 +44,7 @@ class OneOfConstraint extends Constraint
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $other
|
||||
* @param mixed $other
|
||||
* @return string
|
||||
*/
|
||||
protected function failureDescription($other): string
|
||||
|
||||
@@ -22,7 +22,7 @@ use Predis\Connection;
|
||||
*/
|
||||
abstract class PredisTestCase extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected $redisServerVersion = null;
|
||||
protected $redisServerVersion;
|
||||
protected $redisJsonVersion;
|
||||
|
||||
/**
|
||||
@@ -73,7 +73,7 @@ abstract class PredisTestCase extends \PHPUnit\Framework\TestCase
|
||||
*
|
||||
* @return RedisCommandConstraint
|
||||
*/
|
||||
public function isRedisCommand($command = null, ?array $arguments = null): RedisCommandConstraint
|
||||
public function isRedisCommand($command = null, array $arguments = null): RedisCommandConstraint
|
||||
{
|
||||
return new RedisCommandConstraint($command, $arguments);
|
||||
}
|
||||
@@ -224,7 +224,7 @@ abstract class PredisTestCase extends \PHPUnit\Framework\TestCase
|
||||
*
|
||||
* @return Client
|
||||
*/
|
||||
protected function createClient(?array $parameters = null, ?array $options = null, ?bool $flushdb = true): Client
|
||||
protected function createClient(array $parameters = null, array $options = null, ?bool $flushdb = true): Client
|
||||
{
|
||||
$parameters = array_merge(
|
||||
$this->getDefaultParametersArray(),
|
||||
@@ -300,7 +300,6 @@ abstract class PredisTestCase extends \PHPUnit\Framework\TestCase
|
||||
* the default connection parameters used by Predis or a set of connection
|
||||
* parameters specified in the optional second argument.
|
||||
*
|
||||
|
||||
* @param array|string|null $parameters Optional connection parameters
|
||||
*
|
||||
* @return MockObject|Connection\NodeConnectionInterface
|
||||
@@ -362,9 +361,9 @@ abstract class PredisTestCase extends \PHPUnit\Framework\TestCase
|
||||
$this->getName(false)
|
||||
);
|
||||
|
||||
if (isset($annotations['method']['requiresRedisVersion'], $annotations['method']['group']) &&
|
||||
!empty($annotations['method']['requiresRedisVersion']) &&
|
||||
in_array('connected', $annotations['method']['group'])
|
||||
if (isset($annotations['method']['requiresRedisVersion'], $annotations['method']['group'])
|
||||
&& !empty($annotations['method']['requiresRedisVersion'])
|
||||
&& in_array('connected', $annotations['method']['group'])
|
||||
) {
|
||||
return $annotations['method']['requiresRedisVersion'][0];
|
||||
}
|
||||
@@ -517,9 +516,9 @@ abstract class PredisTestCase extends \PHPUnit\Framework\TestCase
|
||||
$this->getName(false)
|
||||
);
|
||||
|
||||
if (isset($annotations['method'][$moduleAnnotation], $annotations['method']['group']) &&
|
||||
!empty($annotations['method'][$moduleAnnotation]) &&
|
||||
in_array('connected', $annotations['method']['group'], true)
|
||||
if (isset($annotations['method'][$moduleAnnotation], $annotations['method']['group'])
|
||||
&& !empty($annotations['method'][$moduleAnnotation])
|
||||
&& in_array('connected', $annotations['method']['group'], true)
|
||||
) {
|
||||
return $annotations['method'][$moduleAnnotation][0];
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class RedisCommandConstraint extends \PHPUnit\Framework\Constraint\Constraint
|
||||
* @param string|CommandInterface $command Expected command instance or command ID
|
||||
* @param ?array $arguments Expected command arguments
|
||||
*/
|
||||
public function __construct($command, ?array $arguments = null)
|
||||
public function __construct($command, array $arguments = null)
|
||||
{
|
||||
if ($command instanceof CommandInterface) {
|
||||
$this->commandID = strtoupper($command->getId());
|
||||
|
||||
@@ -310,7 +310,7 @@ class PredisStrategyTest extends PredisTestCase
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getExpectedCommands(?string $type = null): array
|
||||
protected function getExpectedCommands(string $type = null): array
|
||||
{
|
||||
$commands = [
|
||||
/* commands operating on the key space */
|
||||
|
||||
@@ -333,7 +333,7 @@ class RedisStrategyTest extends PredisTestCase
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getExpectedCommands(?string $type = null): array
|
||||
protected function getExpectedCommands(string $type = null): array
|
||||
{
|
||||
$commands = [
|
||||
/* commands operating on the key space */
|
||||
|
||||
@@ -973,6 +973,11 @@ class KeyPrefixProcessorTest extends PredisTestCase
|
||||
['key', 'MAXLEN', 100],
|
||||
['prefix:key', 'MAXLEN', 100],
|
||||
],
|
||||
/* ---------------- Redis 6.2 ---------------- */
|
||||
['GETDEL',
|
||||
['key'],
|
||||
['prefix:key'],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,10 +61,10 @@ class EVALSHA_RO_Test extends PredisCommandTestCase
|
||||
/**
|
||||
* @group connected
|
||||
* @dataProvider scriptsProvider
|
||||
* @param string $script
|
||||
* @param array $keys
|
||||
* @param array $arguments
|
||||
* @param $expectedResponse
|
||||
* @param string $script
|
||||
* @param array $keys
|
||||
* @param array $arguments
|
||||
* @param $expectedResponse
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 7.0.0
|
||||
*/
|
||||
|
||||
@@ -61,11 +61,11 @@ class EVAL_RO_Test extends PredisCommandTestCase
|
||||
/**
|
||||
* @group connected
|
||||
* @dataProvider scriptsProvider
|
||||
* @param array $dictionary
|
||||
* @param string $script
|
||||
* @param array $keys
|
||||
* @param array $arguments
|
||||
* @param $expectedResponse
|
||||
* @param array $dictionary
|
||||
* @param string $script
|
||||
* @param array $keys
|
||||
* @param array $arguments
|
||||
* @param $expectedResponse
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 7.0.0
|
||||
*/
|
||||
|
||||
@@ -147,14 +147,14 @@ class EXPIREAT_Test extends PredisCommandTestCase
|
||||
['noExpiry', time() + 10, 'XX'],
|
||||
],
|
||||
'only if new expiry is greater then current one' => [
|
||||
['newExpiryLower', 'value', 'EXAT', time() + 1000],
|
||||
['newExpiryGreater', 'value', 'EXAT', time() + 10],
|
||||
['newExpiryLower', 'value', 'EX', 1000],
|
||||
['newExpiryGreater', 'value', 'EX', 10],
|
||||
['newExpiryGreater', time() + 20, 'GT'],
|
||||
['newExpiryLower', time() + 20, 'GT'],
|
||||
],
|
||||
'only if new expiry is lower then current one' => [
|
||||
['newExpiryLower', 'value', 'EXAT', time() + 1000],
|
||||
['newExpiryGreater', 'value', 'EXAT', time() + 10],
|
||||
['newExpiryLower', 'value', 'EX', 1000],
|
||||
['newExpiryGreater', 'value', 'EX', 10],
|
||||
['newExpiryLower', time() + 20, 'LT'],
|
||||
['newExpiryGreater', time() + 20, 'LT'],
|
||||
],
|
||||
|
||||
@@ -113,8 +113,8 @@ class FCALL_RO_Test extends PredisCommandTestCase
|
||||
);
|
||||
|
||||
if (
|
||||
isset($annotations['method']['group']) &&
|
||||
in_array('connected', $annotations['method']['group'], true)
|
||||
isset($annotations['method']['group'])
|
||||
&& in_array('connected', $annotations['method']['group'], true)
|
||||
) {
|
||||
$redis = $this->getClient();
|
||||
$redis->function->delete(self::LIB_NAME);
|
||||
|
||||
@@ -60,9 +60,9 @@ class FCALL_Test extends PredisCommandTestCase
|
||||
/**
|
||||
* @group connected
|
||||
* @dataProvider functionsProvider
|
||||
* @param string $function
|
||||
* @param array $functionArguments
|
||||
* @param $expectedResponse
|
||||
* @param string $function
|
||||
* @param array $functionArguments
|
||||
* @param $expectedResponse
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 7.0.0
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Predis package.
|
||||
*
|
||||
* (c) 2009-2020 Daniele Alessandri
|
||||
* (c) 2021-2023 Till Krüss
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Predis\Command\Redis\Json;
|
||||
|
||||
use Predis\Command\Redis\PredisCommandTestCase;
|
||||
|
||||
class JSONMERGE_Test extends PredisCommandTestCase
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function getExpectedCommand(): string
|
||||
{
|
||||
return JSONMERGE::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function getExpectedId(): string
|
||||
{
|
||||
return 'JSONMERGE';
|
||||
}
|
||||
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testFilterArguments(): void
|
||||
{
|
||||
$arguments = ['key', '$..', '{"a":2}'];
|
||||
$expected = ['key', '$..', '{"a":2}'];
|
||||
|
||||
$command = $this->getCommand();
|
||||
$command->setArguments($arguments);
|
||||
|
||||
$this->assertSame($expected, $command->getArguments());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testParseResponse(): void
|
||||
{
|
||||
$this->assertSame(1, $this->getCommand()->parseResponse(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider jsonProvider
|
||||
* @group connected
|
||||
* @param array $setArguments
|
||||
* @param array $mergeArguments
|
||||
* @param string $expectedResponse
|
||||
* @return void
|
||||
* @requiresRedisJsonVersion >= 2.6.0
|
||||
*/
|
||||
public function testMergeCorrectlyMergeJsonValues(
|
||||
array $setArguments,
|
||||
array $mergeArguments,
|
||||
string $expectedResponse
|
||||
): void {
|
||||
$redis = $this->getClient();
|
||||
|
||||
$this->assertEquals('OK', $redis->jsonset(...$setArguments));
|
||||
$this->assertEquals('OK', $redis->jsonmerge(...$mergeArguments));
|
||||
$this->assertEquals($expectedResponse, $redis->jsonget('key'));
|
||||
}
|
||||
|
||||
public function jsonProvider(): array
|
||||
{
|
||||
return [
|
||||
'create non-existing value' => [
|
||||
['key', '$', '{"a":2}'],
|
||||
['key', '$.b', '8'],
|
||||
'{"a":2,"b":8}',
|
||||
],
|
||||
'replace existing value' => [
|
||||
['key', '$', '{"a":2}'],
|
||||
['key', '$.a', '3'],
|
||||
'{"a":3}',
|
||||
],
|
||||
'replace an array' => [
|
||||
['key', '$', '{"a":[2,4,6,8]}'],
|
||||
['key', '$.a', '[10,12]'],
|
||||
'{"a":[10,12]}',
|
||||
],
|
||||
'merge in multiple-paths' => [
|
||||
['key', '$', '{"f1": {"a":1}, "f2":{"a":2}}'],
|
||||
['key', '$', '{"f2":{"a":3, "b":4}, "f3":[2,4,6]}'],
|
||||
'{"f1":{"a":1},"f2":{"a":3,"b":4},"f3":[2,4,6]}',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Predis package.
|
||||
*
|
||||
* (c) 2009-2020 Daniele Alessandri
|
||||
* (c) 2021-2023 Till Krüss
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Predis\Command\Redis\Json;
|
||||
|
||||
use Predis\Command\Redis\PredisCommandTestCase;
|
||||
use Predis\Response\ServerException;
|
||||
|
||||
class JSONMSET_Test extends PredisCommandTestCase
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function getExpectedCommand(): string
|
||||
{
|
||||
return JSONMSET::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function getExpectedId(): string
|
||||
{
|
||||
return 'JSONMSET';
|
||||
}
|
||||
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testFilterArguments(): void
|
||||
{
|
||||
$arguments = ['key', '$..', 'value', 'key1', '$', 'value1'];
|
||||
$expected = ['key', '$..', 'value', 'key1', '$', 'value1'];
|
||||
|
||||
$command = $this->getCommand();
|
||||
$command->setArguments($arguments);
|
||||
|
||||
$this->assertSame($expected, $command->getArguments());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testParseResponse(): void
|
||||
{
|
||||
$this->assertSame(1, $this->getCommand()->parseResponse(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @return void
|
||||
* @requiresRedisJsonVersion >= 2.6.0
|
||||
*/
|
||||
public function testSetMultipleJsonDocuments(): void
|
||||
{
|
||||
$redis = $this->getClient();
|
||||
|
||||
$this->assertEquals('OK', $redis->jsonmset('doc1', '$', '{"a":2}', 'doc2', '$', '{"b":3}'));
|
||||
$this->assertEquals(['[{"a":2}]', '[{"b":3}]'], $redis->jsonmget(['doc1', 'doc2'], '$'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @return void
|
||||
* @requiresRedisJsonVersion >= 2.6.0
|
||||
*/
|
||||
public function testThrowsExceptionOnNewValuesNotInTheRootPath(): void
|
||||
{
|
||||
$redis = $this->getClient();
|
||||
|
||||
$this->expectException(ServerException::class);
|
||||
$this->expectExceptionMessage('ERR new objects must be created at the root');
|
||||
|
||||
$redis->jsonmset('doc1', '$', '{"a":2}', 'doc2', '$.f', '{"b":3}');
|
||||
}
|
||||
}
|
||||
@@ -58,9 +58,9 @@ class LCS_Test extends PredisCommandTestCase
|
||||
/**
|
||||
* @group connected
|
||||
* @dataProvider stringsProvider
|
||||
* @param array $stringsArguments
|
||||
* @param array $functionArguments
|
||||
* @param $expectedResponse
|
||||
* @param array $stringsArguments
|
||||
* @param array $functionArguments
|
||||
* @param $expectedResponse
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 7.0.0
|
||||
*/
|
||||
|
||||
@@ -113,6 +113,9 @@ class FTSEARCH_Test extends PredisCommandTestCase
|
||||
$ftCreateResponse = $redis->ftcreate('idx_hash', $schema, $ftCreateArguments);
|
||||
$this->assertEquals('OK', $ftCreateResponse);
|
||||
|
||||
// Timeout to make sure that index created before search performed.
|
||||
usleep(2000);
|
||||
|
||||
$ftSearchArguments = new SearchArguments();
|
||||
$ftSearchArguments->addReturn(1, 'should_return');
|
||||
|
||||
|
||||
@@ -110,8 +110,8 @@ class ZINTERCARD_Test extends PredisCommandTestCase
|
||||
/**
|
||||
* @group connected
|
||||
* @dataProvider unexpectedValuesProvider
|
||||
* @param $keys
|
||||
* @param $limit
|
||||
* @param $keys
|
||||
* @param $limit
|
||||
* @param string $expectedExceptionMessage
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 7.0.0
|
||||
|
||||
@@ -115,9 +115,9 @@ class ZINTERSTORE_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @dataProvider unexpectedValueProvider
|
||||
* @param string $destination
|
||||
* @param $keys
|
||||
* @param $weights
|
||||
* @param string $destination
|
||||
* @param $keys
|
||||
* @param $weights
|
||||
* @param string $aggregate
|
||||
* @param string $expectedExceptionMessage
|
||||
* @return void
|
||||
|
||||
@@ -127,8 +127,8 @@ class ZINTER_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @dataProvider unexpectedValueProvider
|
||||
* @param $keys
|
||||
* @param $weights
|
||||
* @param $keys
|
||||
* @param $weights
|
||||
* @param string $aggregate
|
||||
* @param bool $withScores
|
||||
* @param string $expectedExceptionMessage
|
||||
|
||||
@@ -102,14 +102,14 @@ class ZRANGESTORE_Test extends PredisCommandTestCase
|
||||
/**
|
||||
* @group connected
|
||||
* @dataProvider unexpectedValuesProvider
|
||||
* @param int|string $min
|
||||
* @param int|string $max
|
||||
* @param string|bool $by
|
||||
* @param $rev
|
||||
* @param $limit
|
||||
* @param int $offset
|
||||
* @param int $count
|
||||
* @param string $expectedExceptionMessage
|
||||
* @param int|string $min
|
||||
* @param int|string $max
|
||||
* @param string|bool $by
|
||||
* @param $rev
|
||||
* @param $limit
|
||||
* @param int $offset
|
||||
* @param int $count
|
||||
* @param string $expectedExceptionMessage
|
||||
* @return void
|
||||
* @requiresRedisVersion >= 6.2.0
|
||||
*/
|
||||
|
||||
@@ -115,9 +115,9 @@ class ZUNIONSTORE_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @dataProvider unexpectedValueProvider
|
||||
* @param string $destination
|
||||
* @param $keys
|
||||
* @param $weights
|
||||
* @param string $destination
|
||||
* @param $keys
|
||||
* @param $weights
|
||||
* @param string $aggregate
|
||||
* @param string $expectedExceptionMessage
|
||||
* @return void
|
||||
|
||||
@@ -101,8 +101,8 @@ class ZUNION_Test extends PredisCommandTestCase
|
||||
|
||||
/**
|
||||
* @dataProvider unexpectedValueProvider
|
||||
* @param $keys
|
||||
* @param $weights
|
||||
* @param $keys
|
||||
* @param $weights
|
||||
* @param string $aggregate
|
||||
* @param bool $withScores
|
||||
* @param string $expectedExceptionMessage
|
||||
|
||||
@@ -390,7 +390,7 @@ class ReplicationStrategyTest extends PredisTestCase
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getExpectedCommands(?string $type = null): array
|
||||
protected function getExpectedCommands(string $type = null): array
|
||||
{
|
||||
$commands = [
|
||||
/* commands operating on the connection */
|
||||
|
||||
Reference in New Issue
Block a user