Эх сурвалжийг харах

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

Backported from 3befbb3 (master).
Daniele Alessandri 11 жил өмнө
parent
commit
e778baa491

+ 4 - 1
lib/Predis/Pipeline/PipelineContext.php

@@ -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;
     }
 
     /**

+ 14 - 0
tests/Predis/Pipeline/PipelineContextTest.php

@@ -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
      */