ResponseMultiBulkStreamHandlerTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 \PHPUnit_Framework_TestCase as StandardTestCase;
  12. /**
  13. *
  14. */
  15. class ResponseMultiBulkStreamHandlerTest extends StandardTestCase
  16. {
  17. /**
  18. * @group disconnected
  19. */
  20. public function testOk()
  21. {
  22. $handler = new ResponseMultiBulkStreamHandler();
  23. $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface');
  24. $connection->expects($this->never())->method('readLine');
  25. $connection->expects($this->never())->method('readBytes');
  26. $this->assertInstanceOf('Predis\Iterator\MultiBulkResponseSimple', $handler->handle($connection, '1'));
  27. }
  28. /**
  29. * @group disconnected
  30. * @expectedException Predis\Protocol\ProtocolException
  31. * @expectedExceptionMessage Cannot parse 'invalid' as multi-bulk length
  32. */
  33. public function testInvalid()
  34. {
  35. $handler = new ResponseMultiBulkStreamHandler();
  36. $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface');
  37. $connection->expects($this->never())->method('readLine');
  38. $connection->expects($this->never())->method('readBytes');
  39. $handler->handle($connection, 'invalid');
  40. }
  41. }