mirror of
https://github.com/predis/predis.git
synced 2026-10-07 04:19:39 +00:00
[tests] Share common test among connection classes.
This commit is contained in:
@@ -17,6 +17,8 @@ namespace Predis\Connection;
|
||||
*/
|
||||
class PhpiredisSocketConnectionTest extends PredisConnectionTestCase
|
||||
{
|
||||
const CONNECTION_CLASS = 'Predis\Connection\PhpiredisSocketConnection';
|
||||
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
@@ -100,26 +102,6 @@ class PhpiredisSocketConnectionTest extends PredisConnectionTestCase
|
||||
// ---- INTEGRATION TESTS --------------------------------------------- //
|
||||
// ******************************************************************** //
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
*/
|
||||
public function testExecutesCommandsOnServer()
|
||||
{
|
||||
$connection = $this->getConnection($profile, true);
|
||||
|
||||
$cmdPing = $profile->createCommand('ping');
|
||||
$cmdEcho = $profile->createCommand('echo', array('echoed'));
|
||||
$cmdGet = $profile->createCommand('get', array('foobar'));
|
||||
$cmdRpush = $profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol'));
|
||||
$cmdLrange = $profile->createCommand('lrange', array('metavars', 0, -1));
|
||||
|
||||
$this->assertEquals('PONG', $connection->executeCommand($cmdPing));
|
||||
$this->assertSame('echoed', $connection->executeCommand($cmdEcho));
|
||||
$this->assertNull($connection->executeCommand($cmdGet));
|
||||
$this->assertSame(3, $connection->executeCommand($cmdRpush));
|
||||
$this->assertSame(array('foo', 'hoge', 'lol'), $connection->executeCommand($cmdLrange));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group connected
|
||||
* @expectedException \Predis\Connection\ConnectionException
|
||||
@@ -147,31 +129,4 @@ class PhpiredisSocketConnectionTest extends PredisConnectionTestCase
|
||||
|
||||
$connection->read();
|
||||
}
|
||||
|
||||
// ******************************************************************** //
|
||||
// ---- HELPER METHODS ------------------------------------------------ //
|
||||
// ******************************************************************** //
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getConnection(&$profile = null, $initialize = false, array $parameters = array())
|
||||
{
|
||||
$parameters = $this->getParameters($parameters);
|
||||
$profile = $this->getProfile();
|
||||
|
||||
$connection = new PhpiredisSocketConnection($parameters);
|
||||
|
||||
if ($initialize) {
|
||||
$connection->addConnectCommand(
|
||||
$profile->createCommand('select', array($parameters->database))
|
||||
);
|
||||
|
||||
$connection->addConnectCommand(
|
||||
$profile->createCommand('flushdb')
|
||||
);
|
||||
}
|
||||
|
||||
return $connection;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user