From ece71411bd1acab96221aa7972ac8e3cd6e3bd8e Mon Sep 17 00:00:00 2001 From: Vyacheslav Agafonov Date: Wed, 30 Nov 2011 14:51:15 +0400 Subject: [PATCH] added annotation @runInSeparateProcess and removing annotations @expectedException --- redis/RedisManager.php | 2 +- tests/redis/RedisManagerTest.php | 39 +++++++++------------------------------ 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/redis/RedisManager.php b/redis/RedisManager.php index 3bfc30d..31fd245 100644 --- a/redis/RedisManager.php +++ b/redis/RedisManager.php @@ -33,7 +33,7 @@ class RedisManager if (!$config) { if (gettype(Config::get('Redis')) != 'object') { - throw new GeneralException('config non-object'); + throw new GeneralException('Redis config no existence'); } $config = Config::get('Redis')->$name; } diff --git a/tests/redis/RedisManagerTest.php b/tests/redis/RedisManagerTest.php index 5edf851..442a2c5 100644 --- a/tests/redis/RedisManagerTest.php +++ b/tests/redis/RedisManagerTest.php @@ -13,21 +13,18 @@ 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 { - private $connections; - public function run(PHPUnit_Framework_TestResult $result = NULL) { $this->setPreserveGlobalState(false); return parent::run($result); } - + public function setUp() { $this->getMock('Redis'); @@ -46,70 +43,52 @@ class RedisManagerTest extends PHPUnit_Framework_TestCase } /** - * @expectedExceptionMessage Trying to get property of non-object * @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'); + $this->setExpectedException('GeneralException', 'Redis config no existence'); RedisManager::connect(); } - /** - * @expected Exception GeneralException - * @expected ExceptionMessage Connection parameters must be an array - */ public function testConnectWrongPersistantConfig() { - $this->setExpectedException('GeneralException'); + $this->setExpectedException('GeneralException', 'Connection parameters must be an array'); Config::set('Redis', array('new' => 'some')); RedisManager::connect('new'); } - /** - * @expected Exception GeneralException - * @expected ExceptionMessage Connection parameters must be an array - */ public function testConnectDefaultConfig() { - $this->setExpectedException('GeneralException'); + $this->setExpectedException('GeneralException', 'Connection parameters must be an array'); Config::set('Redis', array('default' => 'some')); RedisManager::connect(); } - /** - * @expected Exception GeneralException - * @expected ExceptionMessage Failed to connect to Redis server at - */ public function testConnectFailedConnection() { - $this->setExpectedException('GeneralException'); + $this->setExpectedException('GeneralException', 'Failed to connect to Redis server at'); Config::set('Redis', array('new' => array('host' => 'error', 'port' => 2023, 'database' => 'some'))); RedisManager::connect('new'); } - /** - * @expected Exception GeneralException - * @expected ExceptionMessage Failed to select Redis database with index - */ public function testConnectEstablishedConnectionNoDb() { - $this->setExpectedException('GeneralException'); + $this->setExpectedException('GeneralException', 'Failed to select Redis database with index'); 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')) {