mirror of
https://github.com/predis/predis.git
synced 2026-08-24 07:19:35 +00:00
41c29bed4e
The "throw_errors" connection parameter has been removed and replaced by the new "exceptions" client option since exceptions on -ERR replies returned by Redis are not generated by connection classes anymore but are thrown by the client class and other abstractions such as pipeline contexts. This change does not affect much people using the Predis\Client class (aside from the different configuration) but gives much more flexibility to those building their own pieces of code around the internal classes of Predis.
82 lines
2.4 KiB
PHP
82 lines
2.4 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\Option;
|
|
|
|
use \PHPUnit_Framework_TestCase as StandardTestCase;
|
|
|
|
/**
|
|
* @todo We should test the inner work performed by this class
|
|
* using mock objects, but it is quite hard to to that.
|
|
*/
|
|
class ClientOptionsTest extends StandardTestCase
|
|
{
|
|
/**
|
|
* @group disconnected
|
|
*/
|
|
public function testConstructorWithoutArguments()
|
|
{
|
|
$options = new ClientOptions();
|
|
|
|
$this->assertInstanceOf('Predis\ConnectionFactoryInterface', $options->connections);
|
|
$this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $options->profile);
|
|
$this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $options->cluster);
|
|
$this->assertNull($options->prefix);
|
|
}
|
|
|
|
/**
|
|
* @group disconnected
|
|
*/
|
|
public function testConstructorWithArrayArgument()
|
|
{
|
|
$options = new ClientOptions(array(
|
|
'cluster' => 'Predis\Connection\PredisCluster',
|
|
'connections' => 'Predis\ConnectionFactory',
|
|
'prefix' => 'prefix:',
|
|
'profile' => '2.0',
|
|
'exceptions' => false,
|
|
));
|
|
|
|
$this->assertInstanceOf('Predis\ConnectionFactoryInterface', $options->connections);
|
|
$this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $options->profile);
|
|
$this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $options->cluster);
|
|
$this->assertInstanceOf('Predis\Command\Processor\CommandProcessorInterface', $options->prefix);
|
|
$this->assertInternalType('bool', $options->exceptions);
|
|
}
|
|
|
|
/**
|
|
* @group disconnected
|
|
*/
|
|
public function testHandlesCustomOptionsWithoutHandlers()
|
|
{
|
|
$options = new ClientOptions(array(
|
|
'custom' => 'foobar',
|
|
));
|
|
|
|
$this->assertSame('foobar', $options->custom);
|
|
}
|
|
|
|
/**
|
|
* @group disconnected
|
|
*/
|
|
public function testIsSetReturnsIfOptionHasBeenSetByUser()
|
|
{
|
|
$options = new ClientOptions(array(
|
|
'prefix' => 'prefix:',
|
|
'custom' => 'foobar',
|
|
));
|
|
|
|
$this->assertTrue(isset($options->prefix));
|
|
$this->assertTrue(isset($options->custom));
|
|
$this->assertFalse(isset($options->profile));
|
|
}
|
|
}
|