StatusResponseTest.php 2.0 KB

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