Forráskód Böngészése

Remove Predis\Client::getConnectionById().

Daniele Alessandri 8 éve
szülő
commit
b3b35a9ae2
3 módosított fájl, 2 hozzáadás és 67 törlés
  1. 2 0
      CHANGELOG.md
  2. 0 22
      src/Client.php
  3. 0 45
      tests/Predis/ClientTest.php

+ 2 - 0
CHANGELOG.md

@@ -44,6 +44,8 @@ v2.0.0 (201x-xx-xx)
   implements a method that matches the specified selector which means that some
   implements a method that matches the specified selector which means that some
   selectors may not be available to all kinds of connection backends.
   selectors may not be available to all kinds of connection backends.
 
 
+- The method `Predis\Client::getConnectionById($connectionID)` has been removed.
+
 - Changed the signature for the constructor of `Predis\Command\RawCommand`.
 - Changed the signature for the constructor of `Predis\Command\RawCommand`.
 
 
 - The `Predis\Connection\Aggregate` namespace has been split into two separate
 - The `Predis\Connection\Aggregate` namespace has been split into two separate

+ 0 - 22
src/Client.php

@@ -16,7 +16,6 @@ use Predis\Command\RawCommand;
 use Predis\Command\ScriptCommand;
 use Predis\Command\ScriptCommand;
 use Predis\Configuration\Options;
 use Predis\Configuration\Options;
 use Predis\Configuration\OptionsInterface;
 use Predis\Configuration\OptionsInterface;
-use Predis\Connection\AggregateConnectionInterface;
 use Predis\Connection\ConnectionInterface;
 use Predis\Connection\ConnectionInterface;
 use Predis\Connection\ParametersInterface;
 use Predis\Connection\ParametersInterface;
 use Predis\Connection\Replication\SentinelReplication;
 use Predis\Connection\Replication\SentinelReplication;
@@ -283,27 +282,6 @@ class Client implements ClientInterface, \IteratorAggregate
         return $this->connection;
         return $this->connection;
     }
     }
 
 
-    /**
-     * Retrieves the specified connection from the aggregate connection when the
-     * client is in cluster or replication mode.
-     *
-     * @param string $connectionID Index or alias of the single connection.
-     *
-     * @throws NotSupportedException
-     *
-     * @return Connection\NodeConnectionInterface
-     */
-    public function getConnectionById($connectionID)
-    {
-        if (!$this->connection instanceof AggregateConnectionInterface) {
-            throw new NotSupportedException(
-                'Retrieving connections by ID is supported only by aggregate connections.'
-            );
-        }
-
-        return $this->connection->getConnectionById($connectionID);
-    }
-
     /**
     /**
      * Executes a command without filtering its arguments, parsing the response,
      * Executes a command without filtering its arguments, parsing the response,
      * applying any prefix to keys or throwing exceptions on Redis errors even
      * applying any prefix to keys or throwing exceptions on Redis errors even

+ 0 - 45
tests/Predis/ClientTest.php

@@ -682,51 +682,6 @@ class ClientTest extends PredisTestCase
         $client->invalidCommand();
         $client->invalidCommand();
     }
     }
 
 
-    /**
-     * @group disconnected
-     */
-    public function testGetConnectionFromAggregateConnectionWithAlias()
-    {
-        $client = new Client(array('tcp://host1?alias=node01', 'tcp://host2?alias=node02'), array('cluster' => 'predis'));
-
-        $this->assertInstanceOf('Predis\Connection\Cluster\ClusterInterface', $cluster = $client->getConnection());
-        $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $node01 = $client->getConnectionById('node01'));
-        $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $node02 = $client->getConnectionById('node02'));
-
-        $this->assertSame('host1', $node01->getParameters()->host);
-        $this->assertSame('host2', $node02->getParameters()->host);
-    }
-
-    /**
-     * @group disconnected
-     * @expectedException \Predis\NotSupportedException
-     * @expectedExceptionMessage Retrieving connections by ID is supported only by aggregate connections.
-     */
-    public function testGetConnectionByIdWorksOnlyWithAggregateConnections()
-    {
-        $client = new Client();
-
-        $client->getConnectionById('node01');
-    }
-
-    /**
-     * @group disconnected
-     */
-    public function testGetClientByMethodCreatesClientWithConnectionFromAggregateConnection()
-    {
-        $client = new Client(array('tcp://host1?alias=node01', 'tcp://host2?alias=node02'), array('prefix' => 'pfx:', 'cluster' => 'predis'));
-
-        $this->assertInstanceOf('Predis\Connection\Cluster\ClusterInterface', $cluster = $client->getConnection());
-        $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $node01 = $client->getConnectionById('node01'));
-        $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $node02 = $client->getConnectionById('node02'));
-
-        $clientNode02 = $client->getClientBy('id', 'node02');
-
-        $this->assertInstanceOf('Predis\Client', $clientNode02);
-        $this->assertSame($node02, $clientNode02->getConnection());
-        $this->assertSame($client->getOptions(), $clientNode02->getOptions());
-    }
-
     /**
     /**
      * @group disconnected
      * @group disconnected
      */
      */