Files
predis/tests/Predis/Command/Redis/Search/FTCONFIG_Test.php
T
Vladyslav Vildanov de8147a0d3 Extended RediSearch support by implementing FT.CONFIG HELP command (#1174)
* Added support for new arguments for BITPOS, BITCOUNT commands (#1045)

* Added support for new arguments for EXPIRE, EXPIREAT commands (#1046)

* add support for CF.ADDNX

* Extended core support by implementing SORT_RO command (#1044)

* Added support for SORT_RO command

* Codestyle fixes

* Added command description

---------

Co-authored-by: Vladyslav Vildanov <vladyslavvildanov@Vladyslav-Vildanov-MacBook-Pro.local>

* fix deprecated call

* fix key name

* fix wrong command

* Added support for container commands (#1049)

* Added support for container commands FUNCTION LOAD, FUNCTION DELETE and FCALL

* Changed ContainerInterface and AbstractContainer

* Re-implement logic of abstract methods

---------

Co-authored-by: Vladyslav Vildanov <vladyslavvildanov@Vladyslav-Vildanov-MacBook-Pro.local>

* Added stream commands to KeyPrefixProcessor (#1051)

Co-authored-by: Vladyslav Vildanov <vladyslavvildanov@Vladyslav-Vildanov-MacBook-Pro.local>

* Pulling changes

* Fix return type of ReplicationInterface::getSlaves (#1111)

* Added support for FT.CREATE command

* Fixed tests to choose correct DB

* Added test coverage

* Revert changes for missing commands

* Added data types enums, added methods default assignments

* Fixed vector field, removed default assignments, fixed tests

* Added constants enum for Sortable argument, renamed arguments object

* Codestyle fixes

* Rename test class

* Codestyle fixes

* Changed return annotation

* Separate common and create interfaces

* Codestyle fixes

* Added support for FT.CONFIG SET, FT.CONFIG GET commands

* Revert changes

* Added support for FT.CONFIG HELP command

* Revert interface changes for bitcount command

---------

Co-authored-by: shacharPash <shachar.pashchur@redis.com>
Co-authored-by: Vladyslav Vildanov <vladyslavvildanov@Vladyslav-Vildanov-MacBook-Pro.local>
Co-authored-by: Till Krüss <till@kruss.io>
Co-authored-by: Stephan <glaubinix@users.noreply.github.com>
2023-02-28 12:02:37 +02:00

152 lines
3.6 KiB
PHP

<?php
/*
* This file is part of the Predis package.
*
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Predis\Command\Redis\Search;
use Predis\Command\Redis\PredisCommandTestCase;
use Predis\Response\ServerException;
/**
* @group commands
* @group realm-stack
*/
class FTCONFIG_Test extends PredisCommandTestCase
{
/**
* {@inheritDoc}
*/
protected function getExpectedCommand(): string
{
return FTCONFIG::class;
}
/**
* {@inheritDoc}
*/
protected function getExpectedId(): string
{
return 'FTCONFIG';
}
/**
* @group disconnected
*/
public function testGetFilterArguments(): void
{
$arguments = ['GET', 'option'];
$expected = ['GET', 'option'];
$command = $this->getCommand();
$command->setArguments($arguments);
$this->assertSameValues($expected, $command->getArguments());
}
/**
* @group disconnected
*/
public function testHelpFilterArguments(): void
{
$arguments = ['HELP', 'option'];
$expected = ['HELP', 'option'];
$command = $this->getCommand();
$command->setArguments($arguments);
$this->assertSameValues($expected, $command->getArguments());
}
/**
* @group disconnected
*/
public function testSetFilterArguments(): void
{
$arguments = ['SET', 'option', 'value'];
$expected = ['SET', 'option', 'value'];
$command = $this->getCommand();
$command->setArguments($arguments);
$this->assertSameValues($expected, $command->getArguments());
}
/**
* @group disconnected
*/
public function testParseResponse(): void
{
$this->assertSame(1, $this->getCommand()->parseResponse(1));
}
/**
* @group connected
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
public function testSetGivenRediSearchConfigurationParameter(): void
{
$redis = $this->getClient();
$this->assertEquals('OK', $redis->ftconfig->set('TIMEOUT', 42));
}
/**
* @group connected
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
public function testGetReturnsGivenRediSearchConfigurationParameter(): void
{
$redis = $this->getClient();
$this->assertEquals([['MAXEXPANSIONS', '200']], $redis->ftconfig->get('MAXEXPANSIONS'));
$this->assertEmpty($redis->ftconfig->get('foobar'));
}
/**
* @group connected
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
public function testHelpReturnsGivenRediSearchConfigurationDescription(): void
{
$redis = $this->getClient();
$expectedResponse = [
[
'MAXEXPANSIONS',
'Description',
'Maximum prefix expansions to be used in a query',
'Value',
'200',
],
];
$this->assertEquals($expectedResponse, $redis->ftconfig->help('MAXEXPANSIONS'));
$this->assertEmpty($redis->ftconfig->help('foobar'));
}
/**
* @group connected
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
public function testSetThrowsExceptionOnNonExistingOption(): void
{
$redis = $this->getClient();
$this->expectException(ServerException::class);
$this->expectExceptionMessage('Invalid option');
$redis->ftconfig->set('foobar', 'value');
}
}