From b67dab9ab1bb1dffdca74ecd501a2aa062c25ae1 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Sat, 28 Apr 2012 01:25:17 +0200 Subject: [PATCH] Fix Predis\Commands\ServerEvalSHA::getScriptHash(). "Predis\Commands\ServerEvalSHA::getScriptHash()" was calculating the hash while it just needs to return the first argument of the command. --- CHANGELOG.md | 2 ++ lib/Predis/Commands/ServerEvalSHA.php | 10 ++++++++++ tests/Predis/Commands/ServerEvalSHATest.php | 9 +++++++++ 3 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eaddf88..3cc9fc1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ v0.7.3 (2012-xx-xx) This bug is limited to the above mentioned example and does not affect the classes implemented in the `Predis\Distribution` namespace. +- __FIX__: `Predis\Commands\ServerEvalSHA::getScriptHash()` was calculating the + hash while it just needs to return the first argument of the command. v0.7.2 (2012-04-01) =============================================================================== diff --git a/lib/Predis/Commands/ServerEvalSHA.php b/lib/Predis/Commands/ServerEvalSHA.php index 2e546fea..3151c647 100644 --- a/lib/Predis/Commands/ServerEvalSHA.php +++ b/lib/Predis/Commands/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); + } } diff --git a/tests/Predis/Commands/ServerEvalSHATest.php b/tests/Predis/Commands/ServerEvalSHATest.php index fdc2080d..7015c909 100644 --- a/tests/Predis/Commands/ServerEvalSHATest.php +++ b/tests/Predis/Commands/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 */