mirror of
https://github.com/predis/predis.git
synced 2026-08-25 15:09:38 +00:00
980326d5d8
* Initial work on retries * Added retry class and test coverage * Added support for standalone and cluster * Make TimeoutException instance of CommunicationException * Added pipeline, trasnaction, replication support * Fixed broken test * Marked test as relay-incompatible * Marked test as relay-incompatible * Fixed analysis errors, added missing tests * Codestyle fixes * Fixed test * Update README.md * Update README.md * Update README.md * Updated README.md * Refactor retry on read and write * Added check for timeout value * Updated README.md * Fixed README.md * Codestyle changes * Added missing coverage * Added missing test coverage * Removed comments * Added retry support for Relay connection (#1620) * Added integration test case with mocked retry * Changed client initialisation in tests * Marked test as relay-incompatible --------- Co-authored-by: Pavlo Yatsukhnenko <yatsukhnenko@users.noreply.github.com>
60 lines
1.5 KiB
PHP
60 lines
1.5 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\Transaction\Strategy;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Predis\Command\CommandInterface;
|
|
use Predis\Connection\Parameters;
|
|
use Predis\Connection\Replication\ReplicationInterface;
|
|
use Predis\Transaction\MultiExecState;
|
|
|
|
class ReplicationConnectionStrategyTest extends TestCase
|
|
{
|
|
/**
|
|
* @var ReplicationInterface
|
|
*/
|
|
private $mockConnection;
|
|
|
|
/**
|
|
* @var CommandInterface
|
|
*/
|
|
private $mockCommand;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->mockConnection = $this->getMockBuilder(ReplicationInterface::class)->getMock();
|
|
$this->mockCommand = $this->getMockBuilder(CommandInterface::class)->getMock();
|
|
}
|
|
|
|
/**
|
|
* @return void
|
|
*/
|
|
public function testExecuteCommand(): void
|
|
{
|
|
$this->mockConnection
|
|
->expects($this->once())
|
|
->method('executeCommand')
|
|
->with($this->mockCommand)
|
|
->willReturn('OK');
|
|
|
|
$this->mockConnection
|
|
->expects($this->any())
|
|
->method('getParameters')
|
|
->willReturn(new Parameters());
|
|
|
|
$strategy = new ReplicationConnectionStrategy($this->mockConnection, new MultiExecState());
|
|
|
|
$this->assertEquals('OK', $strategy->executeCommand($this->mockCommand));
|
|
}
|
|
}
|