diff --git a/.codespellrc b/.codespellrc
index 0e95e105c..70f773561 100644
--- a/.codespellrc
+++ b/.codespellrc
@@ -3,4 +3,4 @@ skip=./.git
check-hidden=
check-filenames=
builtin=clear,rare,informal,usage,code,names
-ignore-words-list=master,masters,slave,slaves,whitelist,cas,exat,smove,SUGGET,sugget
+ignore-words-list=master,masters,slave,slaves,whitelist,cas,exat,smove,SUGGET,sugget,ro
diff --git a/.coveralls.yml b/.coveralls.yml
new file mode 100644
index 000000000..c8f7bd3d5
--- /dev/null
+++ b/.coveralls.yml
@@ -0,0 +1 @@
+coverage_clover: build/logs/clover-*.xml
diff --git a/.editorconfig b/.editorconfig
index 0764720be..9cffd80e7 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -14,7 +14,7 @@ block_comment_end = */
[*.php]
max_line_length = 150
-[*.{md,yml,yaml,neon}]
+[*.{md,yml,yaml,neon,sh}]
indent_size = 2
[tests/**.php]
diff --git a/.gitattributes b/.gitattributes
index 226cb6ab2..93cba263a 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -5,6 +5,7 @@
/examples export-ignore
/tests export-ignore
/.codespellrc export-ignore linguist-language=INI
+/.coveralls.yml export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
diff --git a/.github/workflows/cluster/Dockerfile b/.github/workflows/cluster/Dockerfile
new file mode 100644
index 000000000..a434dddce
--- /dev/null
+++ b/.github/workflows/cluster/Dockerfile
@@ -0,0 +1,7 @@
+FROM redis/redis-stack-server:latest as rss
+
+COPY create_cluster.sh /create_cluster.sh
+RUN ls -R /opt/redis-stack
+RUN chmod a+x /create_cluster.sh
+
+ENTRYPOINT [ "/create_cluster.sh"]
diff --git a/.github/workflows/cluster/create_cluster.sh b/.github/workflows/cluster/create_cluster.sh
new file mode 100644
index 000000000..b000a2ad7
--- /dev/null
+++ b/.github/workflows/cluster/create_cluster.sh
@@ -0,0 +1,47 @@
+#! /bin/bash
+
+mkdir -p /nodes
+touch /nodes/nodemap
+if [ -z ${START_PORT} ]; then
+ START_PORT=6372
+fi
+if [ -z ${END_PORT} ]; then
+ END_PORT=6377
+fi
+if [ ! -z "$3" ]; then
+ START_PORT=$2
+ START_PORT=$3
+fi
+echo "STARTING: ${START_PORT}"
+echo "ENDING: ${END_PORT}"
+
+for PORT in `seq ${START_PORT} ${END_PORT}`; do
+ mkdir -p /nodes/$PORT
+ if [[ -e /redis.conf ]]; then
+ cp /redis.conf /nodes/$PORT/redis.conf
+ else
+ touch /nodes/$PORT/redis.conf
+ fi
+ cat << EOF >> /nodes/$PORT/redis.conf
+port ${PORT}
+cluster-enabled yes
+daemonize yes
+logfile /redis.log
+dir /nodes/$PORT
+EOF
+
+ set -x
+ /opt/redis-stack/bin/redis-server /nodes/$PORT/redis.conf
+ sleep 1
+ if [ $? -ne 0 ]; then
+ echo "Redis failed to start, exiting."
+ continue
+ fi
+ echo 127.0.0.1:$PORT >> /nodes/nodemap
+done
+if [ -z "${REDIS_PASSWORD}" ]; then
+ echo yes | /opt/redis-stack/bin/redis-cli --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
+else
+ echo yes | opt/redis-stack/bin/redis-cli -a ${REDIS_PASSWORD} --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1
+fi
+tail -f /redis.log
diff --git a/.github/workflows/cluster/docker-compose.yml b/.github/workflows/cluster/docker-compose.yml
new file mode 100644
index 000000000..2829da39a
--- /dev/null
+++ b/.github/workflows/cluster/docker-compose.yml
@@ -0,0 +1,17 @@
+version: "3.9"
+services:
+ cluster:
+ container_name: redis-cluster
+ build:
+ context: .
+ dockerfile: Dockerfile
+ ports:
+ - "6372:6372"
+ - "6373:6373"
+ - "6374:6374"
+ - "6375:6375"
+ - "6376:6376"
+ - "6377:6378"
+ volumes:
+ - "./redis.conf:/redis.conf:ro"
+
diff --git a/.github/workflows/cluster/redis.conf b/.github/workflows/cluster/redis.conf
new file mode 100644
index 000000000..a676f5776
--- /dev/null
+++ b/.github/workflows/cluster/redis.conf
@@ -0,0 +1,8 @@
+# Redis Cluster config file will be shared across all nodes.
+# Do not change the following configurations that are already set:
+# port, cluster-enabled, daemonize, logfile, dir
+protected-mode no
+loadmodule /opt/redis-stack/lib/redisearch.so
+loadmodule /opt/redis-stack/lib/redistimeseries.so
+loadmodule /opt/redis-stack/lib/rejson.so
+loadmodule /opt/redis-stack/lib/redisbloom.so
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index b5259142d..acc4fa4d4 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -65,12 +65,16 @@ jobs:
- name: Run tests with coverage
if: ${{ matrix.php == '8.1' && matrix.redis == '7' }}
- run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml --coverage-filter ./src
+ run: vendor/bin/phpunit --coverage-clover build/logs/clover-default.xml --coverage-filter ./src
- name: Run tests using Relay
if: ${{ matrix.redis >= '6' }}
run: vendor/bin/phpunit -c phpunit.relay.xml
+ - name: Run tests using Relay with coverage
+ if: ${{ matrix.php == '8.1' && matrix.redis == '7' }}
+ run: vendor/bin/phpunit -c phpunit.relay.xml --coverage-clover build/logs/clover-relay.xml --coverage-filter ./src
+
- name: Send coverage to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -78,3 +82,51 @@ jobs:
run: |
wget "https://github.com/php-coveralls/php-coveralls/releases/download/v2.5.3/php-coveralls.phar"
php ./php-coveralls.phar -v
+
+ predis-cluster:
+
+ name: PHP ${{ matrix.php }} (Redis Cluster latest)
+ runs-on: ubuntu-latest
+
+ strategy:
+ fail-fast: false
+ matrix:
+ php:
+ - '7.2'
+ - '7.3'
+ - '7.4'
+ - '8.0'
+ - '8.1'
+ - '8.2'
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ - name: Run Redis cluster
+ uses: isbang/compose-action@v1.4.1
+ with:
+ compose-file: .github/workflows/cluster/docker-compose.yml
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ extensions: relay
+ coverage: ${{ (matrix.php == '8.1') && 'xdebug' || 'none' }}
+
+ - name: Install Composer dependencies
+ uses: ramsey/composer-install@v2
+ with:
+ dependency-versions: highest
+ composer-options: ${{ matrix.php == '8.0' && '--ignore-platform-reqs' || '' }}
+
+ - name: Run tests against cluster
+ run: |
+ sleep 5 # make sure that docker image is setup
+ vendor/bin/phpunit --group cluster
+
+ - name: Run tests against cluster using Relay
+ run: |
+ sleep 5 # make sure nodes are stable and fully joined
+ vendor/bin/phpunit -c phpunit.relay.xml --group cluster
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dd565df74..61179b282 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,27 @@
## Changelog
+## v2.2.2 (2023-09-13)
+
+### Added
+- Added `client_info` client parameter
+- Added support for `CLUSTER` container command
+
+### Fixed
+- Fixed `EXPIRETIME` not using `prefix`
+- Disabled `CLIENT SETINFO` calls by default
+
+## v2.2.1 (2023-08-15)
+
+### Added
+- Added support for `WAITAOF` command (#1357)
+- Added support for `SHUTDOWN` command (#1359)
+- Added support for `FUNCTION` command (#1332)
+- Added support for new optional `PEXPIRE`, `PEXPIREAT` and `COMMAND`
+- Added missing Redis Stack commands to `KeyPrefixProcessor` (#1358)
+
+### Changed
+- Set client name and version when establishing a connection (#1347)
+
## v2.2.0 (2023-06-14)
Predis v2.2.0 introduces official support for [Redis Stack](https://redis.io/docs/stack/) as well as a [Relay](https://github.com/cachewerk/relay) integration for substantially [faster read performance](https://github.com/predis/predis/wiki/Using-Relay).
diff --git a/FAQ.md b/FAQ.md
index 65d34a0bd..098bda5de 100644
--- a/FAQ.md
+++ b/FAQ.md
@@ -33,7 +33,7 @@ but significantly reduces bytes sent over the network and Redis memory usage.
Without Relay, Predis will not serialize data and will never do that by default. The reason
behind this decision is that serialization is usually something that developers prefer to
-customize depending on their needs and can not be easilygeneralized when using Redis because
+customize depending on their needs and can not be easily generalized when using Redis because
of the many possible access patterns for your data. This does not mean that it is impossible
to have such a feature since you can leverage the extensibility of this library to define
your own serialization-aware commands. You can find more details about how to do that
@@ -90,7 +90,7 @@ Predis is fast enough when Redis is located on the same machine as PHP, more on
[PhpRedis](https://github.com/phpredis/phpredis) (and Relay) perform significantly better when
network I/O is involved, due to their ability to compress data by ~75%. Fewer bytes and received
sent over the network [means faster operations](https://akalongman.medium.com/phpredis-vs-predis-comparison-on-real-production-data-a819b48cbadb),
-and potentially cost savings when network traffic isn't free (e.g. AWS Elasticache Inter-AZ transfer costs).
+and potentially cost savings when network traffic isn't free (e.g. AWS ElastiCache Inter-AZ transfer costs).
## Predis is a pure-PHP implementation: it can not be fast enough! ##
diff --git a/README.md b/README.md
index d73754706..f435bab00 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ More details about this project can be found on the [frequently asked questions]
## Main features ##
-- Support for Redis from __3.0__ to __7.0__.
+- Support for Redis from __3.0__ to __7.2__.
- Support for clustering using client-side sharding and pluggable keyspace distributors.
- Support for [redis-cluster](http://redis.io/topics/cluster-tutorial) (Redis >= 3.0).
- Support for master-slave replication setups and [redis-sentinel](http://redis.io/topics/sentinel).
diff --git a/VERSION b/VERSION
index 17831900d..7dd050c42 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.2.0-RC1
+2.2.3-dev
diff --git a/examples/Commands/waitaof.php b/examples/Commands/waitaof.php
new file mode 100644
index 000000000..c9fd97059
--- /dev/null
+++ b/examples/Commands/waitaof.php
@@ -0,0 +1,41 @@
+info();
+$enabled = false;
+
+if ($info['Persistence']['aof_enabled'] === '0') {
+ $client->config('set', 'appendonly', 'yes');
+ $enabled = true;
+}
+
+// 2. Set key value pair
+$response = $client->set('foo', 'bar');
+echo "Key-value pair set status: {$response}\n";
+
+// 3. Run WAITAOF command to make sure that all previous writes was fsynced
+$response = $client->waitaof(1, 0, 0);
+
+echo "Quantity of local instances that was fsynced - {$response[0]}, quantity of replicas - {$response[1]}";
+
+// 4. Disable appendonly mode if it was enabled during script execution
+if ($enabled) {
+ $client->config('set', 'appendonly', 'no');
+}
diff --git a/phpunit.relay.xml b/phpunit.relay.xml
index 731f29c27..1b66a8936 100644
--- a/phpunit.relay.xml
+++ b/phpunit.relay.xml
@@ -20,10 +20,12 @@
relay-incompatible
+ relay-resp3
realm-webdis
realm-stack
ext-curl
ext-phpiredis
+ cluster
@@ -38,5 +40,9 @@
+
+
+
+
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index d47afa8dd..5ec9da95a 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -33,6 +33,7 @@
ext-relay
ext-curl
ext-phpiredis
+ cluster
@@ -51,5 +52,9 @@
+
+
+
+
diff --git a/src/Client.php b/src/Client.php
index 0517a0870..c73ff2e51 100644
--- a/src/Client.php
+++ b/src/Client.php
@@ -53,7 +53,7 @@
*/
class Client implements ClientInterface, IteratorAggregate
{
- public const VERSION = '2.2.0-RC1';
+ public const VERSION = '2.2.3-dev';
/** @var OptionsInterface */
private $options;
diff --git a/src/ClientContextInterface.php b/src/ClientContextInterface.php
index 95f1590e7..e443ee5d1 100644
--- a/src/ClientContextInterface.php
+++ b/src/ClientContextInterface.php
@@ -39,6 +39,7 @@
use Predis\Command\Argument\TimeSeries\RangeArguments;
use Predis\Command\CommandInterface;
use Predis\Command\Redis\Container\ACL;
+use Predis\Command\Redis\Container\CLUSTER;
use Predis\Command\Redis\Container\FunctionContainer;
use Predis\Command\Redis\Container\Json\JSONDEBUG;
use Predis\Command\Redis\Container\Search\FTCONFIG;
@@ -304,12 +305,14 @@
* @method $this exec()
* @method $this multi()
* @method $this unwatch()
+ * @method $this waitaof(int $numLocal, int $numReplicas, int $timeout)
* @method $this watch($key)
* @method $this eval($script, $numkeys, $keyOrArg1 = null, $keyOrArgN = null)
* @method $this eval_ro(string $script, array $keys, ...$argument)
* @method $this evalsha($script, $numkeys, $keyOrArg1 = null, $keyOrArgN = null)
* @method $this evalsha_ro(string $sha1, array $keys, ...$argument)
* @method $this script($subcommand, $argument = null)
+ * @method $this shutdown(bool $noSave = null, bool $now = false, bool $force = false, bool $abort = false)
* @method $this auth($password)
* @method $this echo($message)
* @method $this ping($message = null)
@@ -338,6 +341,7 @@
* @method $this geosearchstore(string $destination, string $source, FromInterface $from, ByInterface $by, ?string $sorting = null, int $count = -1, bool $any = false, bool $storeDist = false)
*
* Container commands
+ * @property CLUSTER $cluster
* @property FunctionContainer $function
* @property FTCONFIG $ftconfig
* @property FTCURSOR $ftcursor
diff --git a/src/ClientInterface.php b/src/ClientInterface.php
index 924db1ec5..5250dabd5 100644
--- a/src/ClientInterface.php
+++ b/src/ClientInterface.php
@@ -40,6 +40,7 @@
use Predis\Command\CommandInterface;
use Predis\Command\FactoryInterface;
use Predis\Command\Redis\Container\ACL;
+use Predis\Command\Redis\Container\CLUSTER;
use Predis\Command\Redis\Container\FunctionContainer;
use Predis\Command\Redis\Container\Json\JSONDEBUG;
use Predis\Command\Redis\Container\Search\FTCONFIG;
@@ -108,7 +109,7 @@
* @method array cfinsertnx(string $key, int $capacity = -1, bool $noCreate = false, string ...$item)
* @method Status cfreserve(string $key, int $capacity, int $bucketSize = -1, int $maxIterations = -1, int $expansion = -1)
* @method array cfscandump(string $key, int $iterator)
- * @method array cmsincrby(string $key, string|int...$itemIncrementDictionary)
+ * @method array cmsincrby(string $key, string|int ...$itemIncrementDictionary)
* @method array cmsinfo(string $key)
* @method Status cmsinitbydim(string $key, int $width, int $depth)
* @method Status cmsinitbyprob(string $key, float $errorRate, float $probability)
@@ -154,7 +155,7 @@
* @method mixed mset(array $dictionary)
* @method int msetnx(array $dictionary)
* @method Status psetex(string $key, $milliseconds, $value)
- * @method Status set(string $key, $value, $expireResolution = null, $expireTTL = null, $flag = null)
+ * @method Status|null set(string $key, $value, $expireResolution = null, $expireTTL = null, $flag = null)
* @method int setbit(string $key, $offset, $value)
* @method Status setex(string $key, $seconds, $value)
* @method int setnx(string $key, $value)
@@ -322,12 +323,14 @@
* @method array|null exec()
* @method mixed multi()
* @method mixed unwatch()
+ * @method array waitaof(int $numLocal, int $numReplicas, int $timeout)
* @method mixed watch(string $key)
* @method mixed eval(string $script, int $numkeys, string ...$keyOrArg = null)
* @method mixed eval_ro(string $script, array $keys, ...$argument)
* @method mixed evalsha(string $script, int $numkeys, string ...$keyOrArg = null)
* @method mixed evalsha_ro(string $sha1, array $keys, ...$argument)
* @method mixed script($subcommand, $argument = null)
+ * @method Status shutdown(bool $noSave = null, bool $now = false, bool $force = false, bool $abort = false)
* @method mixed auth(string $password)
* @method string echo(string $message)
* @method mixed ping(string $message = null)
@@ -356,6 +359,7 @@
* @method int geosearchstore(string $destination, string $source, FromInterface $from, ByInterface $by, ?string $sorting = null, int $count = -1, bool $any = false, bool $storeDist = false)
*
* Container commands
+ * @property CLUSTER $cluster
* @property FunctionContainer $function
* @property FTCONFIG $ftconfig
* @property FTCURSOR $ftcursor
diff --git a/src/Cluster/ClusterStrategy.php b/src/Cluster/ClusterStrategy.php
index b12b8b0fe..1965e26dd 100644
--- a/src/Cluster/ClusterStrategy.php
+++ b/src/Cluster/ClusterStrategy.php
@@ -53,6 +53,7 @@ protected function getDefaultCommands()
'SORT' => [$this, 'getKeyFromSortCommand'],
'DUMP' => $getKeyFromFirstArgument,
'RESTORE' => $getKeyFromFirstArgument,
+ 'FLUSHDB' => [$this, 'getFakeKey'],
/* commands operating on string values */
'APPEND' => $getKeyFromFirstArgument,
@@ -163,6 +164,9 @@ protected function getDefaultCommands()
'EVAL' => [$this, 'getKeyFromScriptingCommands'],
'EVALSHA' => [$this, 'getKeyFromScriptingCommands'],
+ /* server */
+ 'INFO' => [$this, 'getFakeKey'],
+
/* commands performing geospatial operations */
'GEOADD' => $getKeyFromFirstArgument,
'GEOHASH' => $getKeyFromFirstArgument,
@@ -170,6 +174,9 @@ protected function getDefaultCommands()
'GEODIST' => $getKeyFromFirstArgument,
'GEORADIUS' => [$this, 'getKeyFromGeoradiusCommands'],
'GEORADIUSBYMEMBER' => [$this, 'getKeyFromGeoradiusCommands'],
+
+ /* cluster */
+ 'CLUSTER' => [$this, 'getFakeKey'],
];
}
@@ -216,6 +223,16 @@ public function setCommandHandler($commandID, $callback = null)
$this->commands[$commandID] = $callback;
}
+ /**
+ * Get fake key for commands with no key argument.
+ *
+ * @return string
+ */
+ protected function getFakeKey(): string
+ {
+ return 'key';
+ }
+
/**
* Extracts the key from the first argument of a command instance.
*
diff --git a/src/Command/Processor/KeyPrefixProcessor.php b/src/Command/Processor/KeyPrefixProcessor.php
index 233ffa80a..d7a30c880 100644
--- a/src/Command/Processor/KeyPrefixProcessor.php
+++ b/src/Command/Processor/KeyPrefixProcessor.php
@@ -189,6 +189,111 @@ public function __construct($prefix)
/* ---------------- Redis 6.2 ---------------- */
'GETDEL' => $prefixFirst,
+
+ /* ---------------- Redis 7.0 ---------------- */
+ 'EXPIRETIME' => $prefixFirst,
+
+ /* RedisJSON */
+ 'JSON.ARRAPPEND' => $prefixFirst,
+ 'JSON.ARRINDEX' => $prefixFirst,
+ 'JSON.ARRINSERT' => $prefixFirst,
+ 'JSON.ARRLEN' => $prefixFirst,
+ 'JSON.ARRPOP' => $prefixFirst,
+ 'JSON.ARRTRIM' => $prefixFirst,
+ 'JSON.CLEAR' => $prefixFirst,
+ 'JSON.DEBUG MEMORY' => $prefixFirst,
+ 'JSON.DEL' => $prefixFirst,
+ 'JSON.FORGET' => $prefixFirst,
+ 'JSON.GET' => $prefixFirst,
+ 'JSON.MGET' => $prefixAll,
+ 'JSON.NUMINCRBY' => $prefixFirst,
+ 'JSON.OBJKEYS' => $prefixFirst,
+ 'JSON.OBJLEN' => $prefixFirst,
+ 'JSON.RESP' => $prefixFirst,
+ 'JSON.SET' => $prefixFirst,
+ 'JSON.STRAPPEND' => $prefixFirst,
+ 'JSON.STRLEN' => $prefixFirst,
+ 'JSON.TOGGLE' => $prefixFirst,
+ 'JSON.TYPE' => $prefixFirst,
+
+ /* RedisBloom */
+ 'BF.ADD' => $prefixFirst,
+ 'BF.EXISTS' => $prefixFirst,
+ 'BF.INFO' => $prefixFirst,
+ 'BF.INSERT' => $prefixFirst,
+ 'BF.LOADCHUNK' => $prefixFirst,
+ 'BF.MADD' => $prefixFirst,
+ 'BF.MEXISTS' => $prefixFirst,
+ 'BF.RESERVE' => $prefixFirst,
+ 'BF.SCANDUMP' => $prefixFirst,
+ 'CF.ADD' => $prefixFirst,
+ 'CF.ADDNX' => $prefixFirst,
+ 'CF.COUNT' => $prefixFirst,
+ 'CF.DEL' => $prefixFirst,
+ 'CF.EXISTS' => $prefixFirst,
+ 'CF.INFO' => $prefixFirst,
+ 'CF.INSERT' => $prefixFirst,
+ 'CF.INSERTNX' => $prefixFirst,
+ 'CF.LOADCHUNK' => $prefixFirst,
+ 'CF.MEXISTS' => $prefixFirst,
+ 'CF.RESERVE' => $prefixFirst,
+ 'CF.SCANDUMP' => $prefixFirst,
+ 'CMS.INCRBY' => $prefixFirst,
+ 'CMS.INFO' => $prefixFirst,
+ 'CMS.INITBYDIM' => $prefixFirst,
+ 'CMS.INITBYPROB' => $prefixFirst,
+ 'CMS.QUERY' => $prefixFirst,
+ 'TDIGEST.ADD' => $prefixFirst,
+ 'TDIGEST.BYRANK' => $prefixFirst,
+ 'TDIGEST.BYREVRANK' => $prefixFirst,
+ 'TDIGEST.CDF' => $prefixFirst,
+ 'TDIGEST.CREATE' => $prefixFirst,
+ 'TDIGEST.INFO' => $prefixFirst,
+ 'TDIGEST.MAX' => $prefixFirst,
+ 'TDIGEST.MIN' => $prefixFirst,
+ 'TDIGEST.QUANTILE' => $prefixFirst,
+ 'TDIGEST.RANK' => $prefixFirst,
+ 'TDIGEST.RESET' => $prefixFirst,
+ 'TDIGEST.REVRANK' => $prefixFirst,
+ 'TDIGEST.TRIMMED_MEAN' => $prefixFirst,
+ 'TOPK.ADD' => $prefixFirst,
+ 'TOPK.INCRBY' => $prefixFirst,
+ 'TOPK.INFO' => $prefixFirst,
+ 'TOPK.LIST' => $prefixFirst,
+ 'TOPK.QUERY' => $prefixFirst,
+ 'TOPK.RESERVE' => $prefixFirst,
+
+ /* RediSearch */
+ 'FT.AGGREGATE' => $prefixFirst,
+ 'FT.ALTER' => $prefixFirst,
+ 'FT.CREATE' => $prefixFirst,
+ 'FT.CURSOR DEL' => $prefixFirst,
+ 'FT.CURSOR READ' => $prefixFirst,
+ 'FT.DROPINDEX' => $prefixFirst,
+ 'FT.EXPLAIN' => $prefixFirst,
+ 'FT.INFO' => $prefixFirst,
+ 'FT.PROFILE' => $prefixFirst,
+ 'FT.SEARCH' => $prefixFirst,
+ 'FT.SPELLCHECK' => $prefixFirst,
+ 'FT.SYNDUMP' => $prefixFirst,
+ 'FT.SYNUPDATE' => $prefixFirst,
+ 'FT.TAGVALS' => $prefixFirst,
+
+ /* Redis TimeSeries */
+ 'TS.ADD' => $prefixFirst,
+ 'TS.ALTER' => $prefixFirst,
+ 'TS.CREATE' => $prefixFirst,
+ 'TS.DECRBY' => $prefixFirst,
+ 'TS.DEL' => $prefixFirst,
+ 'TS.GET' => $prefixFirst,
+ 'TS.INCRBY' => $prefixFirst,
+ 'TS.INFO' => $prefixFirst,
+ 'TS.MGET' => $prefixFirst,
+ 'TS.MRANGE' => $prefixFirst,
+ 'TS.MREVRANGE' => $prefixFirst,
+ 'TS.QUERYINDEX' => $prefixFirst,
+ 'TS.RANGE' => $prefixFirst,
+ 'TS.REVRANGE' => $prefixFirst,
];
}
diff --git a/src/Command/Redis/CLUSTER.php b/src/Command/Redis/CLUSTER.php
new file mode 100644
index 000000000..3bbb77cc8
--- /dev/null
+++ b/src/Command/Redis/CLUSTER.php
@@ -0,0 +1,26 @@
+initCommands[] = $command;
}
+ /**
+ * {@inheritdoc}
+ */
+ public function getInitCommands(): array
+ {
+ return $this->initCommands;
+ }
+
/**
* {@inheritdoc}
*/
diff --git a/src/Connection/Cluster/RedisCluster.php b/src/Connection/Cluster/RedisCluster.php
index 7f3013c17..ae2e18db9 100644
--- a/src/Connection/Cluster/RedisCluster.php
+++ b/src/Connection/Cluster/RedisCluster.php
@@ -464,6 +464,14 @@ protected function onMovedResponse(CommandInterface $command, $details)
{
[$slot, $connectionID] = explode(' ', $details, 2);
+ // Handle connection ID in the form of "IP:port (details about exception)"
+ // by trimming everything after first space (including the space)
+ $startPositionOfExtraDetails = strpos($connectionID, ' ');
+
+ if ($startPositionOfExtraDetails !== false) {
+ $connectionID = substr($connectionID, 0, $startPositionOfExtraDetails);
+ }
+
if (!$connection = $this->getConnectionById($connectionID)) {
$connection = $this->createConnection($connectionID);
}
diff --git a/src/Connection/Factory.php b/src/Connection/Factory.php
index ad472360c..86b18c4a0 100644
--- a/src/Connection/Factory.php
+++ b/src/Connection/Factory.php
@@ -13,6 +13,7 @@
namespace Predis\Connection;
use InvalidArgumentException;
+use Predis\Client;
use Predis\Command\RawCommand;
use ReflectionClass;
use UnexpectedValueException;
@@ -174,6 +175,16 @@ protected function prepareConnection(NodeConnectionInterface $connection)
);
}
+ if ($parameters->client_info ?? false && !$connection instanceof RelayConnection) {
+ $connection->addConnectCommand(
+ new RawCommand('CLIENT', ['SETINFO', 'LIB-NAME', 'predis'])
+ );
+
+ $connection->addConnectCommand(
+ new RawCommand('CLIENT', ['SETINFO', 'LIB-VER', Client::VERSION])
+ );
+ }
+
if (isset($parameters->database) && strlen($parameters->database)) {
$connection->addConnectCommand(
new RawCommand('SELECT', [$parameters->database])
diff --git a/src/Connection/ParametersInterface.php b/src/Connection/ParametersInterface.php
index 37ed97f7a..7893ea117 100644
--- a/src/Connection/ParametersInterface.php
+++ b/src/Connection/ParametersInterface.php
@@ -31,6 +31,7 @@
* @property string $database Database index (see the SELECT command).
* @property bool $async_connect Performs the connect() operation asynchronously.
* @property bool $tcp_nodelay Toggles the Nagle's algorithm for coalescing.
+ * @property bool $client_info Whether to set LIB-NAME and LIB-VER when connecting.
* @property bool $cache (Relay only) Whether to use in-memory caching.
* @property string $serializer (Relay only) Serializer used for data serialization.
* @property string $compression (Relay only) Algorithm used for data compression.
diff --git a/src/Connection/RelayConnection.php b/src/Connection/RelayConnection.php
index 4ff674f5f..aa78e313f 100644
--- a/src/Connection/RelayConnection.php
+++ b/src/Connection/RelayConnection.php
@@ -16,6 +16,7 @@
use Predis\ClientException;
use Predis\Command\CommandInterface;
use Predis\NotSupportedException;
+use Predis\Response\ErrorInterface as ErrorResponseInterface;
use Predis\Response\ServerException;
use Relay\Exception as RelayException;
use Relay\Relay;
@@ -198,9 +199,13 @@ public function getClient()
/**
* {@inheritdoc}
*/
- protected function getIdentifier()
+ public function getIdentifier()
{
- return $this->client->endpointId();
+ try {
+ return $this->client->endpointId();
+ } catch (RelayException $ex) {
+ return parent::getIdentifier();
+ }
}
/**
@@ -253,7 +258,13 @@ public function executeCommand(CommandInterface $command)
? $this->client->{$name}(...$command->getArguments())
: $this->client->rawCommand($name, ...$command->getArguments());
} catch (RelayException $ex) {
- throw $this->onCommandError($ex, $command);
+ $exception = $this->onCommandError($ex, $command);
+
+ if ($exception instanceof ErrorResponseInterface) {
+ return $exception;
+ }
+
+ throw $exception;
}
}
@@ -265,15 +276,15 @@ public function onCommandError(RelayException $exception, CommandInterface $comm
$code = $exception->getCode();
$message = $exception->getMessage();
- if (strpos($message, 'RELAY_ERR_IO')) {
+ if (strpos($message, 'RELAY_ERR_IO') !== false) {
return new ConnectionException($this, $message, $code, $exception);
}
- if (strpos($message, 'RELAY_ERR_REDIS')) {
+ if (strpos($message, 'RELAY_ERR_REDIS') !== false) {
return new ServerException($message, $code, $exception);
}
- if (strpos($message, 'RELAY_ERR_WRONGTYPE') && strpos($message, "Got reply-type 'status'")) {
+ if (strpos($message, 'RELAY_ERR_WRONGTYPE') !== false && strpos($message, "Got reply-type 'status'") !== false) {
$message = 'Operation against a key holding the wrong kind of value';
}
diff --git a/src/Connection/Replication/SentinelReplication.php b/src/Connection/Replication/SentinelReplication.php
index 13fbedb17..14dbe2758 100644
--- a/src/Connection/Replication/SentinelReplication.php
+++ b/src/Connection/Replication/SentinelReplication.php
@@ -211,6 +211,7 @@ public function add(NodeConnectionInterface $connection)
$this->master = $connection;
} elseif ('sentinel' === $role) {
$this->sentinels[] = $connection;
+
// sentinels are not considered part of the pool.
return;
} else {
diff --git a/src/Connection/StreamConnection.php b/src/Connection/StreamConnection.php
index e0e077c95..2fe307067 100644
--- a/src/Connection/StreamConnection.php
+++ b/src/Connection/StreamConnection.php
@@ -231,7 +231,9 @@ public function connect()
foreach ($this->initCommands as $command) {
$response = $this->executeCommand($command);
- if ($response instanceof ErrorResponseInterface) {
+ if ($response instanceof ErrorResponseInterface && $command->getId() === 'CLIENT') {
+ // Do nothing on CLIENT SETINFO command failure
+ } elseif ($response instanceof ErrorResponseInterface) {
$this->onConnectionError("`{$command->getId()}` failed: {$response->getMessage()}", 0);
}
}
diff --git a/tests/PHPUnit/AssertSameWithPrecisionConstraint.php b/tests/PHPUnit/AssertSameWithPrecisionConstraint.php
new file mode 100644
index 000000000..a96ea5c76
--- /dev/null
+++ b/tests/PHPUnit/AssertSameWithPrecisionConstraint.php
@@ -0,0 +1,81 @@
+expectedValue = $expectedValue;
+ $this->precision = $precision;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function matches($other): bool
+ {
+ if (gettype($this->expectedValue) !== gettype($other)) {
+ return false;
+ }
+
+ if (is_array($other)) {
+ $other = array_map([$this, 'roundToPrecision'], $other);
+ $this->expectedValue = array_map([$this, 'roundToPrecision'], $this->expectedValue);
+
+ return !array_diff($this->expectedValue, $other);
+ }
+
+ $other = $this->roundToPrecision($other);
+ $this->expectedValue = $this->roundToPrecision($this->expectedValue);
+
+ return $other === $this->expectedValue;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function toString(): string
+ {
+ return 'given value matches another value with given precision';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function failureDescription($other): string
+ {
+ return $this->toString();
+ }
+
+ /**
+ * @param mixed $numeric
+ * @return float
+ */
+ private function roundToPrecision($numeric): float
+ {
+ return round((float) $numeric, $this->precision);
+ }
+}
diff --git a/tests/PHPUnit/PredisCommandTestCase.php b/tests/PHPUnit/PredisCommandTestCase.php
index 9aa6f5167..1a13801e5 100644
--- a/tests/PHPUnit/PredisCommandTestCase.php
+++ b/tests/PHPUnit/PredisCommandTestCase.php
@@ -61,7 +61,11 @@ public function getClient(bool $flushdb = true): Client
);
}
- $client = $this->createClient(null, null, $flushdb);
+ if ($this->isClusterTest()) {
+ $client = $this->createClient(null, ['cluster' => 'redis'], $flushdb);
+ } else {
+ $client = $this->createClient(null, null, $flushdb);
+ }
return $client;
}
diff --git a/tests/PHPUnit/PredisTestCase.php b/tests/PHPUnit/PredisTestCase.php
index d67829e87..4ad148c15 100644
--- a/tests/PHPUnit/PredisTestCase.php
+++ b/tests/PHPUnit/PredisTestCase.php
@@ -10,6 +10,7 @@
* file that was distributed with this source code.
*/
+use PHPUnit\AssertSameWithPrecisionConstraint;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\OneOfConstraint;
use PHPUnit\Util\Test as TestUtil;
@@ -131,6 +132,20 @@ public function assertOneOf(array $expected, $actual, string $message = ''): voi
$this->assertThat($actual, new OneOfConstraint($expected), $message);
}
+ /**
+ * Asserts that two values (of the same type) have the same values with given precision.
+ *
+ * @param mixed $expected Expected value
+ * @param mixed $actual Actual value
+ * @param int $precision Precision value should be round to
+ * @param string $message Optional assertion message
+ * @return void
+ */
+ public function assertSameWithPrecision($expected, $actual, int $precision = 0, string $message = ''): void
+ {
+ $this->assertThat($actual, new AssertSameWithPrecisionConstraint($expected, $precision), $message);
+ }
+
/**
* Asserts that a string matches a given regular expression.
*
@@ -153,6 +168,10 @@ public static function assertMatchesRegularExpression(string $pattern, string $s
*/
protected function getDefaultParametersArray(): array
{
+ if ($this->isClusterTest()) {
+ return $this->prepareClusterEndpoints();
+ }
+
return [
'scheme' => 'tcp',
'host' => constant('REDIS_SERVER_HOST'),
@@ -237,6 +256,15 @@ protected function createClient(array $parameters = null, array $options = null,
getenv('USE_RELAY') ? ['connections' => 'relay'] : []
);
+ if ($this->isClusterTest()) {
+ $options = array_merge(
+ [
+ 'cluster' => 'redis',
+ ],
+ $options
+ );
+ }
+
$client = new Client($parameters, $options);
$client->connect();
@@ -537,4 +565,36 @@ protected function markTestSkippedOnCIEnvironment(string $message = 'Test skippe
$this->markTestSkipped($message);
}
}
+
+ /**
+ * Check annotations if it's matches to cluster test scenario.
+ *
+ * @return bool
+ */
+ protected function isClusterTest(): bool
+ {
+ $annotations = TestUtil::parseTestMethodAnnotations(
+ get_class($this),
+ $this->getName(false)
+ );
+
+ return isset($annotations['method']['requiresRedisVersion'], $annotations['method']['group'])
+ && !empty($annotations['method']['requiresRedisVersion'])
+ && in_array('connected', $annotations['method']['group'], true)
+ && in_array('cluster', $annotations['method']['group'], true);
+ }
+
+ /**
+ * Parse comma-separated cluster endpoints and convert them into tcp strings.
+ *
+ * @return array
+ */
+ protected function prepareClusterEndpoints(): array
+ {
+ $endpoints = explode(',', constant('REDIS_CLUSTER_ENDPOINTS'));
+
+ return array_map(static function (string $elem) {
+ return 'tcp://' . $elem;
+ }, $endpoints);
+ }
}
diff --git a/tests/Predis/ClientTest.php b/tests/Predis/ClientTest.php
index 04bac9030..4489b2f04 100644
--- a/tests/Predis/ClientTest.php
+++ b/tests/Predis/ClientTest.php
@@ -1253,6 +1253,36 @@ public function testGetIteratorWithNonTraversableConnectionNoException(): void
$this->assertSame('127.0.0.1:6381', $iterator->key());
}
+ /**
+ * @group connected
+ * @group relay-incompatible
+ * @requiresRedisVersion >= 7.2.0
+ */
+ public function testDoNoSetClientInfoOnConnection(): void
+ {
+ $client = new Client($this->getParameters());
+ $libName = $client->client('LIST')[0]['lib-name'];
+ $libVer = $client->client('LIST')[0]['lib-ver'];
+
+ $this->assertEmpty($libName);
+ $this->assertEmpty($libVer);
+ }
+
+ /**
+ * @group connected
+ * @group relay-incompatible
+ * @requiresRedisVersion >= 7.2.0
+ */
+ public function testSetClientInfoOnConnectionWhenEnabled(): void
+ {
+ $client = new Client($this->getParameters(['client_info' => true]));
+ $libName = $client->client('LIST')[0]['lib-name'];
+ $libVer = $client->client('LIST')[0]['lib-ver'];
+
+ $this->assertSame('predis', $libName);
+ $this->assertSame(Client::VERSION, $libVer);
+ }
+
// ******************************************************************** //
// ---- HELPER METHODS ------------------------------------------------ //
// ******************************************************************** //
diff --git a/tests/Predis/Cluster/PredisStrategyTest.php b/tests/Predis/Cluster/PredisStrategyTest.php
index fbf7922c8..70d492f49 100644
--- a/tests/Predis/Cluster/PredisStrategyTest.php
+++ b/tests/Predis/Cluster/PredisStrategyTest.php
@@ -106,6 +106,21 @@ public function testInterleavedKeysCommands(): void
}
}
+ /**
+ * @group disconnected
+ */
+ public function testFakeKeyCommandsWithOneKey(): void
+ {
+ $strategy = $this->getClusterStrategy();
+ $commands = $this->getCommandFactory();
+ $arguments = [];
+
+ foreach ($this->getExpectedCommands('keys-fake') as $commandID) {
+ $command = $commands->create($commandID, $arguments);
+ $this->assertNotNull($strategy->getSlot($command), $commandID);
+ }
+ }
+
/**
* @group disconnected
*/
@@ -327,6 +342,7 @@ protected function getExpectedCommands(string $type = null): array
'SORT' => 'variable',
'DUMP' => 'keys-first',
'RESTORE' => 'keys-first',
+ 'FLUSHDB' => 'keys-fake',
/* commands operating on string values */
'APPEND' => 'keys-first',
@@ -437,6 +453,9 @@ protected function getExpectedCommands(string $type = null): array
'EVAL' => 'keys-script',
'EVALSHA' => 'keys-script',
+ /* server */
+ 'INFO' => 'keys-fake',
+
/* commands performing geospatial operations */
'GEOADD' => 'keys-first',
'GEOHASH' => 'keys-first',
@@ -444,6 +463,9 @@ protected function getExpectedCommands(string $type = null): array
'GEODIST' => 'keys-first',
'GEORADIUS' => 'keys-georadius',
'GEORADIUSBYMEMBER' => 'keys-georadius',
+
+ /* cluster */
+ 'CLUSTER' => 'keys-fake',
];
if (isset($type)) {
diff --git a/tests/Predis/Cluster/RedisStrategyTest.php b/tests/Predis/Cluster/RedisStrategyTest.php
index dd570d531..d21b0b3bc 100644
--- a/tests/Predis/Cluster/RedisStrategyTest.php
+++ b/tests/Predis/Cluster/RedisStrategyTest.php
@@ -134,6 +134,21 @@ public function testInterleavedKeysCommandsWithMoreKeys(): void
}
}
+ /**
+ * @group disconnected
+ */
+ public function testFakeKeyCommandsWithOneKey(): void
+ {
+ $strategy = $this->getClusterStrategy();
+ $commands = $this->getCommandFactory();
+ $arguments = [];
+
+ foreach ($this->getExpectedCommands('keys-fake') as $commandID) {
+ $command = $commands->create($commandID, $arguments);
+ $this->assertNotNull($strategy->getSlot($command), $commandID);
+ }
+ }
+
/**
* @group disconnected
*/
@@ -350,6 +365,7 @@ protected function getExpectedCommands(string $type = null): array
'SORT' => 'keys-first', // TODO
'DUMP' => 'keys-first',
'RESTORE' => 'keys-first',
+ 'FLUSHDB' => 'keys-fake',
/* commands operating on string values */
'APPEND' => 'keys-first',
@@ -460,6 +476,9 @@ protected function getExpectedCommands(string $type = null): array
'EVAL' => 'keys-script',
'EVALSHA' => 'keys-script',
+ /* server */
+ 'INFO' => 'keys-fake',
+
/* commands performing geospatial operations */
'GEOADD' => 'keys-first',
'GEOHASH' => 'keys-first',
@@ -467,6 +486,9 @@ protected function getExpectedCommands(string $type = null): array
'GEODIST' => 'keys-first',
'GEORADIUS' => 'keys-georadius',
'GEORADIUSBYMEMBER' => 'keys-georadius',
+
+ /* cluster */
+ 'CLUSTER' => 'keys-fake',
];
if (isset($type)) {
diff --git a/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php b/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php
index b8acc4e1b..1cadb544d 100644
--- a/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php
+++ b/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php
@@ -978,6 +978,11 @@ public function commandArgumentsDataProvider(): array
['key'],
['prefix:key'],
],
+ /* ---------------- Redis 7.0 ---------------- */
+ ['EXPIRETIME',
+ ['key'],
+ ['prefix:key'],
+ ],
];
}
}
diff --git a/tests/Predis/Command/Redis/ACL_Test.php b/tests/Predis/Command/Redis/ACL_Test.php
index ff3d5fc6f..3f270b5ed 100644
--- a/tests/Predis/Command/Redis/ACL_Test.php
+++ b/tests/Predis/Command/Redis/ACL_Test.php
@@ -101,7 +101,7 @@ public function testDryRunSimulateExecutionOfGivenCommandByUser(): void
$redis->acl->dryRun('Test', 'SET', 'foo', 'bar')
);
$this->assertEquals(
- "This user has no permissions to run the 'get' command",
+ "User Test has no permissions to run the 'get' command",
$redis->acl->dryRun('Test', 'GET', 'foo')
);
}
diff --git a/tests/Predis/Command/Redis/BloomFilter/BFADD_Test.php b/tests/Predis/Command/Redis/BloomFilter/BFADD_Test.php
index 81bf9a909..81487c2fb 100644
--- a/tests/Predis/Command/Redis/BloomFilter/BFADD_Test.php
+++ b/tests/Predis/Command/Redis/BloomFilter/BFADD_Test.php
@@ -61,8 +61,9 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
- * @requiresRedisBfVersion >= 1.0
+ * @requiresRedisBfVersion >= 1.0.0
*/
public function testAddGivenItemIntoBloomFilter(): void
{
@@ -75,7 +76,8 @@ public function testAddGivenItemIntoBloomFilter(): void
/**
* @group connected
- * @requiresRedisBfVersion >= 1.0
+ * @group relay-incompatible
+ * @requiresRedisBfVersion >= 1.0.0
*/
public function testThrowsExceptionOnWrongType(): void
{
diff --git a/tests/Predis/Command/Redis/BloomFilter/BFEXISTS_Test.php b/tests/Predis/Command/Redis/BloomFilter/BFEXISTS_Test.php
index 528453326..32e55fd53 100644
--- a/tests/Predis/Command/Redis/BloomFilter/BFEXISTS_Test.php
+++ b/tests/Predis/Command/Redis/BloomFilter/BFEXISTS_Test.php
@@ -60,8 +60,9 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
- * @requiresRedisBfVersion >= 1.0
+ * @requiresRedisBfVersion >= 1.0.0
*/
public function testExistsReturnsExistingItemWithinBloomFilter(): void
{
diff --git a/tests/Predis/Command/Redis/BloomFilter/BFINFO_Test.php b/tests/Predis/Command/Redis/BloomFilter/BFINFO_Test.php
index e83e17cee..06f673790 100644
--- a/tests/Predis/Command/Redis/BloomFilter/BFINFO_Test.php
+++ b/tests/Predis/Command/Redis/BloomFilter/BFINFO_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(array $actualResponse, array $expectedResponse
/**
* @group connected
+ * @group relay-resp3
* @dataProvider filtersProvider
* @param array $filter
* @param string $key
@@ -98,7 +99,8 @@ public function testThrowsExceptionOnUnexpectedValueGiven(): void
/**
* @group connected
- * @requiresRedisBfVersion >= 1.0
+ * @group relay-resp3
+ * @requiresRedisBfVersion >= 1.0.0
*/
public function testThrowsExceptionOnWrongType(): void
{
diff --git a/tests/Predis/Command/Redis/BloomFilter/BFINSERT_Test.php b/tests/Predis/Command/Redis/BloomFilter/BFINSERT_Test.php
index a53bcc89d..421174cdf 100644
--- a/tests/Predis/Command/Redis/BloomFilter/BFINSERT_Test.php
+++ b/tests/Predis/Command/Redis/BloomFilter/BFINSERT_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider filtersProvider
* @param array $arguments
* @param string $key
@@ -101,6 +102,7 @@ public function testInsertThrowsExceptionOnNonExistingBloomFilterWithNoCreateMod
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 1.0.0
*/
@@ -134,6 +136,7 @@ public function testInsertAddItemOnlyOnExistingFilterWithNoCreateModifier(): voi
/**
* @group connected
+ * @group relay-resp3
* @dataProvider unexpectedValuesProvider
* @param array $arguments
* @param string $expectedExceptionMessage
diff --git a/tests/Predis/Command/Redis/BloomFilter/BFLOADCHUNK_Test.php b/tests/Predis/Command/Redis/BloomFilter/BFLOADCHUNK_Test.php
index 4e443aa18..1c1133a96 100644
--- a/tests/Predis/Command/Redis/BloomFilter/BFLOADCHUNK_Test.php
+++ b/tests/Predis/Command/Redis/BloomFilter/BFLOADCHUNK_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/BloomFilter/BFMADD_Test.php b/tests/Predis/Command/Redis/BloomFilter/BFMADD_Test.php
index 5b0b49685..da0def032 100644
--- a/tests/Predis/Command/Redis/BloomFilter/BFMADD_Test.php
+++ b/tests/Predis/Command/Redis/BloomFilter/BFMADD_Test.php
@@ -61,8 +61,9 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
- * @requiresRedisBfVersion >= 1.0
+ * @requiresRedisBfVersion >= 1.0.0
*/
public function testAddGivenItemsIntoBloomFilter(): void
{
@@ -75,7 +76,8 @@ public function testAddGivenItemsIntoBloomFilter(): void
/**
* @group connected
- * @requiresRedisBfVersion >= 1.0
+ * @group relay-incompatible
+ * @requiresRedisBfVersion >= 1.0.0
*/
public function testThrowsExceptionOnWrongType(): void
{
diff --git a/tests/Predis/Command/Redis/BloomFilter/BFMEXISTS_Test.php b/tests/Predis/Command/Redis/BloomFilter/BFMEXISTS_Test.php
index df151381a..d78cef77d 100644
--- a/tests/Predis/Command/Redis/BloomFilter/BFMEXISTS_Test.php
+++ b/tests/Predis/Command/Redis/BloomFilter/BFMEXISTS_Test.php
@@ -60,8 +60,9 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
- * @requiresRedisBfVersion >= 1.0
+ * @requiresRedisBfVersion >= 1.0.0
*/
public function testExistsReturnsExistingItemsWithinBloomFilter(): void
{
diff --git a/tests/Predis/Command/Redis/BloomFilter/BFRESERVE_Test.php b/tests/Predis/Command/Redis/BloomFilter/BFRESERVE_Test.php
index 1ac80529b..c5d8918fd 100644
--- a/tests/Predis/Command/Redis/BloomFilter/BFRESERVE_Test.php
+++ b/tests/Predis/Command/Redis/BloomFilter/BFRESERVE_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider filtersProvider
* @param array $filter
* @param string $key
@@ -98,7 +99,8 @@ public function testThrowsExceptionOnUnexpectedValueGiven(): void
/**
* @group connected
- * @requiresRedisBfVersion >= 1.0
+ * @group relay-resp3
+ * @requiresRedisBfVersion >= 1.0.0
*/
public function testThrowsExceptionOnWrongType(): void
{
diff --git a/tests/Predis/Command/Redis/BloomFilter/BFSCANDUMP_Test.php b/tests/Predis/Command/Redis/BloomFilter/BFSCANDUMP_Test.php
index 78f4a9ec3..3d64db40c 100644
--- a/tests/Predis/Command/Redis/BloomFilter/BFSCANDUMP_Test.php
+++ b/tests/Predis/Command/Redis/BloomFilter/BFSCANDUMP_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/CLUSTER_Test.php b/tests/Predis/Command/Redis/CLUSTER_Test.php
new file mode 100644
index 000000000..f693db750
--- /dev/null
+++ b/tests/Predis/Command/Redis/CLUSTER_Test.php
@@ -0,0 +1,130 @@
+getCommand();
+ $command->setArguments($arguments);
+
+ $this->assertSame($expected, $command->getArguments());
+ }
+
+ /**
+ * @group disconnected
+ */
+ public function testFilterArgumentsOfDelSlotsRange(): void
+ {
+ $arguments = ['DELSLOTSRANGE', 1, 1000];
+ $expected = ['DELSLOTSRANGE', 1, 1000];
+
+ $command = $this->getCommand();
+ $command->setArguments($arguments);
+
+ $this->assertSame($expected, $command->getArguments());
+ }
+
+ /**
+ * @group disconnected
+ */
+ public function testFilterArgumentsOfLinks(): void
+ {
+ $arguments = ['LINKS'];
+ $expected = ['LINKS'];
+
+ $command = $this->getCommand();
+ $command->setArguments($arguments);
+
+ $this->assertSame($expected, $command->getArguments());
+ }
+
+ /**
+ * @group disconnected
+ */
+ public function testFilterArgumentsOfShards(): void
+ {
+ $arguments = ['SHARDS'];
+ $expected = ['SHARDS'];
+
+ $command = $this->getCommand();
+ $command->setArguments($arguments);
+
+ $this->assertSame($expected, $command->getArguments());
+ }
+
+ /**
+ * @group connected
+ * @group cluster
+ * @return void
+ * @requiresRedisVersion >= 7.0.0
+ */
+ public function testAddSlotsRangeToGivenNode(): void
+ {
+ $redis = $this->getClient();
+
+ // Sometimes the cluster can be in a state where slots are
+ // missing on some shards (e.g. they are being rebalanced)
+ $shards = $redis->cluster->shards();
+ $slots = $shards[0][1] ?? $shards[0]['slots'];
+
+ if (empty($slots)) {
+ $slots = $shards[1][1] ?? $shards[1]['slots'];
+ }
+
+ if (empty($slots)) {
+ $slots = $shards[2][1] ?? $shards[2]['slots'];
+ }
+
+ [$startSlot, $endSlot] = $slots;
+
+ $this->assertEquals('OK', $redis->cluster->delSlotsRange($startSlot, $endSlot));
+ $this->assertEquals('OK', $redis->cluster->addSlotsRange($startSlot, $endSlot));
+ }
+
+ /**
+ * @group connected
+ * @group cluster
+ * @return void
+ * @requiresRedisVersion >= 7.0.0
+ */
+ public function testLinksReturnsClusterPeerLinks(): void
+ {
+ $redis = $this->getClient();
+
+ $this->assertNotEmpty($redis->cluster->links());
+ }
+}
diff --git a/tests/Predis/Command/Redis/Container/CLUSTER_Test.php b/tests/Predis/Command/Redis/Container/CLUSTER_Test.php
new file mode 100644
index 000000000..c69d7e0cf
--- /dev/null
+++ b/tests/Predis/Command/Redis/Container/CLUSTER_Test.php
@@ -0,0 +1,27 @@
+getMockBuilder(ClientInterface::class)->getMock();
+ $command = new CLUSTER($mockClient);
+
+ $this->assertSame('CLUSTER', $command->getContainerCommandId());
+ }
+}
diff --git a/tests/Predis/Command/Redis/CountMinSketch/CMSINCRBY_Test.php b/tests/Predis/Command/Redis/CountMinSketch/CMSINCRBY_Test.php
index d58779f1c..f41104bdf 100644
--- a/tests/Predis/Command/Redis/CountMinSketch/CMSINCRBY_Test.php
+++ b/tests/Predis/Command/Redis/CountMinSketch/CMSINCRBY_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider sketchesProvider
* @param array $incrementArguments
* @param array $queryArguments
diff --git a/tests/Predis/Command/Redis/CountMinSketch/CMSINFO_Test.php b/tests/Predis/Command/Redis/CountMinSketch/CMSINFO_Test.php
index 3f44471f7..0d343df1b 100644
--- a/tests/Predis/Command/Redis/CountMinSketch/CMSINFO_Test.php
+++ b/tests/Predis/Command/Redis/CountMinSketch/CMSINFO_Test.php
@@ -64,6 +64,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.0.0
*/
diff --git a/tests/Predis/Command/Redis/CountMinSketch/CMSINITBYDIM_Test.php b/tests/Predis/Command/Redis/CountMinSketch/CMSINITBYDIM_Test.php
index 4449ba629..35b901b9e 100644
--- a/tests/Predis/Command/Redis/CountMinSketch/CMSINITBYDIM_Test.php
+++ b/tests/Predis/Command/Redis/CountMinSketch/CMSINITBYDIM_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.0.0
*/
diff --git a/tests/Predis/Command/Redis/CountMinSketch/CMSINITBYPROB_Test.php b/tests/Predis/Command/Redis/CountMinSketch/CMSINITBYPROB_Test.php
index f280456f3..28e4fac03 100644
--- a/tests/Predis/Command/Redis/CountMinSketch/CMSINITBYPROB_Test.php
+++ b/tests/Predis/Command/Redis/CountMinSketch/CMSINITBYPROB_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.0.0
*/
diff --git a/tests/Predis/Command/Redis/CountMinSketch/CMSMERGE_Test.php b/tests/Predis/Command/Redis/CountMinSketch/CMSMERGE_Test.php
index 42eb687ca..7b3d3f9d7 100644
--- a/tests/Predis/Command/Redis/CountMinSketch/CMSMERGE_Test.php
+++ b/tests/Predis/Command/Redis/CountMinSketch/CMSMERGE_Test.php
@@ -59,6 +59,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider sketchesProvider
* @param array $mergeArguments
* @param string $destinationKey
@@ -107,6 +108,7 @@ public function testThrowsExceptionOnNonExistingDestinationCountMinSketch(): voi
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.0.0
*/
@@ -125,6 +127,7 @@ public function testThrowsExceptionOnNonExistingSourceCountMinSketch(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.0.0
*/
diff --git a/tests/Predis/Command/Redis/CountMinSketch/CMSQUERY_Test.php b/tests/Predis/Command/Redis/CountMinSketch/CMSQUERY_Test.php
index f3335a615..bf7aa51fd 100644
--- a/tests/Predis/Command/Redis/CountMinSketch/CMSQUERY_Test.php
+++ b/tests/Predis/Command/Redis/CountMinSketch/CMSQUERY_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider sketchesProvider
* @param array $queryArguments
* @param array $expectedResponse
diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFADDNX_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFADDNX_Test.php
index 94a6960b3..be99b8eab 100644
--- a/tests/Predis/Command/Redis/CuckooFilter/CFADDNX_Test.php
+++ b/tests/Predis/Command/Redis/CuckooFilter/CFADDNX_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFADD_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFADD_Test.php
index 95f729905..cf720a3ab 100644
--- a/tests/Predis/Command/Redis/CuckooFilter/CFADD_Test.php
+++ b/tests/Predis/Command/Redis/CuckooFilter/CFADD_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFCOUNT_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFCOUNT_Test.php
index 76306df79..1b86098fa 100644
--- a/tests/Predis/Command/Redis/CuckooFilter/CFCOUNT_Test.php
+++ b/tests/Predis/Command/Redis/CuckooFilter/CFCOUNT_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFDEL_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFDEL_Test.php
index 70f2c0985..8045b3e1b 100644
--- a/tests/Predis/Command/Redis/CuckooFilter/CFDEL_Test.php
+++ b/tests/Predis/Command/Redis/CuckooFilter/CFDEL_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFEXISTS_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFEXISTS_Test.php
index 78f6d0219..dceb09639 100644
--- a/tests/Predis/Command/Redis/CuckooFilter/CFEXISTS_Test.php
+++ b/tests/Predis/Command/Redis/CuckooFilter/CFEXISTS_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFINFO_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFINFO_Test.php
index 72ab27f20..f0f75f563 100644
--- a/tests/Predis/Command/Redis/CuckooFilter/CFINFO_Test.php
+++ b/tests/Predis/Command/Redis/CuckooFilter/CFINFO_Test.php
@@ -62,6 +62,7 @@ public function testParseResponse(array $actualResponse, array $expectedResponse
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFINSERTNX_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFINSERTNX_Test.php
index 1f8a1da49..7763fd9ac 100644
--- a/tests/Predis/Command/Redis/CuckooFilter/CFINSERTNX_Test.php
+++ b/tests/Predis/Command/Redis/CuckooFilter/CFINSERTNX_Test.php
@@ -51,6 +51,7 @@ public function testFilterArguments(array $actualArguments, array $expectedArgum
/**
* @group connected
+ * @group relay-resp3
* @dataProvider filtersProvider
* @param array $filterArguments
* @param string $key
@@ -76,6 +77,7 @@ public function testInsertItemsIntoNonExistingCuckooFilter(
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 1.0.0
*/
@@ -107,6 +109,7 @@ public function testInsertThrowsErrorOnInsertingIntoNonExistingFilterWithNoCreat
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFINSERT_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFINSERT_Test.php
index 901040603..9c4bd79b5 100644
--- a/tests/Predis/Command/Redis/CuckooFilter/CFINSERT_Test.php
+++ b/tests/Predis/Command/Redis/CuckooFilter/CFINSERT_Test.php
@@ -52,6 +52,7 @@ public function testFilterArguments(array $actualArguments, array $expectedArgum
/**
* @group connected
+ * @group relay-resp3
* @dataProvider filtersProvider
* @param array $filterArguments
* @param string $key
@@ -77,6 +78,7 @@ public function testInsertItemsIntoGivenCuckooFilter(
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 1.0.0
*/
@@ -110,6 +112,7 @@ public function testInsertThrowsErrorOnInsertingIntoNonExistingFilterWithNoCreat
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 1.0.0
*/
@@ -125,6 +128,7 @@ public function testInsertIntoAlreadyExistingFilterWithNoCreateModifier(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFLOADCHUNK_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFLOADCHUNK_Test.php
index aaa738f95..0383c82bc 100644
--- a/tests/Predis/Command/Redis/CuckooFilter/CFLOADCHUNK_Test.php
+++ b/tests/Predis/Command/Redis/CuckooFilter/CFLOADCHUNK_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFMEXISTS_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFMEXISTS_Test.php
index a1b91ca06..75c4fe227 100644
--- a/tests/Predis/Command/Redis/CuckooFilter/CFMEXISTS_Test.php
+++ b/tests/Predis/Command/Redis/CuckooFilter/CFMEXISTS_Test.php
@@ -60,8 +60,9 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
- * @requiresRedisBfVersion >= 1.0
+ * @requiresRedisBfVersion >= 1.0.0
*/
public function testExistsReturnsExistingItemsWithinCuckooFilter(): void
{
diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFRESERVE_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFRESERVE_Test.php
index eef7b0212..1b88687f9 100644
--- a/tests/Predis/Command/Redis/CuckooFilter/CFRESERVE_Test.php
+++ b/tests/Predis/Command/Redis/CuckooFilter/CFRESERVE_Test.php
@@ -51,6 +51,7 @@ public function testFilterArguments(array $actualArguments, array $expectedArgum
/**
* @group connected
+ * @group relay-resp3
* @dataProvider filtersProvider
* @param array $filterArguments
* @param int $expectedCapacity
diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFSCANDUMP_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFSCANDUMP_Test.php
index 1e6b5983a..cad364681 100644
--- a/tests/Predis/Command/Redis/CuckooFilter/CFSCANDUMP_Test.php
+++ b/tests/Predis/Command/Redis/CuckooFilter/CFSCANDUMP_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/GET_Test.php b/tests/Predis/Command/Redis/GET_Test.php
index 80c047b7a..3409ae349 100644
--- a/tests/Predis/Command/Redis/GET_Test.php
+++ b/tests/Predis/Command/Redis/GET_Test.php
@@ -67,6 +67,16 @@ public function testReturnsStringValue(): void
$this->assertEquals('bar', $redis->get('foo'));
}
+ /**
+ * @group connected
+ * @group cluster
+ * @requiresRedisVersion >= 6.0.0
+ */
+ public function testReturnsStringValueUsingCluster(): void
+ {
+ $this->testReturnsStringValue();
+ }
+
/**
* @group connected
*/
@@ -80,6 +90,16 @@ public function testReturnsEmptyStringOnEmptyStrings(): void
$this->assertSame('', $redis->get('foo'));
}
+ /**
+ * @group connected
+ * @group cluster
+ * @requiresRedisVersion >= 6.0.0
+ */
+ public function testReturnsEmptyStringOnEmptyStringsUsingCluster(): void
+ {
+ $this->testReturnsEmptyStringOnEmptyStrings();
+ }
+
/**
* @group connected
*/
@@ -91,6 +111,16 @@ public function testReturnsNullOnNonExistingKeys(): void
$this->assertNull($redis->get('foo'));
}
+ /**
+ * @group connected
+ * @group cluster
+ * @requiresRedisVersion >= 6.0.0
+ */
+ public function testReturnsNullOnNonExistingKeysUsingCluster(): void
+ {
+ $this->testReturnsNullOnNonExistingKeys();
+ }
+
/**
* @group connected
*/
@@ -104,4 +134,14 @@ public function testThrowsExceptionOnWrongType(): void
$redis->rpush('metavars', 'foo');
$redis->get('metavars');
}
+
+ /**
+ * @group connected
+ * @group cluster
+ * @requiresRedisVersion >= 6.0.0
+ */
+ public function testThrowsExceptionOnWrongTypeUsingCluster(): void
+ {
+ $this->testThrowsExceptionOnWrongType();
+ }
}
diff --git a/tests/Predis/Command/Redis/HGETALL_Test.php b/tests/Predis/Command/Redis/HGETALL_Test.php
index 308a3f580..41e799f3a 100644
--- a/tests/Predis/Command/Redis/HGETALL_Test.php
+++ b/tests/Predis/Command/Redis/HGETALL_Test.php
@@ -75,6 +75,20 @@ public function testReturnsAllTheFieldsAndTheirValues(): void
$this->assertSame([], $redis->hgetall('unknown'));
}
+ /**
+ * @group connected
+ * @group cluster
+ * @requiresRedisVersion >= 6.0.0
+ */
+ public function testReturnsAllTheFieldsAndTheirValuesUsingCluster(): void
+ {
+ $redis = $this->getClient();
+
+ $redis->del('metavars');
+
+ $this->testReturnsAllTheFieldsAndTheirValues();
+ }
+
/**
* @group connected
* @requiresRedisVersion >= 2.0.0
@@ -82,11 +96,21 @@ public function testReturnsAllTheFieldsAndTheirValues(): void
public function testThrowsExceptionOnWrongType(): void
{
$this->expectException('Predis\Response\ServerException');
- $this->expectExceptionMessage('Operation against a key holding the wrong kind of value');
+ $this->expectExceptionMessageMatches('/.*Operation against a key holding the wrong kind of value.*/');
$redis = $this->getClient();
$redis->set('foo', 'bar');
$redis->hgetall('foo');
}
+
+ /**
+ * @group connected
+ * @group cluster
+ * @requiresRedisVersion >= 6.0.0
+ */
+ public function testThrowsExceptionOnWrongTypeUsingCluster(): void
+ {
+ $this->testThrowsExceptionOnWrongType();
+ }
}
diff --git a/tests/Predis/Command/Redis/HGET_Test.php b/tests/Predis/Command/Redis/HGET_Test.php
index 443cb4e8b..3efe2a356 100644
--- a/tests/Predis/Command/Redis/HGET_Test.php
+++ b/tests/Predis/Command/Redis/HGET_Test.php
@@ -71,6 +71,20 @@ public function testReturnsValueOfSpecifiedField(): void
$this->assertNull($redis->hget('unknown', 'foo'));
}
+ /**
+ * @group connected
+ * @group cluster
+ * @requiresRedisVersion >= 6.0.0
+ */
+ public function testReturnsValueOfSpecifiedFieldUsingCluster(): void
+ {
+ $redis = $this->getClient();
+
+ $redis->del('metavars');
+
+ $this->testReturnsValueOfSpecifiedField();
+ }
+
/**
* @group connected
* @requiresRedisVersion >= 2.0.0
@@ -78,11 +92,21 @@ public function testReturnsValueOfSpecifiedField(): void
public function testThrowsExceptionOnWrongType(): void
{
$this->expectException('Predis\Response\ServerException');
- $this->expectExceptionMessage('Operation against a key holding the wrong kind of value');
+ $this->expectExceptionMessageMatches('/.*Operation against a key holding the wrong kind of value.*/');
$redis = $this->getClient();
$redis->set('foo', 'bar');
$redis->hget('foo', 'bar');
}
+
+ /**
+ * @group connected
+ * @group cluster
+ * @requiresRedisVersion >= 6.0.0
+ */
+ public function testThrowsExceptionOnWrongTypeUsingCluster(): void
+ {
+ $this->testThrowsExceptionOnWrongType();
+ }
}
diff --git a/tests/Predis/Command/Redis/HSET_Test.php b/tests/Predis/Command/Redis/HSET_Test.php
index e6d77ae2f..6cd60918a 100644
--- a/tests/Predis/Command/Redis/HSET_Test.php
+++ b/tests/Predis/Command/Redis/HSET_Test.php
@@ -73,6 +73,20 @@ public function testSetsValueOfSpecifiedField(): void
$this->assertSame(['bar', 'piyo'], $redis->hmget('metavars', 'foo', 'hoge'));
}
+ /**
+ * @group connected
+ * @group cluster
+ * @requiresRedisVersion >= 6.0.0
+ */
+ public function testSetsValueOfSpecifiedFieldUsingCluster(): void
+ {
+ $redis = $this->getClient();
+
+ $redis->del('metavars');
+
+ $this->testSetsValueOfSpecifiedField();
+ }
+
/**
* @group connected
* @requiresRedisVersion >= 2.0.0
@@ -80,11 +94,21 @@ public function testSetsValueOfSpecifiedField(): void
public function testThrowsExceptionOnWrongType(): void
{
$this->expectException('Predis\Response\ServerException');
- $this->expectExceptionMessage('Operation against a key holding the wrong kind of value');
+ $this->expectExceptionMessageMatches('/.*Operation against a key holding the wrong kind of value.*/');
$redis = $this->getClient();
$redis->set('metavars', 'foo');
$redis->hset('metavars', 'foo', 'bar');
}
+
+ /**
+ * @group connected
+ * @group cluster
+ * @requiresRedisVersion >= 6.0.0
+ */
+ public function testThrowsExceptionOnWrongTypeUsingCluster(): void
+ {
+ $this->testThrowsExceptionOnWrongType();
+ }
}
diff --git a/tests/Predis/Command/Redis/Json/JSONARRAPPEND_Test.php b/tests/Predis/Command/Redis/Json/JSONARRAPPEND_Test.php
index 678463556..84a69a417 100644
--- a/tests/Predis/Command/Redis/Json/JSONARRAPPEND_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONARRAPPEND_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/Json/JSONARRINDEX_Test.php b/tests/Predis/Command/Redis/Json/JSONARRINDEX_Test.php
index 43e91ca47..3a27c16cb 100644
--- a/tests/Predis/Command/Redis/Json/JSONARRINDEX_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONARRINDEX_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/Json/JSONARRINSERT_Test.php b/tests/Predis/Command/Redis/Json/JSONARRINSERT_Test.php
index 5bb2c758e..61298d3e2 100644
--- a/tests/Predis/Command/Redis/Json/JSONARRINSERT_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONARRINSERT_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/Json/JSONARRLEN_Test.php b/tests/Predis/Command/Redis/Json/JSONARRLEN_Test.php
index 6565e3471..e90255006 100644
--- a/tests/Predis/Command/Redis/Json/JSONARRLEN_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONARRLEN_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/Json/JSONARRPOP_Test.php b/tests/Predis/Command/Redis/Json/JSONARRPOP_Test.php
index 6d80fd990..8bf1f37d5 100644
--- a/tests/Predis/Command/Redis/Json/JSONARRPOP_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONARRPOP_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/Json/JSONARRTRIM_Test.php b/tests/Predis/Command/Redis/Json/JSONARRTRIM_Test.php
index a40de6a06..7ca362317 100644
--- a/tests/Predis/Command/Redis/Json/JSONARRTRIM_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONARRTRIM_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/Json/JSONCLEAR_Test.php b/tests/Predis/Command/Redis/Json/JSONCLEAR_Test.php
index 5e53cfa6f..4cffb5a1d 100644
--- a/tests/Predis/Command/Redis/Json/JSONCLEAR_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONCLEAR_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/Json/JSONDEBUG_Test.php b/tests/Predis/Command/Redis/Json/JSONDEBUG_Test.php
index b13feec9d..0cde3a125 100644
--- a/tests/Predis/Command/Redis/Json/JSONDEBUG_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONDEBUG_Test.php
@@ -56,6 +56,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/Json/JSONDEL_Test.php b/tests/Predis/Command/Redis/Json/JSONDEL_Test.php
index 4d48d82f6..f8e2d0011 100644
--- a/tests/Predis/Command/Redis/Json/JSONDEL_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONDEL_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/Json/JSONFORGET_Test.php b/tests/Predis/Command/Redis/Json/JSONFORGET_Test.php
index 9e5ef474a..0646b74d0 100644
--- a/tests/Predis/Command/Redis/Json/JSONFORGET_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONFORGET_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/Json/JSONGET_Test.php b/tests/Predis/Command/Redis/Json/JSONGET_Test.php
index 39c6cea8c..b1a278601 100644
--- a/tests/Predis/Command/Redis/Json/JSONGET_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONGET_Test.php
@@ -59,6 +59,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonData
* @param string $key
@@ -101,6 +102,7 @@ public function testReturnsJsonValuesArrayOnMultiplePathsProvided(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider unexpectedValuesProvider
* @param array $arguments
* @param string $expectedExceptionMessage
diff --git a/tests/Predis/Command/Redis/Json/JSONMERGE_Test.php b/tests/Predis/Command/Redis/Json/JSONMERGE_Test.php
index b9cb7a740..57ef01f45 100644
--- a/tests/Predis/Command/Redis/Json/JSONMERGE_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONMERGE_Test.php
@@ -57,6 +57,7 @@ public function testParseResponse(): void
/**
* @dataProvider jsonProvider
* @group connected
+ * @group relay-resp3
* @param array $setArguments
* @param array $mergeArguments
* @param string $expectedResponse
diff --git a/tests/Predis/Command/Redis/Json/JSONMGET_Test.php b/tests/Predis/Command/Redis/Json/JSONMGET_Test.php
index 5700bfee4..19c703f29 100644
--- a/tests/Predis/Command/Redis/Json/JSONMGET_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONMGET_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $firstJson
* @param array $secondJson
diff --git a/tests/Predis/Command/Redis/Json/JSONMSET_Test.php b/tests/Predis/Command/Redis/Json/JSONMSET_Test.php
index 2083d39c6..68fcbdb71 100644
--- a/tests/Predis/Command/Redis/Json/JSONMSET_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONMSET_Test.php
@@ -57,6 +57,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisJsonVersion >= 2.6.0
*/
@@ -70,6 +71,7 @@ public function testSetMultipleJsonDocuments(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisJsonVersion >= 2.6.0
*/
diff --git a/tests/Predis/Command/Redis/Json/JSONNUMINCRBY_Test.php b/tests/Predis/Command/Redis/Json/JSONNUMINCRBY_Test.php
index 3dc871894..918f382d8 100644
--- a/tests/Predis/Command/Redis/Json/JSONNUMINCRBY_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONNUMINCRBY_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/Json/JSONOBJKEYS_Test.php b/tests/Predis/Command/Redis/Json/JSONOBJKEYS_Test.php
index 5726e9a1a..706b1f7c4 100644
--- a/tests/Predis/Command/Redis/Json/JSONOBJKEYS_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONOBJKEYS_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/Json/JSONOBJLEN_Test.php b/tests/Predis/Command/Redis/Json/JSONOBJLEN_Test.php
index 0380bc932..79f5ff5e5 100644
--- a/tests/Predis/Command/Redis/Json/JSONOBJLEN_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONOBJLEN_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/Json/JSONRESP_Test.php b/tests/Predis/Command/Redis/Json/JSONRESP_Test.php
index 5fa15aaf2..5df533542 100644
--- a/tests/Predis/Command/Redis/Json/JSONRESP_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONRESP_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/Json/JSONSET_Test.php b/tests/Predis/Command/Redis/Json/JSONSET_Test.php
index dc1715f8c..3037058ac 100644
--- a/tests/Predis/Command/Redis/Json/JSONSET_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONSET_Test.php
@@ -59,6 +59,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param string $key
* @param string $defaultJson
diff --git a/tests/Predis/Command/Redis/Json/JSONSTRAPPEND_Test.php b/tests/Predis/Command/Redis/Json/JSONSTRAPPEND_Test.php
index 3f2b1e329..4cd19af43 100644
--- a/tests/Predis/Command/Redis/Json/JSONSTRAPPEND_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONSTRAPPEND_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/Json/JSONSTRLEN_Test.php b/tests/Predis/Command/Redis/Json/JSONSTRLEN_Test.php
index 4058d89a8..03fb285c9 100644
--- a/tests/Predis/Command/Redis/Json/JSONSTRLEN_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONSTRLEN_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/Json/JSONTOGGLE_Test.php b/tests/Predis/Command/Redis/Json/JSONTOGGLE_Test.php
index 40dc8950c..8d8aced44 100644
--- a/tests/Predis/Command/Redis/Json/JSONTOGGLE_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONTOGGLE_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/Json/JSONTYPE_Test.php b/tests/Predis/Command/Redis/Json/JSONTYPE_Test.php
index f40d4e13c..c90c76c65 100644
--- a/tests/Predis/Command/Redis/Json/JSONTYPE_Test.php
+++ b/tests/Predis/Command/Redis/Json/JSONTYPE_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider jsonProvider
* @param array $jsonArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/OBJECT_Test.php b/tests/Predis/Command/Redis/OBJECT_Test.php
index 7fbec0e62..51e93ea53 100644
--- a/tests/Predis/Command/Redis/OBJECT_Test.php
+++ b/tests/Predis/Command/Redis/OBJECT_Test.php
@@ -82,7 +82,7 @@ public function testObjectIdletime(): void
/**
* @group connected
- * @requiresRedisVersion >= 2.2.3
+ * @requiresRedisVersion < 7.2.0
*/
public function testObjectEncoding(): void
{
@@ -92,6 +92,19 @@ public function testObjectEncoding(): void
$this->assertMatchesRegularExpression('/[zip|quick]list/', $redis->object('ENCODING', 'list:metavars'));
}
+ /**
+ * @group connected
+ * @requiresRedisVersion >= 7.2.0
+ */
+ public function testObjectEncodingReturnsUpdatedResponse(): void
+ {
+ $redis = $this->getClient();
+
+ $redis->lpush('list:metavars', 'foo', 'bar');
+
+ $this->assertSame('listpack', $redis->object('ENCODING', 'list:metavars'));
+ }
+
/**
* @group connected
* @requiresRedisVersion >= 2.2.3
diff --git a/tests/Predis/Command/Redis/SET_Test.php b/tests/Predis/Command/Redis/SET_Test.php
index 5127e9e16..71f4aaf2f 100644
--- a/tests/Predis/Command/Redis/SET_Test.php
+++ b/tests/Predis/Command/Redis/SET_Test.php
@@ -82,6 +82,16 @@ public function testSetStringValue(): void
$this->assertSame('bar', $redis->get('foo'));
}
+ /**
+ * @group connected
+ * @group cluster
+ * @requiresRedisVersion >= 6.0.0
+ */
+ public function testSetStringValueUsingCluster(): void
+ {
+ $this->testSetStringValue();
+ }
+
/**
* @group connected
* @requiresRedisVersion >= 2.6.12
@@ -94,6 +104,16 @@ public function testSetStringValueWithModifierEX(): void
$this->assertSame(1, $redis->ttl('foo'));
}
+ /**
+ * @group connected
+ * @group cluster
+ * @requiresRedisVersion >= 6.0.0
+ */
+ public function testSetStringValueWithModifierEXUsingCluster(): void
+ {
+ $this->testSetStringValueWithModifierEX();
+ }
+
/**
* @group connected
* @requiresRedisVersion >= 2.6.12
@@ -109,6 +129,16 @@ public function testSetStringValueWithModifierPX(): void
$this->assertLessThanOrEqual(1000, $pttl);
}
+ /**
+ * @group connected
+ * @group cluster
+ * @requiresRedisVersion >= 6.0.0
+ */
+ public function testSetStringValueWithModifierPXUsingCluster(): void
+ {
+ $this->testSetStringValueWithModifierPX();
+ }
+
/**
* @group connected
* @requiresRedisVersion >= 2.6.12
@@ -121,6 +151,16 @@ public function testSetStringValueWithModifierNX(): void
$this->assertNull($redis->set('foo', 'bar', 'NX'));
}
+ /**
+ * @group connected
+ * @group cluster
+ * @requiresRedisVersion >= 6.0.0
+ */
+ public function testSetStringValueWithModifierNXUsingCluster(): void
+ {
+ $this->testSetStringValueWithModifierNX();
+ }
+
/**
* @group connected
* @requiresRedisVersion >= 2.6.12
@@ -134,4 +174,26 @@ public function testSetStringValueWithModifierXX(): void
$this->assertEquals('OK', $redis->set('foo', 'barbar', 'XX'));
$this->assertNull($redis->set('foofoo', 'barbar', 'XX'));
}
+
+ /**
+ * @group connected
+ * @group cluster
+ * @requiresRedisVersion >= 6.0.0
+ */
+ public function testSetStringValueWithModifierXXUsingCluster(): void
+ {
+ $this->testSetStringValueWithModifierXX();
+ }
+
+ /**
+ * @group connected
+ * @group cluster
+ * @requiresRedisVersion >= 3.0.0
+ */
+ public function testSetStringValueInClusterMode(): void
+ {
+ $redis = $this->getClient();
+
+ $this->assertEquals('OK', $redis->set('foo', 'bar'));
+ }
}
diff --git a/tests/Predis/Command/Redis/SHUTDOWN_Test.php b/tests/Predis/Command/Redis/SHUTDOWN_Test.php
index ddf9f1122..533139db7 100644
--- a/tests/Predis/Command/Redis/SHUTDOWN_Test.php
+++ b/tests/Predis/Command/Redis/SHUTDOWN_Test.php
@@ -35,13 +35,48 @@ protected function getExpectedId(): string
}
/**
+ * @dataProvider argumentsProvider
* @group disconnected
*/
- public function testFilterArguments(): void
+ public function testFilterArguments(array $actualArguments, array $expectedResponse): void
{
$command = $this->getCommand();
- $command->setArguments([]);
+ $command->setArguments($actualArguments);
- $this->assertSame([], $command->getArguments());
+ $this->assertSame($expectedResponse, $command->getArguments());
+ }
+
+ public function argumentsProvider(): array
+ {
+ return [
+ 'with no arguments' => [
+ [],
+ [],
+ ],
+ 'with SAVE argument' => [
+ [true],
+ ['SAVE'],
+ ],
+ 'with NOSAVE argument' => [
+ [false],
+ ['NOSAVE'],
+ ],
+ 'with NOW argument' => [
+ [null, true],
+ ['NOW'],
+ ],
+ 'with FORCE argument' => [
+ [null, false, true],
+ ['FORCE'],
+ ],
+ 'with ABORT argument' => [
+ [null, false, false, true],
+ ['ABORT'],
+ ],
+ 'with all arguments' => [
+ [true, true, true, true],
+ ['SAVE', 'NOW', 'FORCE', 'ABORT'],
+ ],
+ ];
}
}
diff --git a/tests/Predis/Command/Redis/Search/FTAGGREGATE_Test.php b/tests/Predis/Command/Redis/Search/FTAGGREGATE_Test.php
index 5518709ec..943126517 100644
--- a/tests/Predis/Command/Redis/Search/FTAGGREGATE_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTAGGREGATE_Test.php
@@ -64,6 +64,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.1.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTALIASADD_Test.php b/tests/Predis/Command/Redis/Search/FTALIASADD_Test.php
index fb659acf4..cfdbbb608 100644
--- a/tests/Predis/Command/Redis/Search/FTALIASADD_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTALIASADD_Test.php
@@ -63,6 +63,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
@@ -100,6 +101,7 @@ public function testThrowsExceptionOnNonExistingIndex(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTALIASDEL_Test.php b/tests/Predis/Command/Redis/Search/FTALIASDEL_Test.php
index c448c7996..d5a599dbf 100644
--- a/tests/Predis/Command/Redis/Search/FTALIASDEL_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTALIASDEL_Test.php
@@ -62,6 +62,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTALIASUPDATE_Test.php b/tests/Predis/Command/Redis/Search/FTALIASUPDATE_Test.php
index e21531bb5..da383369e 100644
--- a/tests/Predis/Command/Redis/Search/FTALIASUPDATE_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTALIASUPDATE_Test.php
@@ -62,6 +62,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
@@ -99,6 +100,7 @@ public function testUpdateRemovesAliasAssociationFromAlreadyExistingAlias(): voi
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTALTER_Test.php b/tests/Predis/Command/Redis/Search/FTALTER_Test.php
index 06e815e5f..146652695 100644
--- a/tests/Predis/Command/Redis/Search/FTALTER_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTALTER_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTCONFIG_Test.php b/tests/Predis/Command/Redis/Search/FTCONFIG_Test.php
index 8b75363e3..14a93dbee 100644
--- a/tests/Predis/Command/Redis/Search/FTCONFIG_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTCONFIG_Test.php
@@ -89,6 +89,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
@@ -101,6 +102,7 @@ public function testSetGivenRediSearchConfigurationParameter(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
@@ -114,6 +116,7 @@ public function testGetReturnsGivenRediSearchConfigurationParameter(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
@@ -136,6 +139,7 @@ public function testHelpReturnsGivenRediSearchConfigurationDescription(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTCREATE_Test.php b/tests/Predis/Command/Redis/Search/FTCREATE_Test.php
index 746d3d7bc..d154b79c5 100644
--- a/tests/Predis/Command/Redis/Search/FTCREATE_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTCREATE_Test.php
@@ -62,6 +62,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTCURSOR_Test.php b/tests/Predis/Command/Redis/Search/FTCURSOR_Test.php
index a814eaacf..8044cb0d1 100644
--- a/tests/Predis/Command/Redis/Search/FTCURSOR_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTCURSOR_Test.php
@@ -79,6 +79,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.1.0
*/
@@ -178,6 +179,7 @@ public function testDelExplicitlyRemovesExistingCursor(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.1.0
*/
@@ -193,6 +195,7 @@ public function testReadThrowsExceptionOnWrongCursorId(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.1.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTDICTADD_Test.php b/tests/Predis/Command/Redis/Search/FTDICTADD_Test.php
index 577fda960..d4a4bfb16 100644
--- a/tests/Predis/Command/Redis/Search/FTDICTADD_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTDICTADD_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.4.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTDICTDEL_Test.php b/tests/Predis/Command/Redis/Search/FTDICTDEL_Test.php
index 566add53f..465444652 100644
--- a/tests/Predis/Command/Redis/Search/FTDICTDEL_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTDICTDEL_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider dictionariesProvider
* @param array $addArguments
* @param array $deleteArguments
diff --git a/tests/Predis/Command/Redis/Search/FTDICTDUMP_Test.php b/tests/Predis/Command/Redis/Search/FTDICTDUMP_Test.php
index 7c260dc78..d95a6c40e 100644
--- a/tests/Predis/Command/Redis/Search/FTDICTDUMP_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTDICTDUMP_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.4.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTDROPINDEX_Test.php b/tests/Predis/Command/Redis/Search/FTDROPINDEX_Test.php
index d026db7a7..d229f0513 100644
--- a/tests/Predis/Command/Redis/Search/FTDROPINDEX_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTDROPINDEX_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 2.0.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTEXPLAIN_Test.php b/tests/Predis/Command/Redis/Search/FTEXPLAIN_Test.php
index 8d6dcead8..ac474ca63 100644
--- a/tests/Predis/Command/Redis/Search/FTEXPLAIN_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTEXPLAIN_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTINFO_Test.php b/tests/Predis/Command/Redis/Search/FTINFO_Test.php
index 6915e0066..98cc2170f 100644
--- a/tests/Predis/Command/Redis/Search/FTINFO_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTINFO_Test.php
@@ -63,7 +63,7 @@ public function testParseResponse(): void
/**
* @group connected
- * @group relay-incompatible
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*
@@ -96,7 +96,6 @@ public function testThrowsExceptionOnNonExistingIndex(): void
$redis = $this->getClient();
$this->expectException(ServerException::class);
- $this->expectExceptionMessage('Unknown Index name');
$redis->ftinfo('index');
}
diff --git a/tests/Predis/Command/Redis/Search/FTPROFILE_Test.php b/tests/Predis/Command/Redis/Search/FTPROFILE_Test.php
index 78c83c69c..694ab2aff 100644
--- a/tests/Predis/Command/Redis/Search/FTPROFILE_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTPROFILE_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider queryProvider
* @param array $createArguments
* @param array $profileArguments
diff --git a/tests/Predis/Command/Redis/Search/FTSEARCH_Test.php b/tests/Predis/Command/Redis/Search/FTSEARCH_Test.php
index dfca91d5a..f7c690eba 100644
--- a/tests/Predis/Command/Redis/Search/FTSEARCH_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTSEARCH_Test.php
@@ -54,6 +54,7 @@ public function testFilterArguments(array $actualArguments, array $expectedArgum
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
* @requiresRedisJsonVersion >= 1.0.0
@@ -80,7 +81,7 @@ public function testSearchValuesByJsonIndex(): void
$this->assertEquals('OK', $ftCreateResponse);
// Timeout to make sure that index created before search performed.
- usleep(2000);
+ usleep(10000);
$ftSearchArguments = new SearchArguments();
$ftSearchArguments->addReturn(2, 'arr', 'val');
@@ -91,6 +92,7 @@ public function testSearchValuesByJsonIndex(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
@@ -114,7 +116,7 @@ public function testSearchValuesByHashIndex(): void
$this->assertEquals('OK', $ftCreateResponse);
// Timeout to make sure that index created before search performed.
- usleep(2000);
+ usleep(10000);
$ftSearchArguments = new SearchArguments();
$ftSearchArguments->addReturn(1, 'should_return');
diff --git a/tests/Predis/Command/Redis/Search/FTSPELLCHECK_Test.php b/tests/Predis/Command/Redis/Search/FTSPELLCHECK_Test.php
index 16ee1f70a..55d91fcfc 100644
--- a/tests/Predis/Command/Redis/Search/FTSPELLCHECK_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTSPELLCHECK_Test.php
@@ -62,6 +62,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.4.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTSUGADD_Test.php b/tests/Predis/Command/Redis/Search/FTSUGADD_Test.php
index f858796c9..5a0d3d055 100644
--- a/tests/Predis/Command/Redis/Search/FTSUGADD_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTSUGADD_Test.php
@@ -59,6 +59,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTSUGDEL_Test.php b/tests/Predis/Command/Redis/Search/FTSUGDEL_Test.php
index 3a52e4204..edb5a02cf 100644
--- a/tests/Predis/Command/Redis/Search/FTSUGDEL_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTSUGDEL_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTSUGGET_Test.php b/tests/Predis/Command/Redis/Search/FTSUGGET_Test.php
index 3239d53d0..90f83e857 100644
--- a/tests/Predis/Command/Redis/Search/FTSUGGET_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTSUGGET_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider suggestionProvider
* @param array $addArguments
* @param array $getArguments
@@ -83,6 +84,7 @@ public function testGetSuggestionsForGivenPrefix(
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTSUGLEN_Test.php b/tests/Predis/Command/Redis/Search/FTSUGLEN_Test.php
index 214ed246b..b23a6aeca 100644
--- a/tests/Predis/Command/Redis/Search/FTSUGLEN_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTSUGLEN_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTSYNDUMP_Test.php b/tests/Predis/Command/Redis/Search/FTSYNDUMP_Test.php
index 2821f65a7..f74d19921 100644
--- a/tests/Predis/Command/Redis/Search/FTSYNDUMP_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTSYNDUMP_Test.php
@@ -62,6 +62,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.2.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTSYNUPDATE_Test.php b/tests/Predis/Command/Redis/Search/FTSYNUPDATE_Test.php
index 21c5eb1b2..c015d79c9 100644
--- a/tests/Predis/Command/Redis/Search/FTSYNUPDATE_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTSYNUPDATE_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.2.0
*/
@@ -106,6 +107,7 @@ public function testUpdatesAlreadyExistingSynonymGroupWithinGivenIndex(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.2.0
*/
diff --git a/tests/Predis/Command/Redis/Search/FTTAGVALS_Test.php b/tests/Predis/Command/Redis/Search/FTTAGVALS_Test.php
index 80a7813a0..4bf809b31 100644
--- a/tests/Predis/Command/Redis/Search/FTTAGVALS_Test.php
+++ b/tests/Predis/Command/Redis/Search/FTTAGVALS_Test.php
@@ -63,6 +63,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTADD_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTADD_Test.php
index fa76ee6ac..896fa24f2 100644
--- a/tests/Predis/Command/Redis/TDigest/TDIGESTADD_Test.php
+++ b/tests/Predis/Command/Redis/TDigest/TDIGESTADD_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.4.0
*/
diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTBYRANK_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTBYRANK_Test.php
index 4aadeb79d..8549c56a5 100644
--- a/tests/Predis/Command/Redis/TDigest/TDIGESTBYRANK_Test.php
+++ b/tests/Predis/Command/Redis/TDigest/TDIGESTBYRANK_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.4.0
*/
diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTBYREVRANK_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTBYREVRANK_Test.php
index 7fc8a3a19..232508f24 100644
--- a/tests/Predis/Command/Redis/TDigest/TDIGESTBYREVRANK_Test.php
+++ b/tests/Predis/Command/Redis/TDigest/TDIGESTBYREVRANK_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.4.0
*/
diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTCDF_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTCDF_Test.php
index 2b23e6aed..562150849 100644
--- a/tests/Predis/Command/Redis/TDigest/TDIGESTCDF_Test.php
+++ b/tests/Predis/Command/Redis/TDigest/TDIGESTCDF_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.4.0
*/
@@ -76,8 +77,8 @@ public function testReturnsValuesEstimatedForGivenRanks(): void
$actualResponse = $redis->tdigestcdf('key', 0, 1, 2, 3, 4);
- $this->assertEquals($expectedResponse, $actualResponse);
- $this->assertEquals(['nan', 'nan'], $redis->tdigestcdf('empty_key', 0, 1));
+ $this->assertSameWithPrecision($expectedResponse, $actualResponse, 5);
+ $this->assertSame(['nan', 'nan'], $redis->tdigestcdf('empty_key', 0, 1));
}
/**
diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTCREATE_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTCREATE_Test.php
index 39bcc23c0..2ead7c260 100644
--- a/tests/Predis/Command/Redis/TDigest/TDIGESTCREATE_Test.php
+++ b/tests/Predis/Command/Redis/TDigest/TDIGESTCREATE_Test.php
@@ -59,6 +59,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider sketchesProvider
* @param array $createArguments
* @param string $key
diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTINFO_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTINFO_Test.php
index 86072cc29..121b2d23f 100644
--- a/tests/Predis/Command/Redis/TDigest/TDIGESTINFO_Test.php
+++ b/tests/Predis/Command/Redis/TDigest/TDIGESTINFO_Test.php
@@ -77,6 +77,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.4.0
*/
diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTMAX_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTMAX_Test.php
index 62b0a7a8e..9e9b7c20e 100644
--- a/tests/Predis/Command/Redis/TDigest/TDIGESTMAX_Test.php
+++ b/tests/Predis/Command/Redis/TDigest/TDIGESTMAX_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.4.0
*/
diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTMERGE_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTMERGE_Test.php
index b4d73071f..aa6cf45b1 100644
--- a/tests/Predis/Command/Redis/TDigest/TDIGESTMERGE_Test.php
+++ b/tests/Predis/Command/Redis/TDigest/TDIGESTMERGE_Test.php
@@ -51,6 +51,7 @@ public function testFilterArguments(array $actualArguments, array $expectedArgum
/**
* @group connected
+ * @group relay-resp3
* @dataProvider sketchesProvider
* @param string $sourceKey1
* @param string $sourceKey2
@@ -92,6 +93,7 @@ public function testMergeTwoSketchesIntoOneWithinGivenDestinationKey(
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.4.0
*/
@@ -118,6 +120,7 @@ public function testMergedSketchHaveCompressionEqualMaxValueAmongAllSourceSketch
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.4.0
*/
@@ -156,6 +159,7 @@ public function testMergeOverrideAlreadyExistingSketchWithOverrideModifier(): vo
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.4.0
*/
@@ -184,6 +188,7 @@ public function testMergeWithAlreadyExistingSketchIfNoOverrideModifierGiven(): v
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.4.0
*/
diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTMIN_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTMIN_Test.php
index c70629950..490508322 100644
--- a/tests/Predis/Command/Redis/TDigest/TDIGESTMIN_Test.php
+++ b/tests/Predis/Command/Redis/TDigest/TDIGESTMIN_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.4.0
*/
diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTQUANTILE_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTQUANTILE_Test.php
index b43cc5334..8a3622b3a 100644
--- a/tests/Predis/Command/Redis/TDigest/TDIGESTQUANTILE_Test.php
+++ b/tests/Predis/Command/Redis/TDigest/TDIGESTQUANTILE_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.4.0
*/
diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTRANK_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTRANK_Test.php
index b3e2502f6..3afb63e1b 100644
--- a/tests/Predis/Command/Redis/TDigest/TDIGESTRANK_Test.php
+++ b/tests/Predis/Command/Redis/TDigest/TDIGESTRANK_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.4.0
*/
diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTRESET_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTRESET_Test.php
index bc3ebe25f..5ad1f76b9 100644
--- a/tests/Predis/Command/Redis/TDigest/TDIGESTRESET_Test.php
+++ b/tests/Predis/Command/Redis/TDigest/TDIGESTRESET_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.4.0
*/
diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTREVRANK_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTREVRANK_Test.php
index 67b4799d2..370fb1b6e 100644
--- a/tests/Predis/Command/Redis/TDigest/TDIGESTREVRANK_Test.php
+++ b/tests/Predis/Command/Redis/TDigest/TDIGESTREVRANK_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.4.0
*/
diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTTRIMMED_MEAN_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTTRIMMED_MEAN_Test.php
index 15490426b..001e07c92 100644
--- a/tests/Predis/Command/Redis/TDigest/TDIGESTTRIMMED_MEAN_Test.php
+++ b/tests/Predis/Command/Redis/TDigest/TDIGESTTRIMMED_MEAN_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider sketchesProvider
* @param array $addArguments
* @param string $key
@@ -102,6 +103,7 @@ public function testReturnsNanOnEmptySketchKey(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.4.0
*/
diff --git a/tests/Predis/Command/Redis/TimeSeries/TSADD_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSADD_Test.php
index a969e88e5..a59950499 100644
--- a/tests/Predis/Command/Redis/TimeSeries/TSADD_Test.php
+++ b/tests/Predis/Command/Redis/TimeSeries/TSADD_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/TimeSeries/TSALTER_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSALTER_Test.php
index 01f6fd3ee..9680448fc 100644
--- a/tests/Predis/Command/Redis/TimeSeries/TSALTER_Test.php
+++ b/tests/Predis/Command/Redis/TimeSeries/TSALTER_Test.php
@@ -62,6 +62,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/TimeSeries/TSCREATERULE_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSCREATERULE_Test.php
index 25a448f25..5119a51e7 100644
--- a/tests/Predis/Command/Redis/TimeSeries/TSCREATERULE_Test.php
+++ b/tests/Predis/Command/Redis/TimeSeries/TSCREATERULE_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
@@ -95,6 +96,7 @@ public function testThrowsExceptionOnNonExistingDestinationKey(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/TimeSeries/TSCREATE_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSCREATE_Test.php
index ef7c66ceb..3e2183c45 100644
--- a/tests/Predis/Command/Redis/TimeSeries/TSCREATE_Test.php
+++ b/tests/Predis/Command/Redis/TimeSeries/TSCREATE_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/TimeSeries/TSDECRBY_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSDECRBY_Test.php
index b2d7e2107..1dbc91bdb 100644
--- a/tests/Predis/Command/Redis/TimeSeries/TSDECRBY_Test.php
+++ b/tests/Predis/Command/Redis/TimeSeries/TSDECRBY_Test.php
@@ -63,6 +63,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
@@ -121,6 +122,7 @@ public function testDecrByCreateNewSampleIfNotExists(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
@@ -147,7 +149,6 @@ public function testThrowsExceptionOnOlderTimestampGiven(): void
);
$this->expectException(ServerException::class);
- $this->expectExceptionMessage('TSDB: for incrby/decrby, timestamp should be newer than the');
$redis->tsdecrby('temperature:2:32', 27, (new DecrByArguments())->timestamp(123123123122));
}
diff --git a/tests/Predis/Command/Redis/TimeSeries/TSDELETERULE_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSDELETERULE_Test.php
index ac5818943..eba727199 100644
--- a/tests/Predis/Command/Redis/TimeSeries/TSDELETERULE_Test.php
+++ b/tests/Predis/Command/Redis/TimeSeries/TSDELETERULE_Test.php
@@ -62,6 +62,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/TimeSeries/TSDEL_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSDEL_Test.php
index a9506eaba..744180595 100644
--- a/tests/Predis/Command/Redis/TimeSeries/TSDEL_Test.php
+++ b/tests/Predis/Command/Redis/TimeSeries/TSDEL_Test.php
@@ -63,6 +63,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.6.0
*/
diff --git a/tests/Predis/Command/Redis/TimeSeries/TSGET_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSGET_Test.php
index 4ab298dff..d429dd884 100644
--- a/tests/Predis/Command/Redis/TimeSeries/TSGET_Test.php
+++ b/tests/Predis/Command/Redis/TimeSeries/TSGET_Test.php
@@ -62,6 +62,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/TimeSeries/TSINCRBY_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSINCRBY_Test.php
index fbfceaca5..77ca7ff37 100644
--- a/tests/Predis/Command/Redis/TimeSeries/TSINCRBY_Test.php
+++ b/tests/Predis/Command/Redis/TimeSeries/TSINCRBY_Test.php
@@ -63,6 +63,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
@@ -121,6 +122,7 @@ public function testIncrByCreateNewSampleIfNotExists(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
@@ -147,7 +149,6 @@ public function testThrowsExceptionOnOlderTimestampGiven(): void
);
$this->expectException(ServerException::class);
- $this->expectExceptionMessage('TSDB: for incrby/decrby, timestamp should be newer than the');
$redis->tsincrby('temperature:2:32', 27, (new IncrByArguments())->timestamp(123123123122));
}
diff --git a/tests/Predis/Command/Redis/TimeSeries/TSINFO_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSINFO_Test.php
index 20566d532..c796eebf1 100644
--- a/tests/Predis/Command/Redis/TimeSeries/TSINFO_Test.php
+++ b/tests/Predis/Command/Redis/TimeSeries/TSINFO_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/TimeSeries/TSMADD_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSMADD_Test.php
index a9f8a11a7..860750ebe 100644
--- a/tests/Predis/Command/Redis/TimeSeries/TSMADD_Test.php
+++ b/tests/Predis/Command/Redis/TimeSeries/TSMADD_Test.php
@@ -63,6 +63,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
@@ -101,7 +102,6 @@ public function testThrowsExceptionOnNonWrongArgumentsNumber(): void
$redis = $this->getClient();
$this->expectException(ServerException::class);
- $this->expectExceptionMessage("ERR wrong number of arguments for 'TS.MADD' command");
$redis->tsmadd('temperature:2:32', 123123123123, 27, 'temperature:2:33', 123123123124);
}
diff --git a/tests/Predis/Command/Redis/TimeSeries/TSMGET_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSMGET_Test.php
index 74d5b9810..50f18ca63 100644
--- a/tests/Predis/Command/Redis/TimeSeries/TSMGET_Test.php
+++ b/tests/Predis/Command/Redis/TimeSeries/TSMGET_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/TimeSeries/TSMRANGE_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSMRANGE_Test.php
index cd7c126eb..cc13025a9 100644
--- a/tests/Predis/Command/Redis/TimeSeries/TSMRANGE_Test.php
+++ b/tests/Predis/Command/Redis/TimeSeries/TSMRANGE_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/TimeSeries/TSMREVRANGE_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSMREVRANGE_Test.php
index 8d5a9adb9..5bfab8a9c 100644
--- a/tests/Predis/Command/Redis/TimeSeries/TSMREVRANGE_Test.php
+++ b/tests/Predis/Command/Redis/TimeSeries/TSMREVRANGE_Test.php
@@ -60,6 +60,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.4.0
*/
diff --git a/tests/Predis/Command/Redis/TimeSeries/TSQUERYINDEX_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSQUERYINDEX_Test.php
index 0630300c8..0c75f93b5 100644
--- a/tests/Predis/Command/Redis/TimeSeries/TSQUERYINDEX_Test.php
+++ b/tests/Predis/Command/Redis/TimeSeries/TSQUERYINDEX_Test.php
@@ -54,6 +54,7 @@ public function testFilterArguments(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/TimeSeries/TSRANGE_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSRANGE_Test.php
index b4c7b0df3..56caaa092 100644
--- a/tests/Predis/Command/Redis/TimeSeries/TSRANGE_Test.php
+++ b/tests/Predis/Command/Redis/TimeSeries/TSRANGE_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/TimeSeries/TSREVRANGE_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSREVRANGE_Test.php
index 1615f5c61..004615bcf 100644
--- a/tests/Predis/Command/Redis/TimeSeries/TSREVRANGE_Test.php
+++ b/tests/Predis/Command/Redis/TimeSeries/TSREVRANGE_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
*/
diff --git a/tests/Predis/Command/Redis/TopK/TOPKADD_Test.php b/tests/Predis/Command/Redis/TopK/TOPKADD_Test.php
index 19dd7e03e..ac568f6da 100644
--- a/tests/Predis/Command/Redis/TopK/TOPKADD_Test.php
+++ b/tests/Predis/Command/Redis/TopK/TOPKADD_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider structuresProvider
* @param array $reserveArguments
* @param array $addArguments
diff --git a/tests/Predis/Command/Redis/TopK/TOPKINCRBY_Test.php b/tests/Predis/Command/Redis/TopK/TOPKINCRBY_Test.php
index 06f605f28..bdd06c85e 100644
--- a/tests/Predis/Command/Redis/TopK/TOPKINCRBY_Test.php
+++ b/tests/Predis/Command/Redis/TopK/TOPKINCRBY_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.0.0
*/
diff --git a/tests/Predis/Command/Redis/TopK/TOPKINFO_Test.php b/tests/Predis/Command/Redis/TopK/TOPKINFO_Test.php
index 2a0ca4c9b..6d7d2a055 100644
--- a/tests/Predis/Command/Redis/TopK/TOPKINFO_Test.php
+++ b/tests/Predis/Command/Redis/TopK/TOPKINFO_Test.php
@@ -64,6 +64,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.0.0
*/
@@ -73,9 +74,10 @@ public function testReturnsInfoAboutGivenTopKStructure(): void
$redis->topkreserve('key', 50);
- $this->assertEquals(
+ $this->assertSameWithPrecision(
['k' => 50, 'width' => 8, 'depth' => 7, 'decay' => '0.90000000000000002'],
- $redis->topkinfo('key')
+ $redis->topkinfo('key'),
+ 1
);
}
diff --git a/tests/Predis/Command/Redis/TopK/TOPKLIST_Test.php b/tests/Predis/Command/Redis/TopK/TOPKLIST_Test.php
index 795a0de3e..e20f5cade 100644
--- a/tests/Predis/Command/Redis/TopK/TOPKLIST_Test.php
+++ b/tests/Predis/Command/Redis/TopK/TOPKLIST_Test.php
@@ -63,6 +63,7 @@ public function testParseResponse(array $arguments, array $actualResponse, array
/**
* @group connected
+ * @group relay-resp3
* @dataProvider structureProvider
* @param array $reserveArguments
* @param array $addArguments
diff --git a/tests/Predis/Command/Redis/TopK/TOPKQUERY_Test.php b/tests/Predis/Command/Redis/TopK/TOPKQUERY_Test.php
index 721150e07..779775866 100644
--- a/tests/Predis/Command/Redis/TopK/TOPKQUERY_Test.php
+++ b/tests/Predis/Command/Redis/TopK/TOPKQUERY_Test.php
@@ -61,6 +61,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @return void
* @requiresRedisBfVersion >= 2.0.0
*/
diff --git a/tests/Predis/Command/Redis/TopK/TOPKRESERVE_Test.php b/tests/Predis/Command/Redis/TopK/TOPKRESERVE_Test.php
index 08a978ee4..a8261de1b 100644
--- a/tests/Predis/Command/Redis/TopK/TOPKRESERVE_Test.php
+++ b/tests/Predis/Command/Redis/TopK/TOPKRESERVE_Test.php
@@ -59,6 +59,7 @@ public function testParseResponse(): void
/**
* @group connected
+ * @group relay-resp3
* @dataProvider structureProvider
* @param array $topKArguments
* @param string $key
@@ -77,7 +78,7 @@ public function testReserveInitializeTopKStructureWithGivenConfiguration(
$actualInfoResponse = $redis->topkinfo($key);
$this->assertEquals('OK', $actualResponse);
- $this->assertEquals($expectedInfoResponse, $actualInfoResponse);
+ $this->assertSameWithPrecision($expectedInfoResponse, $actualInfoResponse, 1);
}
/**
diff --git a/tests/Predis/Command/Redis/WAITAOF_Test.php b/tests/Predis/Command/Redis/WAITAOF_Test.php
new file mode 100644
index 000000000..8b0c074a5
--- /dev/null
+++ b/tests/Predis/Command/Redis/WAITAOF_Test.php
@@ -0,0 +1,80 @@
+getClient();
+ $this->assertEquals('OK', $redis->config('set', 'appendonly', 'yes'));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function getExpectedCommand(): string
+ {
+ return WAITAOF::class;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function getExpectedId(): string
+ {
+ return 'WAITAOF';
+ }
+
+ /**
+ * @group disconnected
+ */
+ public function testFilterArguments(): void
+ {
+ $actualArguments = $expectedArguments = [1, 2, 3];
+
+ $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 >= 7.2.0
+ */
+ public function testReturnQuantityOfSyncedAOFInstances(): void
+ {
+ $redis = $this->getClient();
+
+ $this->assertEquals('OK', $redis->set('foo', 'bar'));
+ $this->assertSame([1, 0], $redis->waitaof(1, 0, 0));
+ }
+
+ protected function tearDown(): void
+ {
+ $redis = $this->getClient();
+ $this->assertEquals('OK', $redis->config('set', 'appendonly', 'no'));
+ }
+}
diff --git a/tests/Predis/Connection/Cluster/RedisClusterTest.php b/tests/Predis/Connection/Cluster/RedisClusterTest.php
index cf021b2cc..7388bed3c 100644
--- a/tests/Predis/Connection/Cluster/RedisClusterTest.php
+++ b/tests/Predis/Connection/Cluster/RedisClusterTest.php
@@ -12,6 +12,7 @@
namespace Predis\Connection\Cluster;
+use Iterator;
use PHPUnit\Framework\MockObject\MockObject;
use Predis\Cluster;
use Predis\Command;
@@ -1212,11 +1213,12 @@ public function testFetchSlotsMapFromClusterWithClusterSlotsCommand(): void
/**
* @group disconnected
+ * @dataProvider onMovedResponsesDataProvider
*/
- public function testAskSlotMapToRedisClusterOnMovedResponseByDefault(): void
+ public function testAskSlotMapToRedisClusterOnMovedResponseByDefault(string $movedErrorMessage): void
{
$cmdGET = Command\RawCommand::create('GET', 'node:1001');
- $rspMOVED = new Response\Error('MOVED 1970 127.0.0.1:6380');
+ $rspMOVED = new Response\Error($movedErrorMessage);
$rspSlotsArray = [
[0, 8191, ['127.0.0.1', 6379]],
[8192, 16383, ['127.0.0.1', 6380]],
@@ -1261,6 +1263,20 @@ public function testAskSlotMapToRedisClusterOnMovedResponseByDefault(): void
$this->assertCount(2, $cluster);
}
+ /**
+ * @return Iterator
+ */
+ public function onMovedResponsesDataProvider(): Iterator
+ {
+ yield 'MOVED 1970 127.0.0.1:6380' => [
+ 'movedErrorMessage' => 'MOVED 1970 127.0.0.1:6380',
+ ];
+
+ yield 'MOVED 1970 127.0.0.1:6380 (relay exception details)' => [
+ 'movedErrorMessage' => 'MOVED 1970 127.0.0.1:6380 (relay exception details)',
+ ];
+ }
+
/**
* @group disconnected
*/
diff --git a/tests/Predis/Connection/FactoryTest.php b/tests/Predis/Connection/FactoryTest.php
index 4d98dd6f6..9d48bd533 100644
--- a/tests/Predis/Connection/FactoryTest.php
+++ b/tests/Predis/Connection/FactoryTest.php
@@ -12,6 +12,8 @@
namespace Predis\Connection;
+use Predis\Client;
+use Predis\Command\RawCommand;
use PredisTestCase;
use ReflectionObject;
use stdClass;
@@ -538,6 +540,27 @@ public function testDefineAndUndefineConnection(): void
$factory->create('test://127.0.0.1');
}
+ /**
+ * @group disconnected
+ * @return void
+ */
+ public function testSetClientNameAndVersionOnConnection(): void
+ {
+ $parameters = ['client_info' => true];
+
+ $factory = new Factory();
+ $connection = $factory->create($parameters);
+ $initCommands = $connection->getInitCommands();
+
+ $this->assertInstanceOf(RawCommand::class, $initCommands[0]);
+ $this->assertSame('CLIENT', $initCommands[0]->getId());
+ $this->assertSame(['SETINFO', 'LIB-NAME', 'predis'], $initCommands[0]->getArguments());
+
+ $this->assertInstanceOf(RawCommand::class, $initCommands[1]);
+ $this->assertSame('CLIENT', $initCommands[1]->getId());
+ $this->assertSame(['SETINFO', 'LIB-VER', Client::VERSION], $initCommands[1]->getArguments());
+ }
+
// ******************************************************************** //
// ---- HELPER METHODS ------------------------------------------------ //
// ******************************************************************** //
diff --git a/tests/Predis/Connection/RelayConnectionTest.php b/tests/Predis/Connection/RelayConnectionTest.php
index 11bc72e33..895fb78ea 100644
--- a/tests/Predis/Connection/RelayConnectionTest.php
+++ b/tests/Predis/Connection/RelayConnectionTest.php
@@ -13,8 +13,13 @@
namespace Predis\Connection;
use PHPUnit\Framework\MockObject\MockObject;
+use Predis\ClientException;
use Predis\Command\RawCommand;
use Predis\Response\Error as ErrorResponse;
+use Predis\Response\ErrorInterface as ErrorResponseInterface;
+use ReflectionClass;
+use Relay\Exception as RelayException;
+use Relay\Relay;
/**
* @group ext-relay
@@ -59,6 +64,141 @@ public function testThrowsExceptionOnInitializationCommandFailure(): void
$connection->connect();
}
+ /**
+ * @group connected
+ */
+ public function testGetIdentifierUsesParentGetIdentifier(): void
+ {
+ $relayMock = $this
+ ->getMockBuilder(Relay::class)
+ ->onlyMethods(['endpointId'])
+ ->getMock();
+
+ $relayMock->method('endpointId')
+ ->willThrowException(
+ new RelayException('Not Connected')
+ );
+
+ /** @var RelayConnection&MockObject $connection */
+ $connection = $this
+ ->getMockBuilder($this->getConnectionClass())
+ ->onlyMethods(['createResource'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $reflection = new ReflectionClass($connection);
+ $propertyClient = $reflection->getProperty('client');
+ $propertyClient->setAccessible(true);
+ $propertyClient->setValue($connection, $relayMock);
+ $propertyParameters = $reflection->getProperty('parameters');
+ $propertyParameters->setAccessible(true);
+ $propertyParameters->setValue($connection, new Parameters([
+ 'host' => '127.0.0.1',
+ 'port' => 6379,
+ ]));
+
+ $this->assertEquals('127.0.0.1:6379', $connection->getIdentifier());
+ }
+
+ /**
+ * @group connected
+ */
+ public function testGetIdentifierUsesClientEndpointId(): void
+ {
+ $relayMock = $this
+ ->getMockBuilder(Relay::class)
+ ->onlyMethods(['endpointId'])
+ ->getMock();
+
+ $relayMock->method('endpointId')
+ ->willReturn('127.0.0.1:6379');
+
+ /** @var RelayConnection&MockObject $connection */
+ $connection = $this
+ ->getMockBuilder($this->getConnectionClass())
+ ->onlyMethods(['createResource'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $reflection = new ReflectionClass($connection);
+ $propertyClient = $reflection->getProperty('client');
+ $propertyClient->setAccessible(true);
+ $propertyClient->setValue($connection, $relayMock);
+
+ $this->assertEquals('127.0.0.1:6379', $connection->getIdentifier());
+ }
+
+ /**
+ * @group connected
+ */
+ public function testExecuteCommandReturnsErrorResponseWhenItIsThrownByRelay(): void
+ {
+ $cmdSelect = RawCommand::create('GET', '1');
+
+ $relayMock = $this
+ ->getMockBuilder(Relay::class)
+ ->onlyMethods(['rawCommand'])
+ ->getMock();
+
+ $relayMock->method('rawCommand')
+ ->willThrowException(
+ new RelayException('RELAY_ERR_REDIS')
+ );
+
+ /** @var RelayConnection&MockObject $connection */
+ $connection = $this
+ ->getMockBuilder($this->getConnectionClass())
+ ->onlyMethods(['createResource', 'createClient'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $reflection = new ReflectionClass($connection);
+ $property = $reflection->getProperty('client');
+ $property->setAccessible(true);
+ $property->setValue($connection, $relayMock);
+
+ $connection->method('createResource');
+
+ $response = $connection->executeCommand($cmdSelect);
+
+ $this->assertInstanceOf(ErrorResponseInterface::class, $response);
+ }
+
+ /**
+ * @group connected
+ */
+ public function testExecuteCommandThrowsExceptionWhenThrownByRelayAndItIsNotErrorResponse(): void
+ {
+ $this->expectException('Predis\ClientException');
+ $cmdSelect = RawCommand::create('GET', '1');
+
+ $relayMock = $this
+ ->getMockBuilder(Relay::class)
+ ->onlyMethods(['rawCommand'])
+ ->getMock();
+
+ $relayMock->method('rawCommand')
+ ->willThrowException(
+ new ClientException('RELAY_ERR_REDIS')
+ );
+
+ /** @var RelayConnection&MockObject $connection */
+ $connection = $this
+ ->getMockBuilder($this->getConnectionClass())
+ ->onlyMethods(['createResource', 'createClient'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $reflection = new ReflectionClass($connection);
+ $property = $reflection->getProperty('client');
+ $property->setAccessible(true);
+ $property->setValue($connection, $relayMock);
+
+ $connection->method('createResource');
+
+ $connection->executeCommand($cmdSelect);
+ }
+
// ******************************************************************** //
// ---- INTEGRATION TESTS --------------------------------------------- //
// ******************************************************************** //
diff --git a/tests/Predis/Connection/StreamConnectionTest.php b/tests/Predis/Connection/StreamConnectionTest.php
index 55c30c082..cd38b4086 100644
--- a/tests/Predis/Connection/StreamConnectionTest.php
+++ b/tests/Predis/Connection/StreamConnectionTest.php
@@ -13,6 +13,7 @@
namespace Predis\Connection;
use PHPUnit\Framework\MockObject\MockObject;
+use Predis\Client;
use Predis\Command\RawCommand;
use Predis\Response\Error as ErrorResponse;
@@ -195,4 +196,22 @@ public function testTcpDelayContextFlagIsNotSetByDefault()
$this->assertArrayHasKey('tcp_nodelay', $options['socket']);
$this->assertFalse($options['socket']['tcp_nodelay']);
}
+
+ /**
+ * @group connected
+ * @requiresRedisVersion < 7.0.0
+ */
+ public function testConnectDoNotThrowsExceptionOnClientCommandError(): void
+ {
+ $connection = $this->createConnectionWithParams([]);
+ $connection->addConnectCommand(
+ new RawCommand('CLIENT', ['SETINFO', 'LIB-NAME', 'predis'])
+ );
+ $connection->addConnectCommand(
+ new RawCommand('CLIENT', ['SETINFO', 'LIB-VER', Client::VERSION])
+ );
+
+ $connection->connect();
+ $this->assertTrue(true);
+ }
}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 1e21c3579..be3b405ad 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -20,6 +20,7 @@
require __DIR__ . '/PHPUnit/ArrayHasSameValuesConstraint.php';
require __DIR__ . '/PHPUnit/OneOfConstraint.php';
+require __DIR__ . '/PHPUnit/AssertSameWithPrecisionConstraint.php';
require __DIR__ . '/PHPUnit/RedisCommandConstraint.php';
require __DIR__ . '/PHPUnit/PredisTestCase.php';
require __DIR__ . '/PHPUnit/PredisCommandTestCase.php';