|
|
@ -13,9 +13,9 @@ |
|
|
|
require_once dirname(__FILE__) . '/../../Registry.php'; |
|
|
|
require_once dirname(__FILE__) . '/../../Config.php'; |
|
|
|
require_once dirname(__FILE__) . '/../../redis/RedisManager.php'; |
|
|
|
require_once dirname(__FILE__) . '/../../exception/InitializationException.php'; |
|
|
|
require_once dirname(__FILE__) . '/../../exception/GeneralException.php'; |
|
|
|
|
|
|
|
|
|
|
|
class RedisManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
{ |
|
|
|
|
|
|
@ -46,65 +46,70 @@ class RedisManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @expectedException GeneralException |
|
|
|
* @expectedExceptionMessage Trying to get property of non-object |
|
|
|
* @TODO: line 34: $config = Config::get('Redis')->$name; - check for Redis config existence |
|
|
|
* @TODO: line 34: $config = Config::get('Redis')->$name; - check for Redis config existence. Agafonov: 'check added' |
|
|
|
*/ |
|
|
|
public function testConnectNoAnyConfig() |
|
|
|
{ |
|
|
|
//$this->setExpectedException('GeneralException');
|
|
|
|
$this->setExpectedException('GeneralException'); |
|
|
|
RedisManager::connect(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @expectedException GeneralException |
|
|
|
* @expectedExceptionMessage Connection parameters must be an array |
|
|
|
* @expected Exception GeneralException |
|
|
|
* @expected ExceptionMessage Connection parameters must be an array |
|
|
|
*/ |
|
|
|
public function testConnectWrongPersistantConfig() |
|
|
|
{ |
|
|
|
$this->setExpectedException('GeneralException'); |
|
|
|
Config::set('Redis', array('new' => 'some')); |
|
|
|
RedisManager::connect('new'); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @expectedException GeneralException |
|
|
|
* @expectedExceptionMessage Connection parameters must be an array |
|
|
|
* @expected Exception GeneralException |
|
|
|
* @expected ExceptionMessage Connection parameters must be an array |
|
|
|
*/ |
|
|
|
public function testConnectDefaultConfig() |
|
|
|
{ |
|
|
|
$this->setExpectedException('GeneralException'); |
|
|
|
Config::set('Redis', array('default' => 'some')); |
|
|
|
RedisManager::connect(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @expectedException GeneralException |
|
|
|
* @expectedExceptionMessage Failed to connect to Redis server at |
|
|
|
* @expected Exception GeneralException |
|
|
|
* @expected ExceptionMessage Failed to connect to Redis server at |
|
|
|
*/ |
|
|
|
public function testConnectFailedConnection() |
|
|
|
{ |
|
|
|
$this->setExpectedException('GeneralException'); |
|
|
|
Config::set('Redis', array('new' => array('host' => 'error', 'port' => 2023, 'database' => 'some'))); |
|
|
|
RedisManager::connect('new'); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @expectedException GeneralException |
|
|
|
* @expectedExceptionMessage Failed to select Redis database with index |
|
|
|
* @expected Exception GeneralException |
|
|
|
* @expected ExceptionMessage Failed to select Redis database with index |
|
|
|
*/ |
|
|
|
public function testConnectEstablishedConnectionNoDb() |
|
|
|
{ |
|
|
|
$this->setExpectedException('GeneralException'); |
|
|
|
Config::set('Redis', array('new' => array('host' => true, 'port' => 2023, 'database' => 'some'))); |
|
|
|
RedisManager::connect('new'); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testConnectionGood() |
|
|
|
{ |
|
|
|
// $this->setExpectedException('GeneralException');
|
|
|
|
Config::set('Redis', array('new' => array('host' => true, 'port' => 2023, 'database' => true))); |
|
|
|
$redis = RedisManager::connect('new'); |
|
|
|
$this->assertInstanceOf('RedisMock', $redis); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @runInSeparateProcess |
|
|
|
*/ |
|
|
|
|
|
|
|
public function testConnectWithDebug() |
|
|
|
{ |
|
|
|
if (!defined('DEBUG')) { |
|
|
|