Browse Source

Add missing test for Predis\Client::getClientFor().

Daniele Alessandri 12 years ago
parent
commit
003b3d180d
1 changed files with 17 additions and 0 deletions
  1. 17 0
      tests/Predis/ClientTest.php

+ 17 - 0
tests/Predis/ClientTest.php

@@ -441,6 +441,23 @@ class ClientTest extends StandardTestCase
         $client->getConnectionById('node01');
     }
 
+    /**
+     * @group disconnected
+     */
+    public function testCreateClientWithConnectionFromAggregatedConnection()
+    {
+        $client = new Client(array('tcp://host1?alias=node01', 'tcp://host2?alias=node02'), array('prefix' => 'pfx:'));
+
+        $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $cluster = $client->getConnection());
+        $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $node01 = $client->getConnectionById('node01'));
+        $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $node02 = $client->getConnectionById('node02'));
+
+        $clientNode02 = $client->getClientFor('node02');
+
+        $this->assertSame($node02, $clientNode02->getConnection());
+        $this->assertSame($client->getOptions(), $clientNode02->getOptions());
+    }
+
     /**
      * @group disconnected
      */