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