|
@ -13,9 +13,9 @@ |
|
|
require_once dirname(__FILE__) . '/../../Registry.php'; |
|
|
require_once dirname(__FILE__) . '/../../Registry.php'; |
|
|
require_once dirname(__FILE__) . '/../../Config.php'; |
|
|
require_once dirname(__FILE__) . '/../../Config.php'; |
|
|
require_once dirname(__FILE__) . '/../../redis/RedisManager.php'; |
|
|
require_once dirname(__FILE__) . '/../../redis/RedisManager.php'; |
|
|
|
|
|
require_once dirname(__FILE__) . '/../../exception/InitializationException.php'; |
|
|
require_once dirname(__FILE__) . '/../../exception/GeneralException.php'; |
|
|
require_once dirname(__FILE__) . '/../../exception/GeneralException.php'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RedisManagerTest extends PHPUnit_Framework_TestCase |
|
|
class RedisManagerTest extends PHPUnit_Framework_TestCase |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
@ -46,12 +46,13 @@ class RedisManagerTest extends PHPUnit_Framework_TestCase |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @expectedException GeneralException |
|
|
|
|
|
* @expectedExceptionMessage Trying to get property of non-object |
|
|
* @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() |
|
|
public function testConnectNoAnyConfig() |
|
|
{ |
|
|
{ |
|
|
|
|
|
//$this->setExpectedException('GeneralException');
|
|
|
|
|
|
$this->setExpectedException('GeneralException'); |
|
|
RedisManager::connect(); |
|
|
RedisManager::connect(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -61,6 +62,7 @@ class RedisManagerTest extends PHPUnit_Framework_TestCase |
|
|
*/ |
|
|
*/ |
|
|
public function testConnectWrongPersistantConfig() |
|
|
public function testConnectWrongPersistantConfig() |
|
|
{ |
|
|
{ |
|
|
|
|
|
$this->setExpectedException('GeneralException'); |
|
|
Config::set('Redis', array('new' => 'some')); |
|
|
Config::set('Redis', array('new' => 'some')); |
|
|
RedisManager::connect('new'); |
|
|
RedisManager::connect('new'); |
|
|
} |
|
|
} |
|
@ -71,6 +73,7 @@ class RedisManagerTest extends PHPUnit_Framework_TestCase |
|
|
*/ |
|
|
*/ |
|
|
public function testConnectDefaultConfig() |
|
|
public function testConnectDefaultConfig() |
|
|
{ |
|
|
{ |
|
|
|
|
|
$this->setExpectedException('GeneralException'); |
|
|
Config::set('Redis', array('default' => 'some')); |
|
|
Config::set('Redis', array('default' => 'some')); |
|
|
RedisManager::connect(); |
|
|
RedisManager::connect(); |
|
|
} |
|
|
} |
|
@ -81,6 +84,7 @@ class RedisManagerTest extends PHPUnit_Framework_TestCase |
|
|
*/ |
|
|
*/ |
|
|
public function testConnectFailedConnection() |
|
|
public function testConnectFailedConnection() |
|
|
{ |
|
|
{ |
|
|
|
|
|
$this->setExpectedException('GeneralException'); |
|
|
Config::set('Redis', array('new' => array('host' => 'error', 'port' => 2023, 'database' => 'some'))); |
|
|
Config::set('Redis', array('new' => array('host' => 'error', 'port' => 2023, 'database' => 'some'))); |
|
|
RedisManager::connect('new'); |
|
|
RedisManager::connect('new'); |
|
|
} |
|
|
} |
|
@ -91,20 +95,21 @@ class RedisManagerTest extends PHPUnit_Framework_TestCase |
|
|
*/ |
|
|
*/ |
|
|
public function testConnectEstablishedConnectionNoDb() |
|
|
public function testConnectEstablishedConnectionNoDb() |
|
|
{ |
|
|
{ |
|
|
|
|
|
$this->setExpectedException('GeneralException'); |
|
|
Config::set('Redis', array('new' => array('host' => true, 'port' => 2023, 'database' => 'some'))); |
|
|
Config::set('Redis', array('new' => array('host' => true, 'port' => 2023, 'database' => 'some'))); |
|
|
RedisManager::connect('new'); |
|
|
RedisManager::connect('new'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testConnectionGood() |
|
|
public function testConnectionGood() |
|
|
{ |
|
|
{ |
|
|
|
|
|
// $this->setExpectedException('GeneralException');
|
|
|
Config::set('Redis', array('new' => array('host' => true, 'port' => 2023, 'database' => true))); |
|
|
Config::set('Redis', array('new' => array('host' => true, 'port' => 2023, 'database' => true))); |
|
|
$redis = RedisManager::connect('new'); |
|
|
$redis = RedisManager::connect('new'); |
|
|
$this->assertInstanceOf('RedisMock', $redis); |
|
|
$this->assertInstanceOf('RedisMock', $redis); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @runInSeparateProcess |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
public function testConnectWithDebug() |
|
|
public function testConnectWithDebug() |
|
|
{ |
|
|
{ |
|
|
if (!defined('DEBUG')) { |
|
|
if (!defined('DEBUG')) { |
|
|