소스 검색

Do not parse response to SETNX into boolean value.

Daniele Alessandri 9 년 전
부모
커밋
8c76bd6761
2개의 변경된 파일4개의 추가작업 그리고 11개의 파일을 삭제
  1. 0 8
      src/Command/StringSetPreserve.php
  2. 4 3
      tests/Predis/Command/StringSetPreserveTest.php

+ 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'));
     }
 }