ソースを参照

Do not parse response to SETNX into boolean value.

Daniele Alessandri 9 年 前
コミット
8c76bd6761

+ 0 - 8
src/Command/StringSetPreserve.php

@@ -24,12 +24,4 @@ class StringSetPreserve extends Command
     {
         return 'SETNX';
     }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function parseResponse($data)
-    {
-        return (bool) $data;
-    }
 }

+ 4 - 3
tests/Predis/Command/StringSetPreserveTest.php

@@ -52,7 +52,8 @@ class StringSetPreserveTest extends PredisCommandTestCase
      */
     public function testParseResponse()
     {
-        $this->assertTrue($this->getCommand()->parseResponse(1));
+        $this->assertSame(0, $this->getCommand()->parseResponse(0));
+        $this->assertSame(1, $this->getCommand()->parseResponse(1));
     }
 
     /**
@@ -62,8 +63,8 @@ class StringSetPreserveTest extends PredisCommandTestCase
     {
         $redis = $this->getClient();
 
-        $this->assertTrue($redis->setnx('foo', 'bar'));
-        $this->assertFalse($redis->setnx('foo', 'barbar'));
+        $this->assertSame(1, $redis->setnx('foo', 'bar'));
+        $this->assertSame(0, $redis->setnx('foo', 'barbar'));
         $this->assertEquals('bar', $redis->get('foo'));
     }
 }