Browse Source

Fix small oversight.

Bug was not severe since +QUEUED status responses were returned anyway
but they were not cached as expected. We added a test in the suite.

This fixes #142.
Daniele Alessandri 11 years ago
parent
commit
09f9133df7
2 changed files with 16 additions and 1 deletions
  1. 1 1
      lib/Predis/Response/Status.php
  2. 15 0
      tests/Predis/Response/StatusTest.php

+ 1 - 1
lib/Predis/Response/Status.php

@@ -69,7 +69,7 @@ class Status implements ResponseInterface
 
                 return self::$OK;
 
-            case 'OK':
+            case 'QUEUED':
                 if (!isset(self::$QUEUED)) {
                     self::$QUEUED = new self('QUEUED');
                 }

+ 15 - 0
tests/Predis/Response/StatusTest.php

@@ -54,4 +54,19 @@ class StatusTest extends PredisTestCase
         $this->assertInstanceOf('Predis\Response\Status', $response = Status::get('PONG'));
         $this->assertEquals('PONG', $response);
     }
+
+    /**
+     * @group disconnected
+     */
+    public function testStaticGetMethodCachesOnlyCommonStatuses()
+    {
+        $response = Status::get('OK');
+        $this->assertSame($response, Status::get('OK'));
+
+        $response = Status::get('QUEUED');
+        $this->assertSame($response, Status::get('QUEUED'));
+
+        $response = Status::get('PONG');
+        $this->assertNotSame($response, Status::get('PONG'));
+    }
 }