Files
predis/tests/Predis/Commands/ServerMonitorTest.php
T
Daniele Alessandri f0f3d7814c Fix MONITOR and Predis\MonitorContext with Redis 2.6.
Starting with 2.6, Redis uses a slightly different format for the payload
returned by MONITOR for each command. Predis can now adapt to this difference
and returns a new `client` field in the payload object. This new field is
always defined but is set to NULL when connected to Redis < 2.6.

Please note that Redis 2.6 now does not echo the `MONITOR` command as the
first payload when opening a new MONITOR context.
2012-03-11 13:30:30 +01:00

75 lines
1.7 KiB
PHP

<?php
/*
* This file is part of the Predis package.
*
* (c) Daniele Alessandri <suppakilla@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Predis\Commands;
use \PHPUnit_Framework_TestCase as StandardTestCase;
/**
* @group commands
* @group realm-server
* @group realm-monitor
*/
class ServerMonitorTest extends CommandTestCase
{
/**
* {@inheritdoc}
*/
protected function getExpectedCommand()
{
return 'Predis\Commands\ServerMonitor';
}
/**
* {@inheritdoc}
*/
protected function getExpectedId()
{
return 'MONITOR';
}
/**
* @group disconnected
*/
public function testFilterArguments()
{
$command = $this->getCommand();
$command->setArguments(array());
$this->assertSame(array(), $command->getArguments());
}
/**
* @group disconnected
*/
public function testParseResponse()
{
$this->assertTrue($this->getCommand()->parseResponse(true));
}
/**
* @group connected
*/
public function testReturnsTrueAndReadsEventsFromTheConnection()
{
$connection = $this->getClient()->getConnection();
$command = $this->getCommand();
$this->assertTrue($connection->executeCommand($command));
// NOTE: Starting with 2.6 Redis does not return the "MONITOR" message after
// +OK to the client that issued the MONITOR command.
if (version_compare($this->getProfile()->getVersion(), '2.4', '<=')) {
$this->assertRegExp('/\d+.\d+(\s?\(db \d+\))? "MONITOR"/', $connection->read());
}
}
}