|
@@ -21,27 +21,56 @@ class ComposableTextProtocolTest extends StandardTestCase
|
|
|
/**
|
|
|
* @group disconnected
|
|
|
*/
|
|
|
- public function testCustomSerializer()
|
|
|
+ public function testConstructor()
|
|
|
{
|
|
|
- $serializer = $this->getMock('Predis\Protocol\CommandSerializerInterface');
|
|
|
+ $protocol = new ComposableTextProtocol();
|
|
|
+
|
|
|
+ $this->assertInstanceOf(
|
|
|
+ 'Predis\Protocol\Text\TextRequestSerializer', $protocol->getRequestSerializer()
|
|
|
+ );
|
|
|
+ $this->assertInstanceOf(
|
|
|
+ 'Predis\Protocol\Text\TextResponseReader', $protocol->getResponseReader()
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @group disconnected
|
|
|
+ */
|
|
|
+ public function testConstructorWithArguments()
|
|
|
+ {
|
|
|
+ $serializer = $this->getMock('Predis\Protocol\RequestSerializerInterface');
|
|
|
+ $reader = $this->getMock('Predis\Protocol\ResponseReaderInterface');
|
|
|
+
|
|
|
+ $protocol = new ComposableTextProtocol($serializer, $reader);
|
|
|
+
|
|
|
+ $this->assertSame($serializer, $protocol->getRequestSerializer());
|
|
|
+ $this->assertSame($reader, $protocol->getResponseReader());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @group disconnected
|
|
|
+ */
|
|
|
+ public function testCustomRequestSerializer()
|
|
|
+ {
|
|
|
+ $serializer = $this->getMock('Predis\Protocol\RequestSerializerInterface');
|
|
|
|
|
|
$protocol = new ComposableTextProtocol();
|
|
|
- $protocol->setSerializer($serializer);
|
|
|
+ $protocol->setRequestSerializer($serializer);
|
|
|
|
|
|
- $this->assertSame($serializer, $protocol->getSerializer());
|
|
|
+ $this->assertSame($serializer, $protocol->getRequestSerializer());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @group disconnected
|
|
|
*/
|
|
|
- public function testCustomReader()
|
|
|
+ public function testCustomResponseReader()
|
|
|
{
|
|
|
$reader = $this->getMock('Predis\Protocol\ResponseReaderInterface');
|
|
|
|
|
|
$protocol = new ComposableTextProtocol();
|
|
|
- $protocol->setReader($reader);
|
|
|
+ $protocol->setResponseReader($reader);
|
|
|
|
|
|
- $this->assertSame($reader, $protocol->getReader());
|
|
|
+ $this->assertSame($reader, $protocol->getResponseReader());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -53,10 +82,9 @@ class ComposableTextProtocolTest extends StandardTestCase
|
|
|
|
|
|
$command = $this->getMock('Predis\Command\CommandInterface');
|
|
|
$connection = $this->getMock('Predis\Connection\ComposableConnectionInterface');
|
|
|
- $serializer = $this->getMock('Predis\Protocol\CommandSerializerInterface');
|
|
|
+ $serializer = $this->getMock('Predis\Protocol\RequestSerializerInterface');
|
|
|
|
|
|
- $protocol = new ComposableTextProtocol();
|
|
|
- $protocol->setSerializer($serializer);
|
|
|
+ $protocol = new ComposableTextProtocol($serializer);
|
|
|
|
|
|
$connection->expects($this->once())
|
|
|
->method('writeBytes')
|
|
@@ -80,8 +108,7 @@ class ComposableTextProtocolTest extends StandardTestCase
|
|
|
$connection = $this->getMock('Predis\Connection\ComposableConnectionInterface');
|
|
|
$reader = $this->getMock('Predis\Protocol\ResponseReaderInterface');
|
|
|
|
|
|
- $protocol = new ComposableTextProtocol();
|
|
|
- $protocol->setReader($reader);
|
|
|
+ $protocol = new ComposableTextProtocol(null, $reader);
|
|
|
|
|
|
$reader->expects($this->once())
|
|
|
->method('read')
|
|
@@ -90,30 +117,4 @@ class ComposableTextProtocolTest extends StandardTestCase
|
|
|
|
|
|
$this->assertSame('bulk', $protocol->read($connection));
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * @group disconnected
|
|
|
- */
|
|
|
- public function testSetMultibulkOption()
|
|
|
- {
|
|
|
- $protocol = new ComposableTextProtocol();
|
|
|
- $reader = $protocol->getReader();
|
|
|
-
|
|
|
- $protocol->setOption('iterable_multibulk', true);
|
|
|
- $this->assertInstanceOf('Predis\Protocol\Text\ResponseMultiBulkStreamHandler', $reader->getHandler('*'));
|
|
|
-
|
|
|
- $protocol->setOption('iterable_multibulk', false);
|
|
|
- $this->assertInstanceOf('Predis\Protocol\Text\ResponseMultiBulkHandler', $reader->getHandler('*'));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @group disconnected
|
|
|
- * @expectedException InvalidArgumentException
|
|
|
- * @expectedExceptionMessage The option unknown_option is not supported by the current protocol
|
|
|
- */
|
|
|
- public function testSetInvalidOption()
|
|
|
- {
|
|
|
- $protocol = new ComposableTextProtocol();
|
|
|
- $protocol->setOption('unknown_option', true);
|
|
|
- }
|
|
|
}
|