/**
  * @group disconnected
  */
 public function testCanBeSerialized()
 {
     $connection1 = $this->getMockConnection('tcp://host1?alias=first');
     $connection2 = $this->getMockConnection('tcp://host2?alias=second');
     $cluster = new PredisCluster();
     $cluster->add($connection1);
     $cluster->add($connection2);
     // We use the following line to initialize the underlying hashring.
     $cluster->getConnectionByKey('foo');
     $unserialized = unserialize(serialize($cluster));
     $this->assertEquals($cluster, $unserialized);
 }
 /**
  * @group disconnected
  */
 public function testReturnsCorrectConnectionUsingKey()
 {
     $connection1 = $this->getMockConnection('tcp://host1:7001');
     $connection2 = $this->getMockConnection('tcp://host1:7002');
     $cluster = new PredisCluster();
     $cluster->add($connection1);
     $cluster->add($connection2);
     $this->assertSame($connection1, $cluster->getConnectionByKey('node01:5431'));
     $this->assertSame($connection2, $cluster->getConnectionByKey('node02:3212'));
     $this->assertSame($connection1, $cluster->getConnectionByKey('prefix:{node01:5431}'));
     $this->assertSame($connection2, $cluster->getConnectionByKey('prefix:{node02:3212}'));
 }