StreamableMultiBulkResponseTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /*
  3. * This file is part of the Predis package.
  4. *
  5. * (c) Daniele Alessandri <suppakilla@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Predis\Protocol\Text;
  11. use PredisTestCase;
  12. /**
  13. *
  14. */
  15. class StreamableMultiBulkResponseTest extends PredisTestCase
  16. {
  17. /**
  18. * @group disconnected
  19. */
  20. public function testOk()
  21. {
  22. $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface');
  23. $connection
  24. ->expects($this->never())
  25. ->method('readLine');
  26. $connection
  27. ->expects($this->never())
  28. ->method('readBuffer');
  29. $handler = new Handler\StreamableMultiBulkResponse();
  30. $this->assertInstanceOf('Predis\Response\Iterator\MultiBulk', $handler->handle($connection, '1'));
  31. }
  32. /**
  33. * @group disconnected
  34. * @expectedException \Predis\Protocol\ProtocolException
  35. * @expectedExceptionMessage Cannot parse 'invalid' as a valid length for a multi-bulk response [tcp://127.0.0.1:6379]
  36. */
  37. public function testInvalid()
  38. {
  39. $connection = $this->getMockConnectionOfType('Predis\Connection\CompositeConnectionInterface', 'tcp://127.0.0.1:6379');
  40. $connection
  41. ->expects($this->never())
  42. ->method('readLine');
  43. $connection
  44. ->expects($this->never())
  45. ->method('readBuffer');
  46. $handler = new Handler\StreamableMultiBulkResponse();
  47. $handler->handle($connection, 'invalid');
  48. }
  49. }