ServerMonitorTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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\Command;
  11. /**
  12. * @group commands
  13. * @group realm-server
  14. * @group realm-monitor
  15. */
  16. class ServerMonitorTest extends PredisCommandTestCase
  17. {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. protected function getExpectedCommand()
  22. {
  23. return 'Predis\Command\ServerMonitor';
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. protected function getExpectedId()
  29. {
  30. return 'MONITOR';
  31. }
  32. /**
  33. * @group disconnected
  34. */
  35. public function testFilterArguments()
  36. {
  37. $command = $this->getCommand();
  38. $command->setArguments(array());
  39. $this->assertSame(array(), $command->getArguments());
  40. }
  41. /**
  42. * @group disconnected
  43. */
  44. public function testParseResponse()
  45. {
  46. $this->assertSame('OK', $this->getCommand()->parseResponse('OK'));
  47. }
  48. /**
  49. * @group connected
  50. */
  51. public function testReturnsStatusResponseAndReadsEventsFromTheConnection()
  52. {
  53. $connection = $this->getClient()->getConnection();
  54. $command = $this->getCommand();
  55. $this->assertEquals('OK', $connection->executeCommand($command));
  56. // NOTE: Starting with 2.6 Redis does not return the "MONITOR" message after
  57. // +OK to the client that issued the MONITOR command.
  58. if (version_compare($this->getProfile()->getVersion(), '2.4', '<=')) {
  59. $this->assertRegExp('/\d+.\d+(\s?\(db \d+\))? "MONITOR"/', $connection->read());
  60. }
  61. }
  62. }