StatusResponseTest.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. $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\StatusResponse();
  30. $response = $handler->handle($connection, 'OK');
  31. $this->assertInstanceOf('Predis\Response\Status', $response);
  32. $this->assertEquals('OK', $response);
  33. }
  34. /**
  35. * @group disconnected
  36. */
  37. public function testQueued()
  38. {
  39. $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface');
  40. $connection
  41. ->expects($this->never())
  42. ->method('readLine');
  43. $connection
  44. ->expects($this->never())
  45. ->method('readBuffer');
  46. $handler = new Handler\StatusResponse();
  47. $response = $handler->handle($connection, 'QUEUED');
  48. $this->assertInstanceOf('Predis\Response\Status', $response);
  49. $this->assertEquals('QUEUED', $response);
  50. }
  51. /**
  52. * @group disconnected
  53. */
  54. public function testPlainString()
  55. {
  56. $connection = $this->getMock('Predis\Connection\CompositeConnectionInterface');
  57. $connection
  58. ->expects($this->never())
  59. ->method('readLine');
  60. $connection
  61. ->expects($this->never())
  62. ->method('readBuffer');
  63. $handler = new Handler\StatusResponse();
  64. $response = $handler->handle($connection, 'Background saving started');
  65. $this->assertInstanceOf('Predis\Response\Status', $response);
  66. $this->assertEquals('Background saving started', $response);
  67. }
  68. }