Make Pipeline::executeCommand() return $this for fluent interface.

Backported from 3befbb3 (master).
This commit is contained in:
Daniele Alessandri
2013-12-22 16:45:07 +01:00
parent d88a280977
commit e778baa491
2 changed files with 18 additions and 1 deletions
+4 -1
View File
@@ -90,11 +90,14 @@ class PipelineContext implements BasicClientInterface, ExecutableContextInterfac
/**
* Queues a command instance into the pipeline buffer.
*
* @param CommandInterface $command Command to queue in the buffer.
* @param CommandInterface $command Command to queue in the buffer.
* @return $this
*/
public function executeCommand(CommandInterface $command)
{
$this->recordCommand($command);
return $this;
}
/**
@@ -74,6 +74,20 @@ class PipelineContextTest extends PredisTestCase
$this->assertSame($pipeline, $pipeline->echo('one')->echo('two')->echo('three'));
}
/**
* @group disconnected
*/
public function testExecuteReturnsPipelineForFluentInterface()
{
$profile = ServerProfile::getDefault();
$connection = $this->getMock('Predis\Connection\SingleConnectionInterface');
$pipeline = new PipelineContext(new Client($connection));
$command = $profile->createCommand('echo', array('one'));
$this->assertSame($pipeline, $pipeline->executeCommand($command));
}
/**
* @group disconnected
*/