Browse Source

Merge pull request #43 from juriansluiman/feature-uppercase

Now Predis follows the same standard behaviour of PHP (method names are treated
case-insensitively) when invoking methods related to Redis commands, (i.e.
$client->info() or $client->INFO() makes no difference).
Daniele Alessandri 13 years ago
parent
commit
f7d9c4bac7
2 changed files with 12 additions and 0 deletions
  1. 2 0
      lib/Predis/Profiles/ServerProfile.php
  2. 10 0
      test/RedisCommandsTest.php

+ 2 - 0
lib/Predis/Profiles/ServerProfile.php

@@ -70,10 +70,12 @@ abstract class ServerProfile implements IServerProfile, IProcessingSupport {
     }
 
     public function supportsCommand($command) {
+        $command = strtolower($command);
         return isset($this->_registeredCommands[$command]);
     }
 
     public function createCommand($method, $arguments = array()) {
+        $method = strtolower($method);
         if (!isset($this->_registeredCommands[$method])) {
             throw new ClientException("'$method' is not a registered Redis command");
         }

+ 10 - 0
test/RedisCommandsTest.php

@@ -2075,5 +2075,15 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
     function testLastSave() {
         $this->assertGreaterThan(0, $this->redis->lastsave());
     }
+
+    function testUppercaseCommands() {
+        $uppercase = $this->redis->getProfile()->supportsCommand('INFO');
+        $lowercase = $this->redis->getProfile()->supportsCommand('info');
+        $this->assertEquals($uppercase, $lowercase);
+
+        $uppercase = $this->redis->getProfile()->createCommand('INFO');
+        $lowercase = $this->redis->getProfile()->createCommand('info');
+        $this->assertEquals($uppercase, $lowercase);
+    }
 }
 ?>