Browse Source

Do not parse response to HSETNX into boolean value.

Daniele Alessandri 9 years ago
parent
commit
3fdfc50683
2 changed files with 5 additions and 13 deletions
  1. 0 8
      src/Command/HashSetPreserve.php
  2. 5 5
      tests/Predis/Command/HashSetPreserveTest.php

+ 0 - 8
src/Command/HashSetPreserve.php

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

+ 5 - 5
tests/Predis/Command/HashSetPreserveTest.php

@@ -54,8 +54,8 @@ class HashSetPreserveTest extends PredisCommandTestCase
     {
         $command = $this->getCommand();
 
-        $this->assertTrue($command->parseResponse(1));
-        $this->assertFalse($command->parseResponse(0));
+        $this->assertSame(0, $command->parseResponse(0));
+        $this->assertSame(1, $command->parseResponse(1));
     }
 
     /**
@@ -65,9 +65,9 @@ class HashSetPreserveTest extends PredisCommandTestCase
     {
         $redis = $this->getClient();
 
-        $this->assertTrue($redis->hsetnx('metavars', 'foo', 'bar'));
-        $this->assertTrue($redis->hsetnx('metavars', 'hoge', 'piyo'));
-        $this->assertFalse($redis->hsetnx('metavars', 'foo', 'barbar'));
+        $this->assertSame(1, $redis->hsetnx('metavars', 'foo', 'bar'));
+        $this->assertSame(1, $redis->hsetnx('metavars', 'hoge', 'piyo'));
+        $this->assertSame(0, $redis->hsetnx('metavars', 'foo', 'barbar'));
 
         $this->assertSame(array('bar', 'piyo'), $redis->hmget('metavars', 'foo', 'hoge'));
     }