ServerMonitorTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. 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\Command\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. $this->assertRegExp('/\d+.\d+(\s?\(db \d+\))? "MONITOR"/', $connection->read());
  58. }
  59. }