From cd490da8512d78ae6b6e1f0e1175b083dfa21d94 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sat, 12 Apr 2014 01:34:27 +0530 Subject: [PATCH] Move MissingBehaviorException under ORM/Error --- src/ORM/BehaviorRegistry.php | 12 ++++++------ src/{ => ORM}/Error/MissingBehaviorException.php | 4 +++- tests/TestCase/Error/ExceptionRendererTest.php | 3 ++- tests/TestCase/ORM/BehaviorRegistryTest.php | 2 +- tests/TestCase/ORM/TableTest.php | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) rename src/{ => ORM}/Error/MissingBehaviorException.php (93%) diff --git a/src/ORM/BehaviorRegistry.php b/src/ORM/BehaviorRegistry.php index 2fc79fcae63..41788fafcd5 100644 --- a/src/ORM/BehaviorRegistry.php +++ b/src/ORM/BehaviorRegistry.php @@ -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; @@ -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([ @@ -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]; } @@ -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]; } @@ -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)); } /** @@ -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)); } } diff --git a/src/Error/MissingBehaviorException.php b/src/ORM/Error/MissingBehaviorException.php similarity index 93% rename from src/Error/MissingBehaviorException.php rename to src/ORM/Error/MissingBehaviorException.php index 155be8cf197..bd80ab089cf 100644 --- a/src/Error/MissingBehaviorException.php +++ b/src/ORM/Error/MissingBehaviorException.php @@ -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. diff --git a/tests/TestCase/Error/ExceptionRendererTest.php b/tests/TestCase/Error/ExceptionRendererTest.php index a591f743230..020212b4c46 100644 --- a/tests/TestCase/Error/ExceptionRendererTest.php +++ b/tests/TestCase/Error/ExceptionRendererTest.php @@ -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; @@ -542,7 +543,7 @@ public static function testProvider() { 500 ), array( - new Error\MissingBehaviorException(array('class' => 'MyCustomBehavior')), + new MissingBehaviorException(array('class' => 'MyCustomBehavior')), array( '/

Missing Behavior<\/h2>/', '/Create the class MyCustomBehavior<\/em> below in file:/', diff --git a/tests/TestCase/ORM/BehaviorRegistryTest.php b/tests/TestCase/ORM/BehaviorRegistryTest.php index f351b0b8523..a5fab73e8ab 100644 --- a/tests/TestCase/ORM/BehaviorRegistryTest.php +++ b/tests/TestCase/ORM/BehaviorRegistryTest.php @@ -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() { diff --git a/tests/TestCase/ORM/TableTest.php b/tests/TestCase/ORM/TableTest.php index 183bfe518a1..0f225f0a98e 100644 --- a/tests/TestCase/ORM/TableTest.php +++ b/tests/TestCase/ORM/TableTest.php @@ -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');