123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <?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\Command\Redis;
- /**
- * @group commands
- * @group realm-server
- */
- class CONFIG_Test extends PredisCommandTestCase
- {
- /**
- * {@inheritdoc}
- */
- protected function getExpectedCommand()
- {
- return 'Predis\Command\Redis\CONFIG';
- }
- /**
- * {@inheritdoc}
- */
- protected function getExpectedId()
- {
- return 'CONFIG';
- }
- /**
- * @group disconnected
- */
- public function testFilterArguments()
- {
- $arguments = array('GET', 'slowlog');
- $expected = array('GET', 'slowlog');
- $command = $this->getCommand();
- $command->setArguments($arguments);
- $this->assertSame($expected, $command->getArguments());
- }
- /**
- * @group disconnected
- */
- public function testParseResponseOfConfigGet()
- {
- $raw = array('slowlog-log-slower-than', '10000', 'slowlog-max-len', '64', 'loglevel', 'verbose');
- $expected = array(
- 'slowlog-log-slower-than' => '10000',
- 'slowlog-max-len' => '64',
- 'loglevel' => 'verbose',
- );
- $command = $this->getCommand();
- $this->assertSame($expected, $command->parseResponse($raw));
- }
- /**
- * @group disconnected
- */
- public function testParseResponseOfConfigSet()
- {
- $this->assertSame('OK', $this->getCommand()->parseResponse('OK'));
- }
- /**
- * @group disconnected
- */
- public function testParseResponseOfConfigResetstat()
- {
- $this->assertSame('OK', $this->getCommand()->parseResponse('OK'));
- }
- /**
- * @group connected
- * @requiresRedisVersion >= 2.0.0
- */
- public function testReturnsListOfConfigurationValues()
- {
- $redis = $this->getClient();
- $this->assertInternalType('array', $configs = $redis->config('GET', '*'));
- $this->assertGreaterThan(1, count($configs));
- $this->assertArrayHasKey('loglevel', $configs);
- $this->assertArrayHasKey('appendonly', $configs);
- $this->assertArrayHasKey('dbfilename', $configs);
- }
- /**
- * @group connected
- * @requiresRedisVersion >= 2.0.0
- */
- public function testReturnsListOfOneConfigurationEntry()
- {
- $redis = $this->getClient();
- $this->assertInternalType('array', $configs = $redis->config('GET', 'dbfilename'));
- $this->assertEquals(1, count($configs));
- $this->assertArrayHasKey('dbfilename', $configs);
- }
- /**
- * @group connected
- * @requiresRedisVersion >= 2.0.0
- */
- public function testReturnsEmptyListOnUnknownConfigurationEntry()
- {
- $redis = $this->getClient();
- $this->assertSame(array(), $redis->config('GET', 'foobar'));
- }
- /**
- * @group connected
- * @requiresRedisVersion >= 2.0.0
- */
- public function testReturnsTrueOnSuccessfulConfiguration()
- {
- $redis = $this->getClient();
- $previous = $redis->config('GET', 'loglevel');
- $this->assertEquals('OK', $redis->config('SET', 'loglevel', 'notice'));
- $this->assertSame(array('loglevel' => 'notice'), $redis->config('GET', 'loglevel'));
- // We set the loglevel configuration to the previous value.
- $redis->config('SET', 'loglevel', $previous['loglevel']);
- }
- /**
- * @group connected
- * @requiresRedisVersion >= 2.0.0
- * @expectedException \Predis\Response\ServerException
- * @expectedExceptionMessage ERR Unsupported CONFIG parameter: foo
- */
- public function testThrowsExceptionWhenSettingUnknownConfiguration()
- {
- $redis = $this->getClient();
- $redis->config('SET', 'foo', 'bar');
- }
- /**
- * @group connected
- * @requiresRedisVersion >= 2.0.0
- */
- public function testReturnsTrueOnResetstat()
- {
- $redis = $this->getClient();
- $this->assertEquals('OK', $redis->config('RESETSTAT'));
- }
- /**
- * @group connected
- * @requiresRedisVersion >= 2.0.0
- * @expectedException \Predis\Response\ServerException
- */
- public function testThrowsExceptionOnUnknownSubcommand()
- {
- $redis = $this->getClient();
- $redis->config('FOO');
- }
- }
|