Skip to content

Commit

Permalink
Fix Predis\Commands\ServerEvalSHA::getScriptHash().
Browse files Browse the repository at this point in the history
"Predis\Commands\ServerEvalSHA::getScriptHash()" was calculating the hash
while it just needs to return the first argument of the command.
  • Loading branch information
nrk committed Apr 27, 2012
1 parent 6ba1890 commit b67dab9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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)
===============================================================================
Expand Down
10 changes: 10 additions & 0 deletions lib/Predis/Commands/ServerEvalSHA.php
Expand Up @@ -24,4 +24,14 @@ public function getId()
{
return 'EVALSHA';
}

/**
* Returns the SHA1 hash of the body of the script.
*
* @return string SHA1 hash.
*/
public function getScriptHash()
{
return $this->getArgument(0);
}
}
9 changes: 9 additions & 0 deletions tests/Predis/Commands/ServerEvalSHATest.php
Expand Up @@ -75,6 +75,15 @@ public function testPrefixKeys()
$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
*/
Expand Down

0 comments on commit b67dab9

Please sign in to comment.