123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- namespace Predis\Connection;
- use Predis\Command\RawCommand;
- use Predis\Response\Error as ErrorResponse;
- class PhpiredisSocketConnectionTest extends PredisConnectionTestCase
- {
- const CONNECTION_CLASS = 'Predis\Connection\PhpiredisSocketConnection';
-
- public function testSupportsSchemeTls()
- {
- $connection = $this->createConnectionWithParams(array('scheme' => 'tls'));
- $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection);
- }
-
- public function testSupportsSchemeRediss()
- {
- $connection = $this->createConnectionWithParams(array('scheme' => 'rediss'));
- $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection);
- }
-
- public function testThrowsExceptionOnInitializationCommandFailure()
- {
- $cmdSelect = RawCommand::create('SELECT', '1000');
- $connection = $this
- ->getMockBuilder(static::CONNECTION_CLASS)
- ->setMethods(array('executeCommand', 'createResource'))
- ->setConstructorArgs(array(new Parameters()))
- ->getMock();
- $connection
- ->method('executeCommand')
- ->with($cmdSelect)
- ->will($this->returnValue(
- new ErrorResponse('ERR invalid DB index')
- ));
- $connection->method('createResource');
- $connection->addConnectCommand($cmdSelect);
- $connection->connect();
- }
-
-
-
-
- public function testThrowsExceptionOnUnresolvableHostname()
- {
- $connection = $this->createConnectionWithParams(array('host' => 'bogus.tld'));
- $connection->connect();
- }
-
- public function testThrowsExceptionOnProtocolDesynchronizationErrors()
- {
- $connection = $this->createConnection();
- $socket = $connection->getResource();
- $connection->writeRequest($this->getCommandFactory()->createCommand('ping'));
- socket_read($socket, 1);
- $connection->read();
- }
- }
|