mirror of
https://github.com/predis/predis.git
synced 2026-08-26 19:59:58 +00:00
c60003a717
* Marked missing commands as Prefixable * Codestyle fixes * Updated CHANGELOG.md
108 lines
2.4 KiB
PHP
108 lines
2.4 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Predis package.
|
|
*
|
|
* (c) 2009-2020 Daniele Alessandri
|
|
* (c) 2021-2025 Till Krüss
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Predis\Command\Redis\Search;
|
|
|
|
use Predis\Command\PrefixableCommand;
|
|
use Predis\Command\Redis\PredisCommandTestCase;
|
|
|
|
/**
|
|
* @group commands
|
|
* @group realm-stack
|
|
*/
|
|
class FTDICTADD_Test extends PredisCommandTestCase
|
|
{
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
protected function getExpectedCommand(): string
|
|
{
|
|
return FTDICTADD::class;
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
protected function getExpectedId(): string
|
|
{
|
|
return 'FTDICTADD';
|
|
}
|
|
|
|
/**
|
|
* @group disconnected
|
|
*/
|
|
public function testFilterArguments(): void
|
|
{
|
|
$actualArguments = ['dict', 'foo', 'bar'];
|
|
$expectedArguments = ['dict', 'foo', 'bar'];
|
|
|
|
$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 disconnected
|
|
*/
|
|
public function testPrefixKeys(): void
|
|
{
|
|
/** @var PrefixableCommand $command */
|
|
$command = $this->getCommand();
|
|
$actualArguments = ['arg1'];
|
|
$prefix = 'prefix:';
|
|
$expectedArguments = ['prefix:arg1'];
|
|
|
|
$command->setArguments($actualArguments);
|
|
$command->prefixKeys($prefix);
|
|
|
|
$this->assertSame($expectedArguments, $command->getArguments());
|
|
}
|
|
|
|
/**
|
|
* @group connected
|
|
* @group relay-resp3
|
|
* @return void
|
|
* @requiresRediSearchVersion >= 1.4.0
|
|
*/
|
|
public function testAddTermsIntoGivenDictionary(): void
|
|
{
|
|
$redis = $this->getClient();
|
|
|
|
$actualResponse = $redis->ftdictadd('dict', 'foo', 'bar');
|
|
|
|
$this->assertSame(2, $actualResponse);
|
|
}
|
|
|
|
/**
|
|
* @group connected
|
|
* @return void
|
|
* @requiresRediSearchVersion >= 2.8.0
|
|
*/
|
|
public function testAddTermsIntoGivenDictionaryResp3(): void
|
|
{
|
|
$redis = $this->getResp3Client();
|
|
|
|
$actualResponse = $redis->ftdictadd('dict', 'foo', 'bar');
|
|
|
|
$this->assertSame(2, $actualResponse);
|
|
}
|
|
}
|