Skip to content

Commit

Permalink
Move some classes and interfaces in other namespaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
nrk committed Jul 26, 2012
1 parent 28e1e7a commit 559853b
Show file tree
Hide file tree
Showing 25 changed files with 40 additions and 51 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG.NAMING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ by the naming conventions adopted by the Symfony2 project. This is a list of all

- `Predis\IReplyObject` => `Predis\ResponseObjectInterface`
- `Predis\IRedisServerError` => `Predis\ResponseErrorInterface`
- `Predis\IConnectionFactory` => `Predis\ConnectionFactoryInterface`
- `Predis\IConnectionParameters` => `Predis\ConnectionParametersInterface`
- `Predis\Options\IOption` => `Predis\Option\OptionInterface`
- `Predis\Options\IClientOptions` => `Predis\Option\ClientOptionsInterface`
- `Predis\Profile\IServerProfile` => `Predis\Profile\ServerProfileInterface`
Expand Down Expand Up @@ -48,4 +46,8 @@ by the naming conventions adopted by the Symfony2 project. This is a list of all

### Classes or interfaces moved to different namespaces ###

- `Predis\MonitorContext` is now under the `Predis\Monitor`.
- `Predis\MonitorContext` => `Predis\Monitor\MonitorContext`
- `Predis\ConnectionParameters` => `Predis\Connection\ConnectionParameters`
- `Predis\ConnectionParametersInterface` => `Predis\Connection\ConnectionParametersInterface`
- `Predis\ConnectionFactory` => `Predis\Connection\ConnectionFactory`
- `Predis\ConnectionFactoryInterface` => `Predis\Connection\ConnectionFactoryInterface`
1 change: 0 additions & 1 deletion examples/SimpleDebuggableConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

require 'SharedConfigurations.php';

use Predis\ConnectionParameters;
use Predis\Command\CommandInterface;
use Predis\Connection\StreamConnection;

Expand Down
2 changes: 2 additions & 0 deletions lib/Predis/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use Predis\Option\ClientOptionsInterface;
use Predis\Connection\ConnectionInterface;
use Predis\Connection\AggregatedConnectionInterface;
use Predis\Connection\ConnectionFactory;
use Predis\Connection\ConnectionFactoryInterface;
use Predis\Profile\ServerProfileInterface;
use Predis\Option\ClientOptions;
use Predis\Profile\ServerProfile;
Expand Down
1 change: 0 additions & 1 deletion lib/Predis/Connection/AbstractConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use Predis\Helpers;
use Predis\ResponseObjectInterface;
use Predis\ConnectionParametersInterface;
use Predis\ClientException;
use Predis\NotSupportedException;
use Predis\Command\CommandInterface;
Expand Down
1 change: 0 additions & 1 deletion lib/Predis/Connection/ComposableStreamConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Predis\Connection;

use Predis\ConnectionParametersInterface;
use Predis\Command\CommandInterface;
use Predis\Protocol\ProtocolInterface;
use Predis\Protocol\Text\TextProtocol;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
* file that was distributed with this source code.
*/

namespace Predis;
namespace Predis\Connection;

use Predis\Profile\ServerProfileInterface;
use Predis\Connection\SingleConnectionInterface;
use Predis\Connection\AggregatedConnectionInterface;
use Predis\Profile\ServerProfile;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
* file that was distributed with this source code.
*/

namespace Predis;
namespace Predis\Connection;

use Predis\Profile\ServerProfileInterface;
use Predis\Connection\AggregatedConnectionInterface;

/**
* Interface that must be implemented by classes that provide their own mechanism
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Predis;
namespace Predis\Connection;

use Predis\Option\OptionInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Predis;
namespace Predis\Connection;

/**
* Interface that must be implemented by classes that provide their own mechanism
Expand Down
1 change: 0 additions & 1 deletion lib/Predis/Connection/PhpiredisConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Predis\Connection;

use Predis\Command\CommandInterface;
use Predis\ConnectionParametersInterface;
use Predis\ResponseError;
use Predis\ResponseQueued;
use Predis\ClientException;
Expand Down
5 changes: 2 additions & 3 deletions lib/Predis/Connection/RedisCluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Predis\Connection;

use Predis\ResponseErrorInterface;
use Predis\ConnectionFactoryInterface;
use Predis\Command\CommandInterface;
use Predis\ClientException;
use Predis\NotSupportedException;
Expand All @@ -31,9 +30,9 @@ class RedisCluster implements ClusterConnectionInterface, \IteratorAggregate, \C
private $hashgenerator;

/**
* @param ConnectionFactoryInterface $connections Connection factory object.
* @param FactoryInterface $connections Connection factory object.
*/
public function __construct(ConnectionFactoryInterface $connections = null)
public function __construct(FactoryInterface $connections = null)
{
$this->pool = array();
$this->slots = array();
Expand Down
1 change: 0 additions & 1 deletion lib/Predis/Connection/StreamConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Predis\ResponseError;
use Predis\ResponseQueued;
use Predis\NotSupportedException;
use Predis\ConnectionParametersInterface;
use Predis\Command\CommandInterface;
use Predis\Iterator\MultiBulkResponseSimple;

Expand Down
1 change: 0 additions & 1 deletion lib/Predis/Connection/WebdisConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use Predis\Command\CommandInterface;
use Predis\ResponseObjectInterface;
use Predis\ConnectionParametersInterface;
use Predis\ResponseError;
use Predis\NotSupportedException;
use Predis\Protocol\ProtocolException;
Expand Down
6 changes: 3 additions & 3 deletions lib/Predis/Option/ClientConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace Predis\Option;

use Predis\ConnectionFactoryInterface;
use Predis\ConnectionFactory;
use Predis\Connection\ConnectionFactory;
use Predis\Connection\ConnectionFactoryInterface;

/**
* Option class that returns a connection factory to be used by a client.
Expand All @@ -38,7 +38,7 @@ public function filter(ClientOptionsInterface $options, $value)
}
if (is_string($value) && class_exists($value)) {
if (!($factory = new $value()) && !$factory instanceof ConnectionFactoryInterface) {
throw new \InvalidArgumentException("Class $value must be an instance of Predis\ConnectionFactoryInterface");
throw new \InvalidArgumentException("Class $value must be an instance of Predis\Connection\ConnectionFactoryInterface");
}
return $factory;
}
Expand Down
1 change: 0 additions & 1 deletion tests/PHPUnit/ConnectionTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use \PHPUnit_Framework_TestCase as StandardTestCase;

use Predis\ConnectionParameters;
use Predis\Profile\ServerProfile;

/**
Expand Down
3 changes: 2 additions & 1 deletion tests/Predis/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Predis\Profile\ServerProfile;
use Predis\Connection\PredisCluster;
use Predis\Connection\MasterSlaveReplication;
use Predis\Connection\ConnectionFactory;

/**
*
Expand Down Expand Up @@ -201,7 +202,7 @@ public function testConstructorWithReplicationArgument()
*/
public function testConstructorWithNullAndArrayArgument()
{
$factory = $this->getMock('Predis\ConnectionFactoryInterface');
$factory = $this->getMock('Predis\Connection\ConnectionFactoryInterface');

$arg2 = array('profile' => '2.0', 'prefix' => 'prefix:', 'connections' => $factory);
$client = new Client(null, $arg2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Predis;
namespace Predis\Connection;

use \PHPUnit_Framework_TestCase as StandardTestCase;

Expand All @@ -25,7 +25,7 @@ public function testImplementsCorrectInterface()
{
$factory = new ConnectionFactory();

$this->assertInstanceOf('Predis\ConnectionFactoryInterface', $factory);
$this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $factory);
}

/**
Expand Down Expand Up @@ -275,7 +275,7 @@ public function testAggregatedConnectionSkipCreationOnConnectionInstance()
->method('add')
->with($this->isInstanceOf('Predis\Connection\SingleConnectionInterface'));

$factory = $this->getMock('Predis\ConnectionFactory', array('create'));
$factory = $this->getMock('Predis\Connection\ConnectionFactory', array('create'));
$factory->expects($this->never())
->method('create');

Expand All @@ -285,7 +285,7 @@ public function testAggregatedConnectionSkipCreationOnConnectionInstance()
/**
* @group disconnected
*/
public function testAggregatedConnectionWithMixedConnectionParameters()
public function testAggregatedConnectionWithMixedParameters()
{
list(, $connectionClass) = $this->getMockConnectionClass();

Expand All @@ -294,7 +294,7 @@ public function testAggregatedConnectionWithMixedConnectionParameters()
->method('add')
->with($this->isInstanceOf('Predis\Connection\SingleConnectionInterface'));

$factory = $this->getMock('Predis\ConnectionFactory', array('create'));
$factory = $this->getMock('Predis\Connection\ConnectionFactory', array('create'));
$factory->expects($this->exactly(3))
->method('create')
->will($this->returnCallback(function($_, $_) use($connectionClass) {
Expand All @@ -312,7 +312,7 @@ public function testAggregatedConnectionWithEmptyListOfParameters()
$cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface');
$cluster->expects($this->never())->method('add');

$factory = $this->getMock('Predis\ConnectionFactory', array('create'));
$factory = $this->getMock('Predis\Connection\ConnectionFactory', array('create'));
$factory->expects($this->never())->method('create');

$factory->createAggregated($cluster, array());
Expand All @@ -329,7 +329,7 @@ public function testAggregatedConnectionWithServerProfileArgument()
$cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface');
$profile = $this->getMock('Predis\Profile\ServerProfileInterface');

$factory = $this->getMock('Predis\ConnectionFactory', array('create'));
$factory = $this->getMock('Predis\Connection\ConnectionFactory', array('create'));
$factory->expects($this->exactly(2))
->method('create')
->with($this->anything(), $profile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
* file that was distributed with this source code.
*/

namespace Predis;
namespace Predis\Connection;

use \PHPUnit_Framework_TestCase as StandardTestCase;

/**
* @todo ConnectionParameters::define();
* @todo ConnectionParameters::undefine();
*/
class ConnectionParametersTest extends StandardTestCase
class ParametersTest extends StandardTestCase
{
/**
* @group disconnected
Expand Down
1 change: 0 additions & 1 deletion tests/Predis/Connection/MasterSlaveReplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use \PHPUnit_Framework_TestCase as StandardTestCase;

use Predis\ConnectionParameters;
use Predis\Profile\ServerProfile;

/**
Expand Down
3 changes: 1 addition & 2 deletions tests/Predis/Connection/PhpiredisConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use \PHPUnit_Framework_TestCase as StandardTestCase;

use Predis\ConnectionParameters;
use Predis\Profile\ServerProfile;

/**
Expand All @@ -34,7 +33,7 @@ public function testConstructorDoesNotOpenConnection()
/**
* @group disconnected
*/
public function testExposesConnectionParameters()
public function testExposesParameters()
{
$parameters = $this->getParameters();
$connection = new PhpiredisConnection($parameters);
Expand Down
1 change: 0 additions & 1 deletion tests/Predis/Connection/PredisClusterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use \PHPUnit_Framework_TestCase as StandardTestCase;

use Predis\ConnectionParameters;
use Predis\Profile\ServerProfile;

/**
Expand Down
3 changes: 1 addition & 2 deletions tests/Predis/Connection/StreamConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use \PHPUnit_Framework_TestCase as StandardTestCase;

use Predis\ConnectionParameters;
use Predis\Profile\ServerProfile;

/**
Expand All @@ -34,7 +33,7 @@ public function testConstructorDoesNotOpenConnection()
/**
* @group disconnected
*/
public function testExposesConnectionParameters()
public function testExposesParameters()
{
$parameters = $this->getParameters();
$connection = new StreamConnection($parameters);
Expand Down
1 change: 0 additions & 1 deletion tests/Predis/Connection/WebdisConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use \PHPUnit_Framework_TestCase as StandardTestCase;

use Predis\ConnectionParameters;
use Predis\Profile\ServerProfile;

/**
Expand Down
16 changes: 8 additions & 8 deletions tests/Predis/Option/ClientConnectionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use \PHPUnit_Framework_TestCase as StandardTestCase;

use Predis\ConnectionFactory;
use Predis\Connection\ConnectionFactory;

/**
*
Expand All @@ -30,7 +30,7 @@ public function testValidationReturnsDefaultFactoryWithSchemeDefinitionsArray()

$options = $this->getMock('Predis\Option\ClientOptionsInterface');

$default = $this->getMock('Predis\ConnectionFactoryInterface');
$default = $this->getMock('Predis\Connection\ConnectionFactoryInterface');
$default->expects($this->exactly(2))
->method('define')
->with($this->matchesRegularExpression('/^tcp|redis$/'), $connectionClass);
Expand All @@ -43,7 +43,7 @@ public function testValidationReturnsDefaultFactoryWithSchemeDefinitionsArray()

$factory = $option->filter($options, $value);

$this->assertInstanceOf('Predis\ConnectionFactoryInterface', $factory);
$this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $factory);
$this->assertSame($default, $factory);
}

Expand All @@ -52,7 +52,7 @@ public function testValidationReturnsDefaultFactoryWithSchemeDefinitionsArray()
*/
public function testValidationAcceptsFactoryInstancesAsValue()
{
$value = $this->getMock('Predis\ConnectionFactoryInterface');
$value = $this->getMock('Predis\Connection\ConnectionFactoryInterface');
$options = $this->getMock('Predis\Option\ClientOptionsInterface');

$option = $this->getMock('Predis\Option\ClientConnectionFactory', array('getDefault'));
Expand All @@ -66,7 +66,7 @@ public function testValidationAcceptsFactoryInstancesAsValue()
*/
public function testValidationAcceptsStringAsValue()
{
$factory = 'Predis\ConnectionFactory';
$factory = 'Predis\Connection\ConnectionFactory';
$options = $this->getMock('Predis\Option\ClientOptionsInterface');

$option = $this->getMock('Predis\Option\ClientConnectionFactory', array('getDefault'));
Expand All @@ -93,7 +93,7 @@ public function testValidationThrowsExceptionOnWrongInvalidArguments()
*/
public function testInvokeReturnsSpecifiedFactoryOrDefault()
{
$value = $this->getMock('Predis\ConnectionFactoryInterface');
$value = $this->getMock('Predis\Connection\ConnectionFactoryInterface');
$options = $this->getMock('Predis\Option\ClientOptionsInterface');

$option = $this->getMock('Predis\Option\ClientConnectionFactory', array('filter', 'getDefault'));
Expand All @@ -103,7 +103,7 @@ public function testInvokeReturnsSpecifiedFactoryOrDefault()
->will($this->returnValue($value));
$option->expects($this->never())->method('getDefault');

$this->assertInstanceOf('Predis\ConnectionFactoryInterface', $option($options, $value));
$this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $option($options, $value));

$option = $this->getMock('Predis\Option\ClientConnectionFactory', array('filter', 'getDefault'));
$option->expects($this->never())->method('filter');
Expand All @@ -112,6 +112,6 @@ public function testInvokeReturnsSpecifiedFactoryOrDefault()
->with($options)
->will($this->returnValue($value));

$this->assertInstanceOf('Predis\ConnectionFactoryInterface', $option($options, null));
$this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $option($options, null));
}
}
Loading

0 comments on commit 559853b

Please sign in to comment.