ResponseStatusHandlerTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. use Predis\ResponseQueued;
  13. /**
  14. *
  15. */
  16. class ResponseStatusHandlerTest extends StandardTestCase
  17. {
  18. /**
  19. * @group disconnected
  20. */
  21. public function testOk()
  22. {
  23. $handler = new ResponseStatusHandler();
  24. $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface');
  25. $connection->expects($this->never())->method('readLine');
  26. $connection->expects($this->never())->method('readBytes');
  27. $this->assertTrue($handler->handle($connection, 'OK'));
  28. }
  29. /**
  30. * @group disconnected
  31. */
  32. public function testQueued()
  33. {
  34. $handler = new ResponseStatusHandler();
  35. $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface');
  36. $connection->expects($this->never())->method('readLine');
  37. $connection->expects($this->never())->method('readBytes');
  38. $this->assertInstanceOf('Predis\ResponseQueued', $handler->handle($connection, 'QUEUED'));
  39. }
  40. /**
  41. * @group disconnected
  42. */
  43. public function testPlainString()
  44. {
  45. $handler = new ResponseStatusHandler();
  46. $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface');
  47. $connection->expects($this->never())->method('readLine');
  48. $connection->expects($this->never())->method('readBytes');
  49. $this->assertSame('Background saving started', $handler->handle($connection, 'Background saving started'));
  50. }
  51. }