瀏覽代碼

Make sure raw commands IDs are normalized to uppercase.

Daniele Alessandri 11 年之前
父節點
當前提交
6ef8e99822
共有 2 個文件被更改,包括 11 次插入1 次删除
  1. 1 1
      lib/Predis/Command/RawCommand.php
  2. 10 0
      tests/Predis/Command/RawCommandTest.php

+ 1 - 1
lib/Predis/Command/RawCommand.php

@@ -35,7 +35,7 @@ class RawCommand implements CommandInterface
             throw new InvalidArgumentException("Arguments array is missing the command ID");
         }
 
-        $this->commandID = array_shift($arguments);
+        $this->commandID = strtoupper(array_shift($arguments));
         $this->arguments = $arguments;
     }
 

+ 10 - 0
tests/Predis/Command/RawCommandTest.php

@@ -126,6 +126,16 @@ class RawCommandTest extends PredisTestCase
         $this->assertNull($command->getHash());
     }
 
+    /**
+     * @group disconnected
+     */
+    public function testNormalizesCommandIdentifiersToUppercase()
+    {
+        $command = new RawCommand(array('set', 'key', 'value'));
+
+        $this->assertSame('SET', $command->getId());
+    }
+
     /**
      * @group disconnected
      */