diff --git a/src/ClientContextInterface.php b/src/ClientContextInterface.php index 1d49b2f7..0f1f4074 100644 --- a/src/ClientContextInterface.php +++ b/src/ClientContextInterface.php @@ -93,6 +93,7 @@ use Predis\Command\Redis\Container\FUNCTIONS; * @method $this ftcreate(string $index, Schema $schema, ?CreateArguments $arguments = null) * @method $this ftdictadd(string $dict, ...$term) * @method $this ftdictdel(string $dict, ...$term) + * @method $this ftdictdump(string $dict) * @method $this ftinfo(string $index) * @method $this ftsearch(string $index, string $query, ?SearchArguments $arguments = null) * @method $this get($key) diff --git a/src/ClientInterface.php b/src/ClientInterface.php index 2c4e29bf..6d4b0ef0 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -102,6 +102,7 @@ use Predis\Response\Status; * @method Status ftcreate(string $index, Schema $schema, ?CreateArguments $arguments = null) * @method int ftdictadd(string $dict, ...$term) * @method int ftdictdel(string $dict, ...$term) + * @method array ftdictdump(string $dict) * @method array ftinfo(string $index) * @method array ftsearch(string $index, string $query, ?SearchArguments $arguments = null) * @method string|null get(string $key) diff --git a/src/Command/Redis/Search/FTDICTDUMP.php b/src/Command/Redis/Search/FTDICTDUMP.php new file mode 100644 index 00000000..b8282b56 --- /dev/null +++ b/src/Command/Redis/Search/FTDICTDUMP.php @@ -0,0 +1,28 @@ +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 + * @requiresRediSearchVersion >= 1.4.0 + */ + public function testDumpTermsFromGivenDictionary(): void + { + $redis = $this->getClient(); + + $redis->ftdictadd('dict', 'foo', 'bar'); + + $this->assertSame(['bar', 'foo'], $redis->ftdictdump('dict')); + } + + /** + * @group connected + * @return void + * @requiresRediSearchVersion >= 1.4.0 + */ + public function testThrowsExceptionOnNonExistingDictionary(): void + { + $redis = $this->getClient(); + + $this->expectException(ServerException::class); + $this->expectExceptionMessage('could not open dict key'); + + $redis->ftdictdump('dict'); + } +}