Skip to content
Permalink
Browse files

ORM\Error -> ORM\Exception

  • Loading branch information...
lorenzo committed Aug 30, 2014
1 parent a5571df commit ce8db8598f28fbc11a737f4c3c9caccc5f74a3e1
@@ -14,12 +14,14 @@
*/
namespace Cake\ORM;
use BadMethodCallException;
use Cake\Core\App;
use Cake\Core\Exception\Exception;
use Cake\Core\ObjectRegistry;
use Cake\Event\EventManagerTrait;
use Cake\ORM\Behavior;
use Cake\ORM\Exception\MissingBehaviorException;
use Cake\ORM\Table;
use Cake\Core\ObjectRegistry;
use LogicException;
/**
* BehaviorRegistry is used as a registry for loaded behaviors and handles loading
@@ -82,10 +84,10 @@ protected function _resolveClassName($class) {
* @param string $class The classname that is missing.
* @param string $plugin The plugin the behavior is missing in.
* @return void
* @throws \Cake\ORM\Error\MissingBehaviorException
* @throws \Cake\ORM\Exception\MissingBehaviorException
*/
protected function _throwMissingClassError($class, $plugin) {
throw new Error\MissingBehaviorException([
throw new MissingBehaviorException([
'class' => $class . 'Behavior',
'plugin' => $plugin
]);
@@ -125,7 +127,7 @@ protected function _create($class, $alias, $config) {
* @param string $class The classname that is missing.
* @param string $alias The alias of the object.
* @return void
* @throws \Cake\Core\Exception\Exception when duplicate methods are connected.
* @throws \LogicException when duplicate methods are connected.
*/
protected function _getMethods(Behavior $instance, $class, $alias) {
$finders = array_change_key_case($instance->implementedFinders());
@@ -140,7 +142,7 @@ protected function _getMethods(Behavior $instance, $class, $alias) {
$finder,
$duplicate[0]
);
throw new Exception($error);
throw new LogicException($error);
}
$finders[$finder] = [$alias, $methodName];
}
@@ -154,7 +156,7 @@ protected function _getMethods(Behavior $instance, $class, $alias) {
$method,
$duplicate[0]
);
throw new Exception($error);
throw new LogicException($error);
}
$methods[$method] = [$alias, $methodName];
}
@@ -196,7 +198,7 @@ public function hasFinder($method) {
* @param string $method The method to invoke.
* @param array $args The arguments you want to invoke the method with.
* @return mixed The return value depends on the underlying behavior method.
* @throws \Cake\Core\Exception\Exception When the method is unknown.
* @throws \BadMethodCallException When the method is unknown.
*/
public function call($method, array $args = []) {
$method = strtolower($method);
@@ -205,7 +207,9 @@ public function call($method, array $args = []) {
return call_user_func_array([$this->_loaded[$behavior], $callMethod], $args);
}
throw new Exception(sprintf('Cannot call "%s" it does not belong to any attached behavior.', $method));
throw new BadMethodCallException(
sprintf('Cannot call "%s" it does not belong to any attached behavior.', $method)
);
}
/**
@@ -214,7 +218,7 @@ public function call($method, array $args = []) {
* @param string $type The finder type to invoke.
* @param array $args The arguments you want to invoke the method with.
* @return mixed The return value depends on the underlying behavior method.
* @throws \Cake\Core\Exception\Exception When the method is unknown.
* @throws \BadMethodCallException When the method is unknown.
*/
public function callFinder($type, array $args = []) {
$type = strtolower($type);
@@ -224,7 +228,9 @@ public function callFinder($type, array $args = []) {
return call_user_func_array([$this->_loaded[$behavior], $callMethod], $args);
}
throw new Exception(sprintf('Cannot call finder "%s" it does not belong to any attached behavior.', $type));
throw new BadMethodCallException(
sprintf('Cannot call finder "%s" it does not belong to any attached behavior.', $type)
);
}
}
@@ -11,7 +11,7 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\ORM\Error;
namespace Cake\ORM\Exception;
use Cake\Core\Exception\Exception;
@@ -14,7 +14,7 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\ORM\Error;
namespace Cake\ORM\Exception;
use Cake\Core\Exception\Exception;
@@ -12,7 +12,7 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\ORM\Error;
namespace Cake\ORM\Exception;
use Cake\Core\Exception\Exception;
@@ -12,7 +12,7 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\ORM\Error;
namespace Cake\ORM\Exception;
use RuntimeException;
@@ -14,6 +14,7 @@
*/
namespace Cake\ORM;
use BadMethodCallException;
use Cake\Core\App;
use Cake\Database\Schema\Table as Schema;
use Cake\Database\Type;
@@ -29,8 +30,8 @@
use Cake\ORM\Association\HasMany;
use Cake\ORM\Association\HasOne;
use Cake\ORM\BehaviorRegistry;
use Cake\ORM\Error\MissingEntityException;
use Cake\ORM\Error\RecordNotFoundException;
use Cake\ORM\Exception\MissingEntityException;
use Cake\ORM\Exception\RecordNotFoundException;
use Cake\ORM\Marshaller;
use Cake\Utility\Inflector;
use Cake\Validation\Validator;
@@ -431,7 +432,7 @@ public function displayField($key = null) {
* a new one
*
* @param string $name the name of the class to use
* @throws \Cake\ORM\Error\MissingEntityException when the entity class cannot be found
* @throws \Cake\ORM\Exception\MissingEntityException when the entity class cannot be found
* @return string
*/
public function entityClass($name = null) {
@@ -889,7 +890,7 @@ protected function _setFieldMatchers($options, $keys) {
/**
* {@inheritDoc}
*
* @throws \Cake\ORM\Error\RecordNotFoundException if no record can be found given
* @throws \Cake\ORM\Exception\RecordNotFoundException if no record can be found given
* a primary key value.
* @throws \InvalidArgumentException When $primaryKey has an incorrect number of elements.
*/
@@ -1461,7 +1462,7 @@ public function callFinder($type, Query $query, array $options = []) {
* @param string $method The method name that was fired.
* @param array $args List of arguments passed to the function.
* @return mixed
* @throws \Cake\Core\Exception\Exception when there are missing arguments, or when
* @throws \BadMethodCallException when there are missing arguments, or when
* and & or are combined.
*/
protected function _dynamicFinder($method, $args) {
@@ -1482,7 +1483,7 @@ protected function _dynamicFinder($method, $args) {
$makeConditions = function($fields, $args) {
$conditions = [];
if (count($args) < count($fields)) {
throw new \Cake\Core\Exception\Exception(sprintf(
throw new BadMethodCallException(sprintf(
'Not enough arguments to magic finder. Got %s required %s',
count($args),
count($fields)
@@ -1495,7 +1496,7 @@ protected function _dynamicFinder($method, $args) {
};
if ($hasOr !== false && $hasAnd !== false) {
throw new \Cake\Core\Exception\Exception(
throw new BadMethodCallException(
'Cannot mix "and" & "or" in a magic finder. Use find() instead.'
);
}
@@ -560,15 +560,15 @@ protected function skipUnless($condition, $message = '') {
* @param string $alias The model to get a mock for.
* @param mixed $methods The list of methods to mock
* @param array $options The config data for the mock's constructor.
* @throws \Cake\ORM\Error\MissingTableClassException
* @throws \Cake\ORM\Exception\MissingTableClassException
* @return Model
*/
public function getMockForModel($alias, array $methods = array(), array $options = array()) {
if (empty($options['className'])) {
$class = Inflector::camelize($alias);
$className = App::className($class, 'Model/Table', 'Table');
if (!$className) {
throw new \Cake\ORM\Error\MissingTableClassException(array($alias));
throw new \Cake\ORM\Exception\MissingTableClassException(array($alias));
}
$options['className'] = $className;
}
@@ -109,7 +109,7 @@ public function testLoadPlugin() {
/**
* Test load() on undefined class
*
* @expectedException \Cake\ORM\Error\MissingBehaviorException
* @expectedException \Cake\ORM\Exception\MissingBehaviorException
* @return void
*/
public function testLoadMissingClass() {
@@ -119,7 +119,7 @@ public function testLoadMissingClass() {
/**
* Test load() duplicate method error
*
* @expectedException \Cake\Core\Exception\Exception
* @expectedException LogicException
* @expectedExceptionMessage TestApp\Model\Behavior\DuplicateBehavior contains duplicate method "slugify"
* @return void
*/
@@ -149,7 +149,7 @@ public function testLoadDuplicateMethodAliasing() {
/**
* Test load() duplicate finder error
*
* @expectedException \Cake\Core\Exception\Exception
* @expectedException LogicException
* @expectedExceptionMessage TestApp\Model\Behavior\DuplicateBehavior contains duplicate finder "children"
* @return void
*/
@@ -243,7 +243,7 @@ public function testCall() {
/**
* Test errors on unknown methods.
*
* @expectedException \Cake\Core\Exception\Exception
* @expectedException BadMethodCallException
* @expectedExceptionMessage Cannot call "nope"
*/
public function testCallError() {
@@ -280,7 +280,7 @@ public function testCallFinder() {
/**
* Test errors on unknown methods.
*
* @expectedException \Cake\Core\Exception\Exception
* @expectedException BadMethodCallException
* @expectedExceptionMessage Cannot call finder "nope"
*/
public function testCallFinderError() {
@@ -291,7 +291,7 @@ public function testCallFinderError() {
/**
* Test errors on unloaded behavior methods.
*
* @expectedException \Cake\Core\Exception\Exception
* @expectedException BadMethodCallException
* @expectedExceptionMessage Cannot call "slugify" it does not belong to any attached behavior.
*/
public function testUnloadBehaviorThenCall() {
@@ -304,7 +304,7 @@ public function testUnloadBehaviorThenCall() {
/**
* Test errors on unloaded behavior finders.
*
* @expectedException \Cake\Core\Exception\Exception
* @expectedException BadMethodCallException
* @expectedExceptionMessage Cannot call finder "noslug" it does not belong to any attached behavior.
*/
public function testUnloadBehaviorThenCallFinder() {
@@ -911,7 +911,7 @@ class_alias($class, 'MyPlugin\Model\Entity\SuperUser');
* Tests that using a simple string for entityClass will throw an exception
* when the class does not exist in the namespace
*
* @expectedException \Cake\ORM\Error\MissingEntityException
* @expectedException \Cake\ORM\Exception\MissingEntityException
* @expectedExceptionMessage Entity class FooUser could not be found.
* @return void
*/
@@ -1101,7 +1101,7 @@ public function testBehaviors() {
/**
* Ensure exceptions are raised on missing behaviors.
*
* @expectedException \Cake\ORM\Error\MissingBehaviorException
* @expectedException \Cake\ORM\Exception\MissingBehaviorException
*/
public function testAddBehaviorMissing() {
$table = TableRegistry::get('article');
@@ -2212,7 +2212,7 @@ public function testMagicFindDefaultToAll() {
/**
* Test magic findByXX errors on missing arguments.
*
* @expectedException \Cake\Core\Exception\Exception
* @expectedException BadMethodCallException
* @expectedExceptionMessage Not enough arguments to magic finder. Got 0 required 1
* @return void
*/
@@ -2225,7 +2225,7 @@ public function testMagicFindError() {
/**
* Test magic findByXX errors on missing arguments.
*
* @expectedException \Cake\Core\Exception\Exception
* @expectedException BadMethodCallException
* @expectedExceptionMessage Not enough arguments to magic finder. Got 1 required 2
* @return void
*/
@@ -2238,7 +2238,7 @@ public function testMagicFindErrorMissingField() {
/**
* Test magic findByXX errors when there is a mix of or & and.
*
* @expectedException \Cake\Core\Exception\Exception
* @expectedException BadMethodCallException
* @expectedExceptionMessage Cannot mix "and" & "or" in a magic finder. Use find() instead.
* @return void
*/
@@ -3290,7 +3290,7 @@ public function testGet() {
/**
* Tests that get() will throw an exception if the record was not found
*
* @expectedException \Cake\ORM\Error\RecordNotFoundException
* @expectedException \Cake\ORM\Exception\RecordNotFoundException
* @expectedExceptionMessage Record "10" not found in table "articles"
* @return void
*/

0 comments on commit ce8db85

Please sign in to comment.
You can’t perform that action at this time.