From 3befbb3ac2c9a70489906bd047fddf053a1ffba0 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Sun, 22 Dec 2013 13:40:36 +0100 Subject: [PATCH] Make Pipeline::executeCommand() return $this for fluent interface. --- lib/Predis/Pipeline/Pipeline.php | 5 ++++- tests/Predis/Pipeline/PipelineTest.php | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/Predis/Pipeline/Pipeline.php b/lib/Predis/Pipeline/Pipeline.php index 0f2e569b..f5105107 100644 --- a/lib/Predis/Pipeline/Pipeline.php +++ b/lib/Predis/Pipeline/Pipeline.php @@ -76,11 +76,14 @@ class Pipeline implements BasicClientInterface, ExecutableContextInterface /** * Queues a command instance into the pipeline buffer. * - * @param CommandInterface $command Command to be queued in the buffer. + * @param CommandInterface $command Command instance to be queued in the buffer. + * @return self */ public function executeCommand(CommandInterface $command) { $this->recordCommand($command); + + return $this; } /** diff --git a/tests/Predis/Pipeline/PipelineTest.php b/tests/Predis/Pipeline/PipelineTest.php index d4bec351..8ea68e2c 100644 --- a/tests/Predis/Pipeline/PipelineTest.php +++ b/tests/Predis/Pipeline/PipelineTest.php @@ -129,6 +129,19 @@ class PipelineTest extends PredisTestCase $this->assertSame(array($error, $error), $pipeline->execute()); } + /** + * @group disconnected + */ + public function testExecuteReturnsPipelineForFluentInterface() + { + $profile = Profile\Factory::getDefault(); + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $pipeline = new Pipeline(new Client($connection)); + $command = $profile->createCommand('echo', array('one')); + + $this->assertSame($pipeline, $pipeline->executeCommand($command)); + } + /** * @group disconnected */