added setExpectedException and check empty($search)
This commit is contained in:
@ -22,6 +22,7 @@ class RedisDebugTest extends PHPUnit_Framework_TestCase
|
||||
public function run(PHPUnit_Framework_TestResult $result = NULL)
|
||||
{
|
||||
$this->setPreserveGlobalState(false);
|
||||
|
||||
return parent::run($result);
|
||||
}
|
||||
|
||||
@ -85,7 +86,6 @@ class RedisDebugTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException GeneralException
|
||||
* @expectedExceptionMessage call_user_func_array() expects parameter 1 to be a valid callback
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
@ -94,8 +94,10 @@ class RedisDebugTest extends PHPUnit_Framework_TestCase
|
||||
if (!defined('DEBUG')) {
|
||||
define('DEBUG', true);
|
||||
}
|
||||
|
||||
$mock = $this->getMock('Redis', array('connect'));
|
||||
$redisDebug = new RedisDebug($mock);
|
||||
$this->setExpectedException('GeneralException');
|
||||
$this->assertNull($redisDebug->nothing('localhost', 4322));
|
||||
}
|
||||
}
|
@ -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')) {
|
||||
|
Reference in New Issue
Block a user