Browse Source

Move MissingBehaviorException under ORM/Error

ADmad 12 years ago
parent
commit
cd490da851

+ 6 - 6
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 @@ class BehaviorRegistry extends ObjectRegistry {
  *
  * @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 @@ class BehaviorRegistry extends ObjectRegistry {
 					$finder,
 					$duplicate[0]
 				);
-				throw new Error\Exception($error);
+				throw new Exception($error);
 			}
 			$finders[$finder] = [$alias, $methodName];
 		}
@@ -159,7 +159,7 @@ class BehaviorRegistry extends ObjectRegistry {
 					$method,
 					$duplicate[0]
 				);
-				throw new Error\Exception($error);
+				throw new Exception($error);
 			}
 			$methods[$method] = [$alias, $methodName];
 		}
@@ -210,7 +210,7 @@ class BehaviorRegistry extends ObjectRegistry {
 			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 @@ class BehaviorRegistry extends ObjectRegistry {
 			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));
 	}
 
 }

+ 3 - 1
src/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.

+ 2 - 1
tests/TestCase/Error/ExceptionRendererTest.php

@@ -28,6 +28,7 @@ use Cake\Error;
 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 @@ class ExceptionRendererTest extends TestCase {
 				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:/',

+ 1 - 1
tests/TestCase/ORM/BehaviorRegistryTest.php

@@ -109,7 +109,7 @@ class BehaviorRegistryTest extends TestCase {
 /**
  * Test load() on undefined class
  *
- * @expectedException \Cake\Error\MissingBehaviorException
+ * @expectedException \Cake\ORM\Error\MissingBehaviorException
  * @return void
  */
 	public function testLoadMissingClass() {

+ 1 - 1
tests/TestCase/ORM/TableTest.php

@@ -1029,7 +1029,7 @@ class TableTest extends \Cake\TestSuite\TestCase {
 /**
  * Ensure exceptions are raised on missing behaviors.
  *
- * @expectedException \Cake\Error\MissingBehaviorException
+ * @expectedException \Cake\ORM\Error\MissingBehaviorException
  */
 	public function testAddBehaviorMissing() {
 		$table = TableRegistry::get('article');