mirror of
https://github.com/predis/predis.git
synced 2026-08-25 22:09:40 +00:00
a9de0bba0e
* 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 examples * Added test group --------- 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>
89 lines
2.4 KiB
PHP
89 lines
2.4 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\Container;
|
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
|
use PHPUnit\Framework\TestCase;
|
|
use Predis\ClientInterface;
|
|
use Predis\Command\Container\Search\FTCONFIG;
|
|
use UnexpectedValueException;
|
|
|
|
class ContainerFactoryTest extends TestCase
|
|
{
|
|
/**
|
|
* @var MockObject|ClientInterface
|
|
*/
|
|
private $mockClient;
|
|
|
|
/**
|
|
* @var ContainerFactory
|
|
*/
|
|
private $factory;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->mockClient = $this->getMockBuilder(ClientInterface::class)->getMock();
|
|
$this->factory = new ContainerFactory();
|
|
}
|
|
|
|
/**
|
|
* @dataProvider containerProvider
|
|
* @param string $containerCommandId
|
|
* @param string $expectedContainerClass
|
|
* @return void
|
|
*/
|
|
public function testCreatesReturnsExistingCommandContainerClass(
|
|
string $containerCommandId,
|
|
string $expectedContainerClass
|
|
): void {
|
|
$expectedContainer = new $expectedContainerClass($this->mockClient);
|
|
|
|
$this->assertEquals(
|
|
$expectedContainer,
|
|
$this->factory::create($this->mockClient, $containerCommandId)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @dataProvider unexpectedValuesProvider
|
|
* @param string $containerCommandId
|
|
* @param string $expectedExceptionMessage
|
|
* @return void
|
|
*/
|
|
public function testThrowsExceptionOnNonExistingCommand(
|
|
string $containerCommandId,
|
|
string $expectedExceptionMessage
|
|
): void {
|
|
$this->expectException(UnexpectedValueException::class);
|
|
$this->expectExceptionMessage($expectedExceptionMessage);
|
|
|
|
$this->factory::create($this->mockClient, $containerCommandId);
|
|
}
|
|
|
|
public function containerProvider(): array
|
|
{
|
|
return [
|
|
'core command' => ['function', FUNCTIONS::class],
|
|
'module command' => ['ftconfig', FTCONFIG::class],
|
|
];
|
|
}
|
|
|
|
public function unexpectedValuesProvider(): array
|
|
{
|
|
return [
|
|
'not supported module container command' => ['ftfoobar', 'Given module container command is not supported.'],
|
|
'not supported core container command' => ['foobar', 'Given container command is not supported.'],
|
|
];
|
|
}
|
|
}
|