From dbfc1a74ba524636af2e3ef2c6d330d39098345f Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Sun, 27 Jul 2014 22:28:21 +0200 Subject: [PATCH] More random fixes after inspection. --- bin/create-command-test | 4 ++++ bin/create-pear | 4 ++-- examples/replication_complex.php | 2 +- src/Client.php | 3 +++ src/Connection/Aggregate/RedisCluster.php | 1 - tests/PHPUnit/PredisConnectionTestCase.php | 12 +++++++++++- tests/PHPUnit/PredisProfileTestCase.php | 5 +++-- tests/Predis/ClientTest.php | 4 ++-- tests/Predis/Collection/Iterator/HashKeyTest.php | 2 +- tests/Predis/Collection/Iterator/KeyspaceTest.php | 2 +- tests/Predis/Collection/Iterator/ListKeyTest.php | 4 ++-- tests/Predis/Collection/Iterator/SetKeyTest.php | 2 +- .../Collection/Iterator/SortedSetKeyTest.php | 2 +- tests/Predis/Command/KeyPreciseExpireAtTest.php | 1 - tests/Predis/Command/KeySortTest.php | 8 +++++--- .../Command/Processor/KeyPrefixProcessorTest.php | 8 +++----- tests/Predis/Command/RawCommandTest.php | 2 +- tests/Predis/Command/ServerEvalSHATest.php | 2 -- tests/Predis/Command/ServerEvalTest.php | 2 -- tests/Predis/Command/StringSetBitTest.php | 6 +++--- .../Predis/Command/ZSetIntersectionStoreTest.php | 2 +- tests/Predis/Command/ZSetUnionStoreTest.php | 2 +- tests/Predis/CommunicationExceptionTest.php | 2 +- .../Configuration/ConnectionFactoryOptionTest.php | 2 -- .../Connection/Aggregate/PredisClusterTest.php | 1 - .../Connection/CompositeStreamConnectionTest.php | 4 ++-- tests/Predis/Connection/FactoryTest.php | 7 ++++--- tests/Predis/Connection/ParametersTest.php | 2 -- .../Connection/PhpiredisSocketConnectionTest.php | 2 +- .../Connection/PhpiredisStreamConnectionTest.php | 2 +- tests/Predis/Connection/StreamConnectionTest.php | 2 +- tests/Predis/Monitor/ConsumerTest.php | 9 +++++---- tests/Predis/Pipeline/FireAndForgetTest.php | 5 ----- tests/Predis/Pipeline/PipelineTest.php | 2 +- .../Text/CompositeProtocolProcessorTest.php | 2 -- tests/Predis/PubSub/ConsumerTest.php | 15 +++++++-------- .../Response/Iterator/MultiBulkTupleTest.php | 4 ++-- tests/Predis/Transaction/MultiExecTest.php | 6 +++--- 38 files changed, 74 insertions(+), 73 deletions(-) diff --git a/bin/create-command-test b/bin/create-command-test index 52399435..930797df 100755 --- a/bin/create-command-test +++ b/bin/create-command-test @@ -134,7 +134,11 @@ class CommandTestCaseGenerator throw new RuntimeException("Class $class must implement Predis\Command\CommandInterface."); } + /* + * @var CommandInterface + */ $instance = $reflection->newInstance(); + $buffer = $this->getTestCaseBuffer($instance); return $buffer; diff --git a/bin/create-pear b/bin/create-pear index 054dd39a..b4f92db4 100755 --- a/bin/create-pear +++ b/bin/create-pear @@ -46,12 +46,12 @@ function parseAuthor($string) if (preg_match('/^\s*(.+?)\s*(?:"(\S+)"\s*)?<(\S+)>\s*$/x', $string , $regs)) { if (count($regs) == 4) { - list($orig,$name,$user,$email) = $regs; + list($_,$name,$user,$email) = $regs; $author['name'] = $name; $author['user'] = $user; $author['email'] = $email; } elseif (count($regs) == 3) { - list($orig,$name,$email) = $regs; + list($_,$name,$email) = $regs; $author['name'] = $name; $author['email'] = $email; } diff --git a/examples/replication_complex.php b/examples/replication_complex.php index 7d75b95e..c13d95fa 100644 --- a/examples/replication_complex.php +++ b/examples/replication_complex.php @@ -58,7 +58,7 @@ $options = array( return $profile; }, - 'replication' => function ($options) { + 'replication' => function () { $strategy = new ReplicationStrategy(); $strategy->setScriptReadOnly(HashMultipleGetAll::BODY); diff --git a/src/Client.php b/src/Client.php index ea99ade6..e49b005f 100644 --- a/src/Client.php +++ b/src/Client.php @@ -417,6 +417,9 @@ class Client implements ClientInterface $class = 'Predis\Pipeline\Pipeline'; } + /* + * @var ClientContextInterface + */ $pipeline = new $class($this); if (isset($callable)) { diff --git a/src/Connection/Aggregate/RedisCluster.php b/src/Connection/Aggregate/RedisCluster.php index 849263cc..77892e22 100644 --- a/src/Connection/Aggregate/RedisCluster.php +++ b/src/Connection/Aggregate/RedisCluster.php @@ -21,7 +21,6 @@ use Predis\Cluster\RedisStrategy as RedisClusterStrategy; use Predis\Command\CommandInterface; use Predis\Command\RawCommand; use Predis\Connection\NodeConnectionInterface; -use Predis\Connection\Factory; use Predis\Connection\FactoryInterface; use Predis\Response\ErrorInterface as ErrorResponseInterface; diff --git a/tests/PHPUnit/PredisConnectionTestCase.php b/tests/PHPUnit/PredisConnectionTestCase.php index 307dd72f..d9c1b7bc 100644 --- a/tests/PHPUnit/PredisConnectionTestCase.php +++ b/tests/PHPUnit/PredisConnectionTestCase.php @@ -116,6 +116,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ public function testExecutesCommandOnServer() { + $profile = $this->getProfile(); $connection = $this->getConnection($profile); $cmdPing = $this->getMock($profile->getCommandClass('ping'), array('parseResponse')); @@ -130,6 +131,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ public function testWritesCommandToServer() { + $profile = $this->getProfile(); $connection = $this->getConnection($profile); $cmdEcho = $this->getMock($profile->getCommandClass('echo'), array('parseResponse')); @@ -146,6 +148,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ public function testReadsCommandFromServer() { + $profile = $this->getProfile(); $connection = $this->getConnection($profile); $cmdEcho = $this->getMock($profile->getCommandClass('echo'), array('parseResponse')); @@ -162,7 +165,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ public function testIsAbleToWriteMultipleCommandsAndReadThemBackForPipelining() { - $connection = $this->getConnection($profile); + $profile = $this->getProfile(); $cmdPing = $this->getMock($profile->getCommandClass('ping'), array('parseResponse')); $cmdPing->expects($this->never()) @@ -187,6 +190,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ public function testSendsInitializationCommandsOnConnection() { + $profile = $this->getProfile(); $connection = $this->getConnection($profile, true); $cmdPing = $this->getMock($profile->getCommandClass('ping'), array('getArguments')); @@ -210,6 +214,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ public function testReadsStatusResponses() { + $profile = $this->getProfile(); $connection = $this->getConnection($profile, true); $connection->writeRequest($profile->createCommand('set', array('foo', 'bar'))); @@ -229,6 +234,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ public function testReadsBulkResponses() { + $profile = $this->getProfile(); $connection = $this->getConnection($profile, true); $connection->executeCommand($profile->createCommand('set', array('foo', 'bar'))); @@ -245,6 +251,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ public function testReadsIntegerResponses() { + $profile = $this->getProfile(); $connection = $this->getConnection($profile, true); $connection->executeCommand($profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol'))); @@ -258,6 +265,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ public function testReadsErrorResponsesAsResponseErrorObjects() { + $profile = $this->getProfile(); $connection = $this->getConnection($profile, true); $connection->executeCommand($profile->createCommand('set', array('foo', 'bar'))); @@ -272,6 +280,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ public function testReadsMultibulkResponsesAsArrays() { + $profile = $this->getProfile(); $connection = $this->getConnection($profile, true); $connection->executeCommand($profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol'))); @@ -299,6 +308,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ public function testThrowsExceptionOnReadWriteTimeout() { + $profile = $this->getProfile(); $connection = $this->getConnection($profile, true, array('read_write_timeout' => 0.5)); $connection->executeCommand($profile->createCommand('brpop', array('foo', 3))); diff --git a/tests/PHPUnit/PredisProfileTestCase.php b/tests/PHPUnit/PredisProfileTestCase.php index af1690c5..fc35d187 100644 --- a/tests/PHPUnit/PredisProfileTestCase.php +++ b/tests/PHPUnit/PredisProfileTestCase.php @@ -12,6 +12,7 @@ namespace Predis\Profile; use PredisTestCase; +use Predis\Command\CommandInterface; use Predis\Command\Processor\ProcessorChain; /** @@ -248,13 +249,13 @@ abstract class PredisProfileTestCase extends PredisTestCase $processor->expects($this->once()) ->method('process') ->with($this->isInstanceOf('Predis\Command\CommandInterface')) - ->will($this->returnCallback(function ($cmd) use (&$argsRef) { + ->will($this->returnCallback(function (CommandInterface $cmd) use (&$argsRef) { $cmd->setRawArguments($argsRef = array_map('strtoupper', $cmd->getArguments())); })); $profile = $this->getProfile(); $profile->setProcessor($processor); - $command = $profile->createCommand('set', array('foo', 'bar')); + $profile->createCommand('set', array('foo', 'bar')); $this->assertSame(array('FOO', 'BAR'), $argsRef); } diff --git a/tests/Predis/ClientTest.php b/tests/Predis/ClientTest.php index e81bcbbc..7b2f9794 100644 --- a/tests/Predis/ClientTest.php +++ b/tests/Predis/ClientTest.php @@ -226,7 +226,7 @@ class ClientTest extends PredisTestCase ->with($this->isInstanceOf('Predis\Configuration\OptionsInterface')) ->will($this->returnValue($wrongType)); - $client = new Client($callable); + new Client($callable); } /** @@ -308,7 +308,7 @@ class ClientTest extends PredisTestCase $arg2 = array('aggregate' => function () use ($fnaggregate) { return $fnaggregate; }); - $client = new Client($arg1, $arg2); + new Client($arg1, $arg2); } /** diff --git a/tests/Predis/Collection/Iterator/HashKeyTest.php b/tests/Predis/Collection/Iterator/HashKeyTest.php index 1a388bbb..15a25b03 100644 --- a/tests/Predis/Collection/Iterator/HashKeyTest.php +++ b/tests/Predis/Collection/Iterator/HashKeyTest.php @@ -32,7 +32,7 @@ class HashKeyTest extends PredisTestCase ->method('getProfile') ->will($this->returnValue(Profile\Factory::get('2.0'))); - $iterator = new HashKey($client, 'key:hash'); + new HashKey($client, 'key:hash'); } /** diff --git a/tests/Predis/Collection/Iterator/KeyspaceTest.php b/tests/Predis/Collection/Iterator/KeyspaceTest.php index f96a1a76..58ce08a2 100644 --- a/tests/Predis/Collection/Iterator/KeyspaceTest.php +++ b/tests/Predis/Collection/Iterator/KeyspaceTest.php @@ -32,7 +32,7 @@ class KeyspaceTest extends PredisTestCase ->method('getProfile') ->will($this->returnValue(Profile\Factory::get('2.0'))); - $iterator = new Keyspace($client); + new Keyspace($client); } /** diff --git a/tests/Predis/Collection/Iterator/ListKeyTest.php b/tests/Predis/Collection/Iterator/ListKeyTest.php index 1d92ccce..7a95edb0 100644 --- a/tests/Predis/Collection/Iterator/ListKeyTest.php +++ b/tests/Predis/Collection/Iterator/ListKeyTest.php @@ -120,7 +120,7 @@ class ListKeyTest extends PredisTestCase ->method('getProfile') ->will($this->returnValue(Profile\Factory::getDefault())); - $iterator = new ListKey($client, 'key:list', 'wrong'); + new ListKey($client, 'key:list', 'wrong'); } /** @@ -135,7 +135,7 @@ class ListKeyTest extends PredisTestCase ->method('getProfile') ->will($this->returnValue(Profile\Factory::getDefault())); - $iterator = new ListKey($client, 'key:list', 'wrong'); + new ListKey($client, 'key:list', 'wrong'); } /** diff --git a/tests/Predis/Collection/Iterator/SetKeyTest.php b/tests/Predis/Collection/Iterator/SetKeyTest.php index 00c1c5fb..fa9e3971 100644 --- a/tests/Predis/Collection/Iterator/SetKeyTest.php +++ b/tests/Predis/Collection/Iterator/SetKeyTest.php @@ -32,7 +32,7 @@ class SetKeyTest extends PredisTestCase ->method('getProfile') ->will($this->returnValue(Profile\Factory::get('2.0'))); - $iterator = new SetKey($client, 'key:set'); + new SetKey($client, 'key:set'); } /** diff --git a/tests/Predis/Collection/Iterator/SortedSetKeyTest.php b/tests/Predis/Collection/Iterator/SortedSetKeyTest.php index 1f679b72..6b7118cd 100644 --- a/tests/Predis/Collection/Iterator/SortedSetKeyTest.php +++ b/tests/Predis/Collection/Iterator/SortedSetKeyTest.php @@ -32,7 +32,7 @@ class SortedSetKeyTest extends PredisTestCase ->method('getProfile') ->will($this->returnValue(Profile\Factory::get('2.0'))); - $iterator = new SortedSetKey($client, 'key:zset'); + new SortedSetKey($client, 'key:zset'); } /** diff --git a/tests/Predis/Command/KeyPreciseExpireAtTest.php b/tests/Predis/Command/KeyPreciseExpireAtTest.php index 077cd4b2..eb2ce4b5 100644 --- a/tests/Predis/Command/KeyPreciseExpireAtTest.php +++ b/tests/Predis/Command/KeyPreciseExpireAtTest.php @@ -85,7 +85,6 @@ class KeyPreciseExpireAtTest extends PredisCommandTestCase { $redis = $this->getClient(); - $now = time(); $redis->set('foo', 'bar'); $this->assertTrue($redis->expireat('foo', time() - 100000)); diff --git a/tests/Predis/Command/KeySortTest.php b/tests/Predis/Command/KeySortTest.php index a7e40327..57bf4086 100644 --- a/tests/Predis/Command/KeySortTest.php +++ b/tests/Predis/Command/KeySortTest.php @@ -11,6 +11,8 @@ namespace Predis\Command; +use Predis\Client; + /** * @group commands * @group realm-key @@ -36,11 +38,11 @@ class KeySortTest extends PredisCommandTestCase /** * Utility method to to an LPUSH of some unordered values on a key. * - * @param \Predis\Client $redis Redis client instance. - * @param string $key Target key + * @param Client $redis Redis client instance. + * @param string $key Target key * @return array */ - protected function lpushUnorderedList(\Predis\Client $redis, $key) + protected function lpushUnorderedList(Client $redis, $key) { $list = array(2, 100, 3, 1, 30, 10); $redis->lpush($key, $list); diff --git a/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php b/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php index 437ca137..709e6007 100644 --- a/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php +++ b/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php @@ -67,16 +67,14 @@ class KeyPrefixProcessorTest extends PredisTestCase */ public function testSkipNotPrefixableCommands() { - $prefix = 'prefix:'; - $unprefixed = 'key'; - $expected = "$prefix$unprefixed"; - $command = $this->getMock('Predis\Command\CommandInterface'); $command->expects($this->once()) ->method('getId') ->will($this->returnValue('unknown')); + $command->expects($this->never()) + ->method('getArguments'); - $processor = new KeyPrefixProcessor($prefix); + $processor = new KeyPrefixProcessor('prefix'); $processor->process($command); } diff --git a/tests/Predis/Command/RawCommandTest.php b/tests/Predis/Command/RawCommandTest.php index 589ac4c1..7be62c8c 100644 --- a/tests/Predis/Command/RawCommandTest.php +++ b/tests/Predis/Command/RawCommandTest.php @@ -65,7 +65,7 @@ class RawCommandTest extends PredisTestCase */ public function testExceptionOnMissingCommandID() { - $command = new RawCommand(array()); + new RawCommand(array()); } /** diff --git a/tests/Predis/Command/ServerEvalSHATest.php b/tests/Predis/Command/ServerEvalSHATest.php index f73f9299..d7b95535 100644 --- a/tests/Predis/Command/ServerEvalSHATest.php +++ b/tests/Predis/Command/ServerEvalSHATest.php @@ -52,8 +52,6 @@ class ServerEvalSHATest extends PredisCommandTestCase */ public function testParseResponse() { - $command = $this->getCommand(); - $this->assertSame('bar', $this->getCommand()->parseResponse('bar')); } diff --git a/tests/Predis/Command/ServerEvalTest.php b/tests/Predis/Command/ServerEvalTest.php index 8579e0ea..181e58b1 100644 --- a/tests/Predis/Command/ServerEvalTest.php +++ b/tests/Predis/Command/ServerEvalTest.php @@ -52,8 +52,6 @@ class ServerEvalTest extends PredisCommandTestCase */ public function testParseResponse() { - $command = $this->getCommand(); - $this->assertSame('bar', $this->getCommand()->parseResponse('bar')); } diff --git a/tests/Predis/Command/StringSetBitTest.php b/tests/Predis/Command/StringSetBitTest.php index 7ed51433..fc1d93c6 100644 --- a/tests/Predis/Command/StringSetBitTest.php +++ b/tests/Predis/Command/StringSetBitTest.php @@ -91,7 +91,7 @@ class StringSetBitTest extends PredisCommandTestCase */ public function testThrowsExceptionOnInvalidBitValue() { - $redis = $this->getClient()->setbit('key:binary', 10, 255); + $this->getClient()->setbit('key:binary', 10, 255); } /** @@ -101,7 +101,7 @@ class StringSetBitTest extends PredisCommandTestCase */ public function testThrowsExceptionOnNegativeOffset() { - $redis = $this->getClient()->setbit('key:binary', -1, 1); + $this->getClient()->setbit('key:binary', -1, 1); } /** @@ -111,7 +111,7 @@ class StringSetBitTest extends PredisCommandTestCase */ public function testThrowsExceptionOnInvalidOffset() { - $redis = $this->getClient()->setbit('key:binary', 'invalid', 1); + $this->getClient()->setbit('key:binary', 'invalid', 1); } /** diff --git a/tests/Predis/Command/ZSetIntersectionStoreTest.php b/tests/Predis/Command/ZSetIntersectionStoreTest.php index 430a40c6..589cbfef 100644 --- a/tests/Predis/Command/ZSetIntersectionStoreTest.php +++ b/tests/Predis/Command/ZSetIntersectionStoreTest.php @@ -164,6 +164,6 @@ class ZSetIntersectionStoreTest extends PredisCommandTestCase $redis = $this->getClient(); $redis->set('foo', 'bar'); - $redis->zinterstore('zset:destination', 1, 'foo'); + $redis->zinterstore('zset:destination', '1', 'foo'); } } diff --git a/tests/Predis/Command/ZSetUnionStoreTest.php b/tests/Predis/Command/ZSetUnionStoreTest.php index a250f4f7..307f5f21 100644 --- a/tests/Predis/Command/ZSetUnionStoreTest.php +++ b/tests/Predis/Command/ZSetUnionStoreTest.php @@ -182,6 +182,6 @@ class ZSetUnionStoreTest extends PredisCommandTestCase $redis = $this->getClient(); $redis->set('foo', 'bar'); - $redis->zunionstore('zset:destination', 1, 'foo'); + $redis->zunionstore('zset:destination', '1', 'foo'); } } diff --git a/tests/Predis/CommunicationExceptionTest.php b/tests/Predis/CommunicationExceptionTest.php index 0ceedb8f..954be22c 100644 --- a/tests/Predis/CommunicationExceptionTest.php +++ b/tests/Predis/CommunicationExceptionTest.php @@ -100,7 +100,7 @@ class CommunicationExceptionTest extends PredisTestCase * @param string $message Exception message. * @param int $code Exception code. * @param \Exception $inner Inner exception. - * @return \Exception + * @return \Predis\CommunicationException */ protected function getException( Connection\NodeConnectionInterface $connection, diff --git a/tests/Predis/Configuration/ConnectionFactoryOptionTest.php b/tests/Predis/Configuration/ConnectionFactoryOptionTest.php index 869e0e9d..73d36ba7 100644 --- a/tests/Predis/Configuration/ConnectionFactoryOptionTest.php +++ b/tests/Predis/Configuration/ConnectionFactoryOptionTest.php @@ -36,7 +36,6 @@ class ConnectionFactoryOptionTest extends PredisTestCase */ public function testAcceptsNamedArrayWithSchemeToConnectionClassMappings() { - $option = new ConnectionFactoryOption(); $options = $this->getMock('Predis\Configuration\OptionsInterface'); $class = get_class($this->getMock('Predis\Connection\NodeConnectionInterface')); @@ -62,7 +61,6 @@ class ConnectionFactoryOptionTest extends PredisTestCase */ public function testAcceptsConnectionFactoryInstance() { - $option = new ConnectionFactoryOption(); $options = $this->getMock('Predis\Configuration\OptionsInterface'); $value = $this->getMock('Predis\Connection\FactoryInterface'); diff --git a/tests/Predis/Connection/Aggregate/PredisClusterTest.php b/tests/Predis/Connection/Aggregate/PredisClusterTest.php index 8286e4e2..05084b4f 100644 --- a/tests/Predis/Connection/Aggregate/PredisClusterTest.php +++ b/tests/Predis/Connection/Aggregate/PredisClusterTest.php @@ -89,7 +89,6 @@ class PredisClusterTest extends PredisTestCase $connection1 = $this->getMockConnection(); $connection2 = $this->getMockConnection('tcp://host1:7001?alias=node2'); $connection3 = $this->getMockConnection('tcp://host1:7002?alias=node3'); - $connection4 = $this->getMockConnection('tcp://host1:7003?alias=node4'); $cluster = new PredisCluster(); $cluster->add($connection1); diff --git a/tests/Predis/Connection/CompositeStreamConnectionTest.php b/tests/Predis/Connection/CompositeStreamConnectionTest.php index 547b4347..0ee61616 100644 --- a/tests/Predis/Connection/CompositeStreamConnectionTest.php +++ b/tests/Predis/Connection/CompositeStreamConnectionTest.php @@ -39,13 +39,13 @@ class CompositeStreamConnectionTest extends PredisConnectionTestCase /** * @group disconnected - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException * @expectedExceptionMessage Invalid scheme: 'udp'. */ public function testThrowsExceptionOnInvalidScheme() { $parameters = $this->getParameters(array('scheme' => 'udp')); - $connection = new CompositeStreamConnection($parameters); + new CompositeStreamConnection($parameters); } /** diff --git a/tests/Predis/Connection/FactoryTest.php b/tests/Predis/Connection/FactoryTest.php index a6cfce39..eee5b4b3 100644 --- a/tests/Predis/Connection/FactoryTest.php +++ b/tests/Predis/Connection/FactoryTest.php @@ -52,11 +52,12 @@ class FactoryTest extends PredisTestCase 'path' => '/tmp/redis.sock', )); - $connection = $factory->create($tcp); + $connection = $factory->create($unix); $parameters = $connection->getParameters(); $this->assertInstanceOf('Predis\Connection\StreamConnection', $connection); - $this->assertEquals($tcp->scheme, $parameters->scheme); - $this->assertEquals($tcp->database, $parameters->database); + $this->assertEquals($unix->scheme, $parameters->scheme); + $this->assertEquals($unix->path, $parameters->path); + $this->assertEquals($unix->database, $parameters->database); } /** diff --git a/tests/Predis/Connection/ParametersTest.php b/tests/Predis/Connection/ParametersTest.php index 8a9f8e95..33d6a937 100644 --- a/tests/Predis/Connection/ParametersTest.php +++ b/tests/Predis/Connection/ParametersTest.php @@ -90,8 +90,6 @@ class ParametersTest extends PredisTestCase */ public function testCreateWithUriString() { - $defaults = $this->getDefaultParametersArray(); - $overrides = array( 'port' => 7000, 'database' => 5, diff --git a/tests/Predis/Connection/PhpiredisSocketConnectionTest.php b/tests/Predis/Connection/PhpiredisSocketConnectionTest.php index 744434ca..cf6d6ad7 100644 --- a/tests/Predis/Connection/PhpiredisSocketConnectionTest.php +++ b/tests/Predis/Connection/PhpiredisSocketConnectionTest.php @@ -45,7 +45,7 @@ class PhpiredisSocketConnectionTest extends PredisConnectionTestCase public function testThrowsExceptionOnInvalidScheme() { $parameters = $this->getParameters(array('scheme' => 'udp')); - $connection = new PhpiredisSocketConnection($parameters); + new PhpiredisSocketConnection($parameters); } /** diff --git a/tests/Predis/Connection/PhpiredisStreamConnectionTest.php b/tests/Predis/Connection/PhpiredisStreamConnectionTest.php index 19527686..ddcc6ffa 100644 --- a/tests/Predis/Connection/PhpiredisStreamConnectionTest.php +++ b/tests/Predis/Connection/PhpiredisStreamConnectionTest.php @@ -45,7 +45,7 @@ class PhpiredisStreamConnectionTest extends PredisConnectionTestCase public function testThrowsExceptionOnInvalidScheme() { $parameters = $this->getParameters(array('scheme' => 'udp')); - $connection = new PhpiredisStreamConnection($parameters); + new PhpiredisStreamConnection($parameters); } /** diff --git a/tests/Predis/Connection/StreamConnectionTest.php b/tests/Predis/Connection/StreamConnectionTest.php index 9421f77f..cf880dcc 100644 --- a/tests/Predis/Connection/StreamConnectionTest.php +++ b/tests/Predis/Connection/StreamConnectionTest.php @@ -45,7 +45,7 @@ class StreamConnectionTest extends PredisConnectionTestCase public function testThrowsExceptionOnInvalidScheme() { $parameters = $this->getParameters(array('scheme' => 'udp')); - $connection = new StreamConnection($parameters); + new StreamConnection($parameters); } /** diff --git a/tests/Predis/Monitor/ConsumerTest.php b/tests/Predis/Monitor/ConsumerTest.php index 003f7846..5e9739f3 100644 --- a/tests/Predis/Monitor/ConsumerTest.php +++ b/tests/Predis/Monitor/ConsumerTest.php @@ -35,7 +35,8 @@ class ConsumerTest extends PredisTestCase ->will($this->returnValue(false)); $client = new Client(null, array('profile' => $profile)); - $monitor = new MonitorConsumer($client); + + new MonitorConsumer($client); } /** @@ -46,9 +47,9 @@ class ConsumerTest extends PredisTestCase public function testMonitorConsumerDoesNotWorkOnClusters() { $cluster = $this->getMock('Predis\Connection\Aggregate\ClusterInterface'); - $client = new Client($cluster); - $monitor = new MonitorConsumer($client); + + new MonitorConsumer($client); } /** @@ -69,7 +70,7 @@ class ConsumerTest extends PredisTestCase ->method('executeCommand') ->with($cmdMonitor); - $monitor = new MonitorConsumer($client); + new MonitorConsumer($client); } /** diff --git a/tests/Predis/Pipeline/FireAndForgetTest.php b/tests/Predis/Pipeline/FireAndForgetTest.php index be2c3448..6886a496 100644 --- a/tests/Predis/Pipeline/FireAndForgetTest.php +++ b/tests/Predis/Pipeline/FireAndForgetTest.php @@ -13,7 +13,6 @@ namespace Predis\Pipeline; use PredisTestCase; use Predis\Client; -use Predis\Profile; /** * @@ -25,8 +24,6 @@ class FireAndForgetTest extends PredisTestCase */ public function testPipelineWithSingleConnection() { - $profile = Profile\Factory::getDefault(); - $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->exactly(3))->method('writeRequest'); $connection->expects($this->never())->method('readResponse'); @@ -45,8 +42,6 @@ class FireAndForgetTest extends PredisTestCase */ public function testSwitchesToMasterWithReplicationConnection() { - $profile = Profile\Factory::getDefault(); - $connection = $this->getMock('Predis\Connection\Aggregate\ReplicationInterface'); $connection->expects($this->once()) ->method('switchTo') diff --git a/tests/Predis/Pipeline/PipelineTest.php b/tests/Predis/Pipeline/PipelineTest.php index 548f510a..77af74d5 100644 --- a/tests/Predis/Pipeline/PipelineTest.php +++ b/tests/Predis/Pipeline/PipelineTest.php @@ -346,8 +346,8 @@ class PipelineTest extends PredisTestCase try { $responses = $pipeline->execute(function ($pipe) { $pipe->echo('one'); - throw new ClientException('TEST'); $pipe->echo('two'); + throw new ClientException('TEST'); }); } catch (Exception $exception) { // NOOP diff --git a/tests/Predis/Protocol/Text/CompositeProtocolProcessorTest.php b/tests/Predis/Protocol/Text/CompositeProtocolProcessorTest.php index 265bd170..21552c1f 100644 --- a/tests/Predis/Protocol/Text/CompositeProtocolProcessorTest.php +++ b/tests/Predis/Protocol/Text/CompositeProtocolProcessorTest.php @@ -103,8 +103,6 @@ class CompositeProtocolProcessorTest extends PredisTestCase */ public function testConnectionRead() { - $serialized = "*1\r\n$4\r\nPING\r\n"; - $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface'); $reader = $this->getMock('Predis\Protocol\ResponseReaderInterface'); diff --git a/tests/Predis/PubSub/ConsumerTest.php b/tests/Predis/PubSub/ConsumerTest.php index be592b7f..2c54fe8d 100644 --- a/tests/Predis/PubSub/ConsumerTest.php +++ b/tests/Predis/PubSub/ConsumerTest.php @@ -34,7 +34,8 @@ class ConsumerTest extends PredisTestCase ->will($this->returnValue(false)); $client = new Client(null, array('profile' => $profile)); - $pubsub = new PubSubConsumer($client); + + new PubSubConsumer($client); } /** @@ -45,9 +46,9 @@ class ConsumerTest extends PredisTestCase public function testPubSubConsumerDoesNotWorkOnClusters() { $cluster = $this->getMock('Predis\Connection\Aggregate\ClusterInterface'); - $client = new Client($cluster); - $pubsub = new PubSubConsumer($client); + + new PubSubConsumer($client); } /** @@ -60,7 +61,7 @@ class ConsumerTest extends PredisTestCase $client = $this->getMock('Predis\Client', array('executeCommand'), array($connection)); $client->expects($this->never())->method('executeCommand'); - $pubsub = new PubSubConsumer($client); + new PubSubConsumer($client); } /** @@ -70,9 +71,6 @@ class ConsumerTest extends PredisTestCase { $profile = Profile\Factory::get(REDIS_SERVER_VERSION); - $cmdSubscribe = $profile->createCommand('subscribe', array('channel:foo')); - $cmdPsubscribe = $profile->createCommand('psubscribe', array('channels:*')); - $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $connection->expects($this->exactly(2))->method('writeRequest'); @@ -85,7 +83,8 @@ class ConsumerTest extends PredisTestCase })); $options = array('subscribe' => 'channel:foo', 'psubscribe' => 'channels:*'); - $pubsub = new PubSubConsumer($client, $options); + + new PubSubConsumer($client, $options); } /** diff --git a/tests/Predis/Response/Iterator/MultiBulkTupleTest.php b/tests/Predis/Response/Iterator/MultiBulkTupleTest.php index 05825882..bbcadb2b 100644 --- a/tests/Predis/Response/Iterator/MultiBulkTupleTest.php +++ b/tests/Predis/Response/Iterator/MultiBulkTupleTest.php @@ -56,7 +56,7 @@ class MultiBulkTupleTest extends PredisTestCase $client = $this->getClient(); $client->zadd('metavars', 1, 'foo', 2, 'hoge', 3, 'lol'); - $iterator = new MultiBulkTuple($client->zrange('metavars', 0, -1, 'withscores')); + $iterator = new MultiBulkTuple($client->zrange('metavars', '0', '-1', 'withscores')); $this->assertInstanceOf('OuterIterator', $iterator); $this->assertInstanceOf('Predis\Response\Iterator\MultiBulkTuple', $iterator); @@ -87,7 +87,7 @@ class MultiBulkTupleTest extends PredisTestCase $client = $this->getClient(); $client->zadd('metavars', 1, 'foo', 2, 'hoge', 3, 'lol'); - $iterator = new MultiBulkTuple($client->zrange('metavars', 0, -1, 'withscores')); + $iterator = new MultiBulkTuple($client->zrange('metavars', '0', '-1', 'withscores')); unset($iterator); diff --git a/tests/Predis/Transaction/MultiExecTest.php b/tests/Predis/Transaction/MultiExecTest.php index 453b3a7f..e1f0c5c7 100644 --- a/tests/Predis/Transaction/MultiExecTest.php +++ b/tests/Predis/Transaction/MultiExecTest.php @@ -37,7 +37,7 @@ class MultiExecTest extends PredisTestCase $connection = $this->getMock('Predis\Connection\NodeConnectionInterface'); $client = new Client($connection, array('profile' => $profile)); - $tx = new MultiExec($client); + new MultiExec($client); } /** @@ -386,7 +386,7 @@ class MultiExecTest extends PredisTestCase $tx = $this->getMockedTransaction($callback, $options); $tx->execute(function ($tx) { - $bar = $tx->get('foo'); + $tx->get('foo'); $tx->set('hoge', 'piyo'); }); @@ -450,7 +450,7 @@ class MultiExecTest extends PredisTestCase $callback = $this->getExecuteCallback(); $tx = $this->getMockedTransaction($callback); - $responses = $tx->execute(function ($tx) { + $tx->execute(function ($tx) { $tx->echo('!!ABORT!!'); }); }