StatusResponseTest.php 1.7 KB

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