Selaa lähdekoodia

Fix Predis\Command\ServerEvalSHA::getScriptHash().

"Predis\Command\ServerEvalSHA::getScriptHash()" was calculating the hash
while it just needs to return the first argument of the command.
Daniele Alessandri 13 vuotta sitten
vanhempi
commit
75afe831b0

+ 10 - 0
lib/Predis/Command/ServerEvalSHA.php

@@ -24,4 +24,14 @@ class ServerEvalSHA extends ServerEval
     {
         return 'EVALSHA';
     }
+
+    /**
+     * Returns the SHA1 hash of the body of the script.
+     *
+     * @return string SHA1 hash.
+     */
+    public function getScriptHash()
+    {
+        return $this->getArgument(0);
+    }
 }

+ 9 - 0
tests/Predis/Command/ServerEvalSHATest.php

@@ -75,6 +75,15 @@ class ServerEvalSHATest extends CommandTestCase
         $this->assertSame($expected, $command->getArguments());
     }
 
+    /**
+     * @group disconnected
+     */
+    public function testGetScriptHash()
+    {
+        $command = $this->getCommandWithArgumentsArray(array($sha1 = sha1('return true')), 0);
+        $this->assertSame($sha1, $command->getScriptHash());
+    }
+
     /**
      * @group connected
      */