Skip to content

Commit

Permalink
Convert trigger_error to an exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 15, 2013
1 parent 10897e5 commit 8f8425c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
16 changes: 3 additions & 13 deletions lib/Cake/Cache/Cache.php
Expand Up @@ -150,15 +150,14 @@ public static function config($key, $config = null) {
* Finds and builds the instance of the required engine class.
*
* @param string $name Name of the config array that needs an engine instance built
* @return boolean
* @throws Cake\Error\Exception
* @throws Cake\Error\Exception When a cache engine cannot be created.
*/
protected static function _buildEngine($name) {
if (empty(static::$_registry)) {
static::$_registry = new CacheRegistry();
}
if (empty(static::$_config[$name]['engine'])) {
return false;
throw new Error\Exception(__d('cake_dev', 'The "%s" cache configuration does not exist.', $name));
}

$config = static::$_config[$name];
Expand All @@ -173,8 +172,6 @@ protected static function _buildEngine($name) {
sort(static::$_groups[$group]);
}
}

return true;
}

/**
Expand Down Expand Up @@ -223,14 +220,7 @@ public static function engine($config) {
return static::$_registry->{$config};
}

if (!static::_buildEngine($config)) {
$message = __d(
'cake_dev',
'The "%s" cache configuration does not exist.',
$config
);
trigger_error($message, E_USER_WARNING);
}
static::_buildEngine($config);
return static::$_registry->{$config};
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Test/TestCase/Cache/CacheTest.php
Expand Up @@ -141,7 +141,7 @@ public function testInvalidConfig() {
/**
* Test write from a config that is undefined.
*
* @expectedException PHPUnit_Framework_Error_Warning
* @expectedException Cake\Error\Exception
* @return void
*/
public function testWriteNonExistingConfig() {
Expand All @@ -151,7 +151,7 @@ public function testWriteNonExistingConfig() {
/**
* Test write from a config that is undefined.
*
* @expectedException PHPUnit_Framework_Error_Warning
* @expectedException Cake\Error\Exception
* @return void
*/
public function testIncrementNonExistingConfig() {
Expand All @@ -161,7 +161,7 @@ public function testIncrementNonExistingConfig() {
/**
* Test write from a config that is undefined.
*
* @expectedException PHPUnit_Framework_Error_Warning
* @expectedException Cake\Error\Exception
* @return void
*/
public function testDecrementNonExistingConfig() {
Expand Down

0 comments on commit 8f8425c

Please sign in to comment.