Skip to content

Commit

Permalink
Move MissingBehaviorException under ORM/Error
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Apr 13, 2014
1 parent bdcf810 commit cd490da
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/ORM/BehaviorRegistry.php
Expand Up @@ -15,7 +15,7 @@
namespace Cake\ORM;

use Cake\Core\App;
use Cake\Error;
use Cake\Error\Exception;
use Cake\ORM\Behavior;
use Cake\ORM\Table;
use Cake\Utility\ObjectRegistry;
Expand Down Expand Up @@ -87,7 +87,7 @@ protected function _resolveClassName($class) {
*
* @param string $class The classname that is missing.
* @param string $plugin The plugin the behavior is missing in.
* @throws \Cake\Error\MissingBehaviorException
* @throws \Cake\ORM\Error\MissingBehaviorException
*/
protected function _throwMissingClassError($class, $plugin) {
throw new Error\MissingBehaviorException([
Expand Down Expand Up @@ -145,7 +145,7 @@ protected function _getMethods(Behavior $instance, $class, $alias) {
$finder,
$duplicate[0]
);
throw new Error\Exception($error);
throw new Exception($error);
}
$finders[$finder] = [$alias, $methodName];
}
Expand All @@ -159,7 +159,7 @@ protected function _getMethods(Behavior $instance, $class, $alias) {
$method,
$duplicate[0]
);
throw new Error\Exception($error);
throw new Exception($error);
}
$methods[$method] = [$alias, $methodName];
}
Expand Down Expand Up @@ -210,7 +210,7 @@ public function call($method, array $args = []) {
return call_user_func_array([$this->_loaded[$behavior], $callMethod], $args);
}

throw new Error\Exception(sprintf('Cannot call "%s" it does not belong to any attached behavior.', $method));
throw new Exception(sprintf('Cannot call "%s" it does not belong to any attached behavior.', $method));
}

/**
Expand All @@ -229,7 +229,7 @@ public function callFinder($type, array $args = []) {
return call_user_func_array([$this->_loaded[$behavior], $callMethod], $args);
}

throw new Error\Exception(sprintf('Cannot call finder "%s" it does not belong to any attached behavior.', $type));
throw new Exception(sprintf('Cannot call finder "%s" it does not belong to any attached behavior.', $type));
}

}
Expand Up @@ -15,7 +15,9 @@
* @since 3.0.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace Cake\Error;
namespace Cake\ORM\Error;

use Cake\Error\Exception;

/**
* Used when a behavior cannot be found.
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase/Error/ExceptionRendererTest.php
Expand Up @@ -28,6 +28,7 @@
use Cake\Error\ExceptionRenderer;
use Cake\Event\Event;
use Cake\Network\Request;
use Cake\ORM\Error\MissingBehaviorException;
use Cake\Routing\Router;
use Cake\TestSuite\TestCase;
use Cake\View\Error\MissingHelperException;
Expand Down Expand Up @@ -542,7 +543,7 @@ public static function testProvider() {
500
),
array(
new Error\MissingBehaviorException(array('class' => 'MyCustomBehavior')),
new MissingBehaviorException(array('class' => 'MyCustomBehavior')),
array(
'/<h2>Missing Behavior<\/h2>/',
'/Create the class <em>MyCustomBehavior<\/em> below in file:/',
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/BehaviorRegistryTest.php
Expand Up @@ -109,7 +109,7 @@ public function testLoadPlugin() {
/**
* Test load() on undefined class
*
* @expectedException \Cake\Error\MissingBehaviorException
* @expectedException \Cake\ORM\Error\MissingBehaviorException
* @return void
*/
public function testLoadMissingClass() {
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/TableTest.php
Expand Up @@ -1029,7 +1029,7 @@ public function testAddBehavior() {
/**
* Ensure exceptions are raised on missing behaviors.
*
* @expectedException \Cake\Error\MissingBehaviorException
* @expectedException \Cake\ORM\Error\MissingBehaviorException
*/
public function testAddBehaviorMissing() {
$table = TableRegistry::get('article');
Expand Down

0 comments on commit cd490da

Please sign in to comment.