diff --git a/cake/console/libs/console_input_argument.php b/cake/console/libs/console_input_argument.php index c0ed84fc0fe..20058235352 100644 --- a/cake/console/libs/console_input_argument.php +++ b/cake/console/libs/console_input_argument.php @@ -116,7 +116,7 @@ public function validChoice($value) { return true; } if (!in_array($value, $this->_choices)) { - throw new InvalidArgumentException(sprintf( + throw new ConsoleException(sprintf( __('"%s" is not a valid value for %s. Please use one of "%s"'), $value, $this->_name, implode(', ', $this->_choices) )); diff --git a/cake/console/libs/console_input_option.php b/cake/console/libs/console_input_option.php index d4d831aa135..56b01d448f6 100644 --- a/cake/console/libs/console_input_option.php +++ b/cake/console/libs/console_input_option.php @@ -142,7 +142,7 @@ public function validChoice($value) { return true; } if (!in_array($value, $this->_choices)) { - throw new InvalidArgumentException(sprintf( + throw new ConsoleException(sprintf( __('"%s" is not a valid value for --%s. Please use one of "%s"'), $value, $this->_name, implode(', ', $this->_choices) )); diff --git a/cake/console/libs/console_option_parser.php b/cake/console/libs/console_option_parser.php index 8a9f8af65e9..5af733e2d28 100644 --- a/cake/console/libs/console_option_parser.php +++ b/cake/console/libs/console_option_parser.php @@ -457,7 +457,7 @@ public function parse($argv, $command = null) { } foreach ($this->_args as $i => $arg) { if ($arg->isRequired() && !isset($args[$i]) && empty($params['help'])) { - throw new RuntimeException( + throw new ConsoleException( __('Missing required arguments. %s is required.', $arg->name()) ); } @@ -552,7 +552,7 @@ protected function _parseShortOption($option, $params) { */ protected function _parseOption($name, $params) { if (!isset($this->_options[$name])) { - throw new InvalidArgumentException(__('Unknown option `%s`', $name)); + throw new ConsoleException(__('Unknown option `%s`', $name)); } $option = $this->_options[$name]; $isBoolean = $option->isBoolean(); @@ -586,7 +586,7 @@ protected function _parseArg($argument, $args) { } $next = count($args); if (!isset($this->_args[$next])) { - throw new InvalidArgumentException(__('Too many arguments.')); + throw new ConsoleException(__('Too many arguments.')); } if ($this->_args[$next]->validChoice($argument)) { diff --git a/cake/console/shell_dispatcher.php b/cake/console/shell_dispatcher.php index a80407613e0..029a914424f 100644 --- a/cake/console/shell_dispatcher.php +++ b/cake/console/shell_dispatcher.php @@ -102,7 +102,7 @@ function __initConstants() { protected function _initEnvironment() { if (!$this->__bootstrap()) { $message = "Unable to load CakePHP core.\nMake sure " . DS . 'cake' . DS . 'libs exists in ' . CAKE_CORE_INCLUDE_PATH; - throw new RuntimeException($message); + throw new CakeException($message); } if (!isset($this->args[0]) || !isset($this->params['working'])) { @@ -110,7 +110,7 @@ protected function _initEnvironment() { "Please make sure that " . DIRECTORY_SEPARATOR . "cake" . DIRECTORY_SEPARATOR . "console is in your system path,\n" . "and check the cookbook for the correct usage of this command.\n" . "(http://book.cakephp.org/)"; - throw new RuntimeException($message); + throw new CakeException($message); } $this->shiftArgs(); diff --git a/cake/libs/cache.php b/cake/libs/cache.php index e211d20f96e..17ba3f8d709 100644 --- a/cake/libs/cache.php +++ b/cake/libs/cache.php @@ -67,7 +67,7 @@ class Cache { * @param string $name Name of the configuration * @param array $settings Optional associative array of settings passed to the engine * @return array(engine, settings) on success, false on failure - * @throws Exception + * @throws CacheException */ public static function config($name = null, $settings = array()) { if (is_array($name)) { @@ -113,10 +113,10 @@ protected static function _buildEngine($name) { return false; } $cacheClass = $class . 'Engine'; - self::$_engines[$name] = new $cacheClass(); - if (!self::$_engines[$name] instanceof CacheEngine) { - throw new Exception(__('Cache engines must use CacheEngine as a base class.')); + if (!is_subclass_of($cacheClass, 'CacheEngine')) { + throw new CacheException(__('Cache engines must use CacheEngine as a base class.')); } + self::$_engines[$name] = new $cacheClass(); if (self::$_engines[$name]->init($config)) { if (time() % self::$_engines[$name]->settings['probability'] === 0) { self::$_engines[$name]->gc(); diff --git a/cake/libs/cache/file.php b/cake/libs/cache/file.php index 687a74f72c6..7560d811397 100644 --- a/cake/libs/cache/file.php +++ b/cake/libs/cache/file.php @@ -249,20 +249,20 @@ public function clear($check) { * Not implemented * * @return void - * @throws BadMethodCallException + * @throws CacheException */ public function decrement($key, $offset = 1) { - throw new BadMethodCallException(__('Files cannot be atomically decremented.')); + throw new CacheException(__('Files cannot be atomically decremented.')); } /** * Not implemented * * @return void - * @throws BadMethodCallException + * @throws CacheException */ public function increment($key, $offset = 1) { - throw new BadMethodCallException(__('Files cannot be atomically incremented.')); + throw new CacheException(__('Files cannot be atomically incremented.')); } /** diff --git a/cake/libs/cache/memcache.php b/cake/libs/cache/memcache.php index 9b121e89ff8..d4a1dbfa83d 100644 --- a/cake/libs/cache/memcache.php +++ b/cake/libs/cache/memcache.php @@ -148,11 +148,11 @@ public function read($key) { * @param integer $offset How much to increment * @param integer $duration How long to cache the data, in seconds * @return New incremented value, false otherwise - * @throws RuntimeException when you try to increment with compress = true + * @throws CacheException when you try to increment with compress = true */ public function increment($key, $offset = 1) { if ($this->settings['compress']) { - throw new RuntimeException( + throw new CacheException( __('Method increment() not implemented for compressed cache in %s', __CLASS__) ); } @@ -166,11 +166,11 @@ public function increment($key, $offset = 1) { * @param integer $offset How much to substract * @param integer $duration How long to cache the data, in seconds * @return New decremented value, false otherwise - * @throws RuntimeException when you try to decrement with compress = true + * @throws CacheException when you try to decrement with compress = true */ public function decrement($key, $offset = 1) { if ($this->settings['compress']) { - throw new RuntimeException( + throw new CacheException( __('Method decrement() not implemented for compressed cache in %s', __CLASS__) ); } diff --git a/cake/libs/cake_log.php b/cake/libs/cake_log.php index 5e8887c65fb..afc8df03335 100644 --- a/cake/libs/cake_log.php +++ b/cake/libs/cake_log.php @@ -97,18 +97,18 @@ class CakeLog { * @param string $key The keyname for this logger, used to remove the logger later. * @param array $config Array of configuration information for the logger * @return boolean success of configuration. - * @throws Exception + * @throws CakeLogException */ public static function config($key, $config) { if (empty($config['engine'])) { - throw new Exception(__('Missing logger classname')); + throw new CakeLogException(__('Missing logger classname')); } $loggerName = $config['engine']; unset($config['engine']); $className = self::_getLogger($loggerName); $logger = new $className($config); if (!$logger instanceof CakeLogInterface) { - throw new Exception(sprintf( + throw new CakeLogException(sprintf( __('logger class %s does not implement a write method.'), $loggerName )); } @@ -134,7 +134,7 @@ protected static function _getLogger($loggerName) { } } if (!class_exists($loggerName)) { - throw new Exception(__('Could not load class %s', $loggerName)); + throw new CakeLogException(__('Could not load class %s', $loggerName)); } return $loggerName; } diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index ec05c55d202..580f51296b2 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -426,7 +426,7 @@ public function __call($name, $params) { $type = strtolower(substr($name, 2)); return $this->is($type); } - throw new BadMethodCallException(sprintf('Method %s does not exist', $name)); + throw new CakeException(__('Method %s does not exist', $name)); } /** diff --git a/cake/libs/cake_response.php b/cake/libs/cake_response.php index d2217efbd87..6c3d751c2b3 100644 --- a/cake/libs/cake_response.php +++ b/cake/libs/cake_response.php @@ -448,13 +448,14 @@ public function body($content = null) { * * @param integer $code * @return integer current status code + * @throws CakeException When an unknown status code is reached. */ public function statusCode($code = null) { if (is_null($code)) { return $this->_status; } if (!isset($this->_statusCodes[$code])) { - throw new OutOfRangeException(__('Unknown status code')); + throw new CakeException(__('Unknown status code')); } return $this->_status = $code; } diff --git a/cake/libs/cake_session.php b/cake/libs/cake_session.php index f90b27b3d3d..c590f28818b 100644 --- a/cake/libs/cake_session.php +++ b/cake/libs/cake_session.php @@ -265,7 +265,7 @@ public static function id($id = null) { public static function delete($name) { if (self::check($name)) { if (in_array($name, self::$watchKeys)) { - trigger_error(__('Deleting session key {%s}', $name), E_USER_NOTICE); + throw new CakeSessionException(__('Deleting session key {%s}', $name)); } self::__overwrite($_SESSION, Set::remove($_SESSION, $name)); return (self::check($name) == false); @@ -426,7 +426,6 @@ public static function watch($var) { */ public static function ignore($var) { if (!in_array($var, self::$watchKeys)) { - debug("NOT"); return; } foreach (self::$watchKeys as $i => $key) { @@ -455,7 +454,7 @@ public static function write($name, $value = null) { } foreach ($write as $key => $val) { if (in_array($key, self::$watchKeys)) { - trigger_error(__('Writing session key {%s}: %s', $key, var_export($val, true)), E_USER_NOTICE); + throw new CakeSessionException(__('Writing session key {%s}: %s', $key, var_export($val, true))); } self::__overwrite($_SESSION, Set::insert($_SESSION, $key, $val)); if (Set::classicExtract($_SESSION, $key) !== $val) { @@ -495,7 +494,7 @@ public static function clear() { * Sessions can be configured with a few shortcut names as well as have any number of ini settings declared. * * @return void - * @throws Exception Throws exceptions when ini_set() fails. + * @throws CakeSessionException Throws exceptions when ini_set() fails. */ protected static function _configureSession() { $sessionConfig = Configure::read('Session'); @@ -527,7 +526,7 @@ protected static function _configureSession() { if (!empty($sessionConfig['ini']) && is_array($sessionConfig['ini'])) { foreach ($sessionConfig['ini'] as $setting => $value) { if (ini_set($setting, $value) === false) { - throw new Exception(sprintf( + throw new CakeSessionException(sprintf( __('Unable to configure the session, setting %s failed.'), $setting )); @@ -565,13 +564,13 @@ protected static function _getHandler($handler) { App::import('Core', 'session/' . $class); } if (!class_exists($class)) { - throw new Exception(__('Could not load %s to handle the session.', $class)); + throw new CakeSessionException(__('Could not load %s to handle the session.', $class)); } $handler = new $class(); if ($handler instanceof CakeSessionHandlerInterface) { return $handler; } - throw new Exception(__('Chosen SessionHandler does not implement CakeSessionHandlerInterface it cannot be used with an engine key.')); + throw new CakeSessionException(__('Chosen SessionHandler does not implement CakeSessionHandlerInterface it cannot be used with an engine key.')); } /** diff --git a/cake/libs/config/php_reader.php b/cake/libs/config/php_reader.php index 169b44df666..1e2734d12d3 100644 --- a/cake/libs/config/php_reader.php +++ b/cake/libs/config/php_reader.php @@ -51,12 +51,12 @@ public function __construct($path = CONFIGS) { * @param string $key The identifier to read from. If the key has a . it will be treated * as a plugin prefix. * @return array Parsed configuration values. - * @throws RuntimeException when files don't exist or they don't contain `$config`. - * InvalidArgumentException when files contain '..' as this could lead to abusive reads. + * @throws ConfigureException when files don't exist or they don't contain `$config`. + * Or when files contain '..' as this could lead to abusive reads. */ public function read($key) { if (strpos($key, '..') !== false) { - throw new InvalidArgumentException(__('Cannot load configuration files with ../ in them.')); + throw new ConfigureException(__('Cannot load configuration files with ../ in them.')); } list($plugin, $key) = pluginSplit($key); @@ -66,11 +66,11 @@ public function read($key) { $file = $this->_path . $key . '.php'; } if (!file_exists($file)) { - throw new RuntimeException(__('Could not load configuration file: ') . $file); + throw new ConfigureException(__('Could not load configuration file: ') . $file); } include $file; if (!isset($config)) { - throw new RuntimeException( + throw new ConfigureException( sprintf(__('No variable $config found in %s.php'), $file) ); } diff --git a/cake/libs/configure.php b/cake/libs/configure.php index fca858832d2..ce05b018e8d 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -325,7 +325,7 @@ public static function drop($name) { * @param string $key name of configuration resource to load. * @param string $config Name of the configured reader to use to read the resource identfied by $key. * @return mixed false if file not found, void if load successful. - * @throws Exception Will throw any exceptions the reader raises. + * @throws ConfigureException Will throw any exceptions the reader raises. */ public static function load($key, $config = 'default') { if (!isset(self::$_readers[$config])) { diff --git a/cake/libs/controller/components/acl.php b/cake/libs/controller/components/acl.php index 3a09c590bf5..1b7b31486b7 100644 --- a/cake/libs/controller/components/acl.php +++ b/cake/libs/controller/components/acl.php @@ -58,7 +58,7 @@ class AclComponent extends Component { /** * Constructor. Will return an instance of the correct ACL class as defined in `Configure::read('Acl.classname')` * - * @throws Exception when Acl.classname could not be loaded. + * @throws CakeException when Acl.classname could not be loaded. */ public function __construct(ComponentCollection $collection, $settings = array()) { parent::__construct($collection, $settings); @@ -68,7 +68,7 @@ public function __construct(ComponentCollection $collection, $settings = array() list($plugin, $name) = pluginSplit($name); $name .= 'Component'; } else { - throw new Exception(__('Could not find %s.', $name)); + throw new CakeException(__('Could not find %s.', $name)); } } $this->adapter($name); @@ -84,7 +84,7 @@ public function __construct(ComponentCollection $collection, $settings = array() * * @param mixed $adapter Instance of AclBase or a string name of the class to use. (optional) * @return mixed either null, or instance of AclBase - * @throws Exception when the given class is not an AclBase + * @throws CakeException when the given class is not an AclBase */ public function adapter($adapter = null) { if ($adapter) { @@ -92,7 +92,7 @@ public function adapter($adapter = null) { $adapter = new $adapter(); } if (!$adapter instanceof AclInterface) { - throw new Exception(__('AclComponent adapters must implement AclInterface')); + throw new CakeException(__('AclComponent adapters must implement AclInterface')); } $this->_Instance = $adapter; $this->_Instance->initialize($this); diff --git a/cake/libs/error/exceptions.php b/cake/libs/error/exceptions.php index 961b39c7d42..b6d49061d86 100644 --- a/cake/libs/error/exceptions.php +++ b/cake/libs/error/exceptions.php @@ -387,4 +387,62 @@ class MissingTableException extends CakeException { */ class MissingModelException extends CakeException { protected $_messageTemplate = 'Model %s could not be found.'; -} \ No newline at end of file +} + + +/** + * Exception class for Cache. This exception will be thrown from Cache when it + * encounters an error. + * + * @package cake.libs + */ +class CacheException extends CakeException { } + +/** + * Exception class for Router. This exception will be thrown from Router when it + * encounters an error. + * + * @package cake.libs + */ +class RouterException extends CakeException { } + +/** + * Exception class for CakeLog. This exception will be thrown from CakeLog when it + * encounters an error. + * + * @package cake.libs + */ +class CakeLogException extends CakeException { } + +/** + * Exception class for CakeSession. This exception will be thrown from CakeSession when it + * encounters an error. + * + * @package cake.libs + */ +class CakeSessionException extends CakeException { } + +/** + * Exception class for Configure. This exception will be thrown from Configure when it + * encounters an error. + * + * @package cake.libs + */ +class ConfigureException extends CakeException { } + +/** + * Exception class for Xml. This exception will be thrown from Xml when it + * encounters an error. + * + * @package cake.libs + */ +class XmlException extends CakeException { } + +/** + * Exception class for Console libraries. This exception will be thrown from Console library + * classes when they encounter an error. + * + * @package cake.libs + */ +class ConsoleException extends CakeException { } + diff --git a/cake/libs/router.php b/cake/libs/router.php index b51f02134df..010511cb257 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -226,7 +226,7 @@ public static function getNamedExpressions() { * shifted into the passed arguments. As well as supplying patterns for routing parameters. * @see routes * @return array Array of routes - * @throws Exception + * @throws RouterException */ public static function connect($route, $defaults = array(), $options = array()) { foreach (self::$_prefixes as $prefix) { @@ -246,13 +246,12 @@ public static function connect($route, $defaults = array(), $options = array()) $routeClass = 'CakeRoute'; if (isset($options['routeClass'])) { $routeClass = $options['routeClass']; + if (!is_subclass_of($routeClass, 'CakeRoute')) { + throw new RouterException(__('Route classes must extend CakeRoute')); + } unset($options['routeClass']); } - $Route = new $routeClass($route, $defaults, $options); - if (!$Route instanceof CakeRoute) { - throw new Exception(__('Route classes must extend CakeRoute')); - } - self::$routes[] =& $Route; + self::$routes[] = new $routeClass($route, $defaults, $options); return self::$routes; } diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index e57e12a686c..a92b3fd4147 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -1133,14 +1133,15 @@ public function radio($fieldName, $options = array(), $attributes = array()) { * The first argument to an input type should always be the fieldname, in `Model.field` format. * The second argument should always be an array of attributes for the input. * - * @param string $method Method name / input type to make. + * @param string $method Method name / input type to make. * @param array $params Parameters for the method call * @return string Formatted input method. + * @throws CakeException When there are no params for the method call. */ public function __call($method, $params) { $options = array(); if (empty($params)) { - throw new Exception(__('Missing field name for FormHelper::%s', $method)); + throw new CakeException(__('Missing field name for FormHelper::%s', $method)); } if (isset($params[1])) { $options = $params[1]; diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index 5816c6b6a74..11b897226bb 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -87,7 +87,7 @@ class PaginatorHelper extends AppHelper { * * @param View $View the view object the helper is attached to. * @param array $settings Array of settings. - * @return void + * @throws CakeException When the AjaxProvider helper does not implement a link method. */ function __construct(View $View, $settings = array()) { parent::__construct($View, $settings); @@ -99,7 +99,7 @@ function __construct(View $View, $settings = array()) { } $classname = $ajaxProvider . 'Helper'; if (!method_exists($classname, 'link')) { - throw new Exception(sprintf( + throw new CakeException(sprintf( __('%s does not implement a link() method, it is incompatible with PaginatorHelper'), $classname )); } diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index a3221c7613d..af035292f4b 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -385,6 +385,7 @@ public function element($name, $params = array(), $callbacks = false) { * @param string $layout Layout to use * @param string $file Custom filename for view * @return string Rendered Element + * @throws CakeException if there is an error in the view. */ public function render($action = null, $layout = null, $file = null) { if ($this->hasRendered) { @@ -409,7 +410,7 @@ public function render($action = null, $layout = null, $file = null) { $layout = $this->layout; } if ($this->output === false) { - throw new RuntimeException(__("Error in view %s, got no content.", $viewFileName)); + throw new CakeException(__("Error in view %s, got no content.", $viewFileName)); } if ($layout && $this->autoLayout) { $this->output = $this->renderLayout($this->output, $layout); @@ -428,6 +429,7 @@ public function render($action = null, $layout = null, $file = null) { * * @param string $content_for_layout Content to render in a view, wrapped by the surrounding layout. * @return mixed Rendered output, or false on error + * @throws CakeException if there is an error in the view. */ public function renderLayout($content_for_layout, $layout = null) { $layoutFileName = $this->_getLayoutFileName($layout); @@ -451,7 +453,7 @@ public function renderLayout($content_for_layout, $layout = null) { $this->output = $this->_render($layoutFileName); if ($this->output === false) { - throw new RuntimeException(__("Error in layout %s, got no content.", $layoutFileName)); + throw new CakeException(__("Error in layout %s, got no content.", $layoutFileName)); } $this->Helpers->trigger('afterLayout', array($layoutFileName)); diff --git a/cake/libs/xml.php b/cake/libs/xml.php index 42097597a5a..160572b951a 100644 --- a/cake/libs/xml.php +++ b/cake/libs/xml.php @@ -73,7 +73,7 @@ class Xml { * @param mixed $input XML string, a path to a file, an URL or an array * @param array $options The options to use * @return object SimpleXMLElement or DOMDocument - * @throws Exception + * @throws XmlException */ public static function build($input, $options = array()) { if (!is_array($options)) { @@ -101,9 +101,9 @@ public static function build($input, $options = array()) { $dom->load($input); return $dom; } elseif (!is_string($input)) { - throw new Exception(__('Invalid input.')); + throw new XmlException(__('Invalid input.')); } - throw new Exception(__('XML cannot be read.')); + throw new XmlException(__('XML cannot be read.')); } /** @@ -141,14 +141,15 @@ public static function build($input, $options = array()) { * @param array $input Array with data * @param array $options The options to use * @return object SimpleXMLElement or DOMDocument + * @throws XmlException */ public static function fromArray($input, $options = array()) { if (!is_array($input) || count($input) !== 1) { - throw new Exception(__('Invalid input.')); + throw new XmlException(__('Invalid input.')); } $key = key($input); if (is_integer($key)) { - throw new Exception(__('The key of input must be alphanumeric')); + throw new XmlException(__('The key of input must be alphanumeric')); } if (!is_array($options)) { @@ -212,7 +213,7 @@ protected function _fromArray(&$dom, &$node, &$data, $format) { } } else { if ($key[0] === '@') { - throw new Exception(__('Invalid array')); + throw new XmlException(__('Invalid array')); } if (array_keys($value) === range(0, count($value) - 1)) { // List foreach ($value as $item) { @@ -225,7 +226,7 @@ protected function _fromArray(&$dom, &$node, &$data, $format) { } } } else { - throw new Exception(__('Invalid array')); + throw new XmlException(__('Invalid array')); } } } @@ -270,13 +271,14 @@ private function __createChild($data) { * * @param object $obj SimpleXMLElement, DOMDocument or DOMNode instance * @return array Array representation of the XML structure. + * @throws XmlException */ public static function toArray($obj) { if ($obj instanceof DOMNode) { $obj = simplexml_import_dom($obj); } if (!($obj instanceof SimpleXMLElement)) { - throw new Exception(__('The input is not instance of SimpleXMLElement, DOMDocument or DOMNode.')); + throw new XmlException(__('The input is not instance of SimpleXMLElement, DOMDocument or DOMNode.')); } $result = array(); $namespaces = array_merge(array('' => ''), $obj->getNamespaces(true)); diff --git a/cake/tests/cases/console/libs/console_option_parser.test.php b/cake/tests/cases/console/libs/console_option_parser.test.php index 656f3317a33..e010bbaf40c 100644 --- a/cake/tests/cases/console/libs/console_option_parser.test.php +++ b/cake/tests/cases/console/libs/console_option_parser.test.php @@ -230,7 +230,7 @@ function testOptionWithBooleanParam() { /** * test parsing options that do not exist. * - * @expectedException InvalidArgumentException + * @expectedException ConsoleException */ function testOptionThatDoesNotExist() { $parser = new ConsoleOptionParser('test', false); @@ -242,7 +242,7 @@ function testOptionThatDoesNotExist() { /** * test that options with choices enforce them. * - * @expectedException InvalidArgumentException + * @expectedException ConsoleException * @return void */ function testOptionWithChoices() { @@ -297,7 +297,7 @@ function testPositionalArgOverwrite() { /** * test parsing arguments. * - * @expectedException InvalidArgumentException + * @expectedException ConsoleException * @return void */ function testParseArgumentTooMany() { @@ -315,7 +315,7 @@ function testParseArgumentTooMany() { /** * test that when there are not enough arguments an exception is raised * - * @expectedException RuntimeException + * @expectedException ConsoleException * @return void */ function testPositionalArgNotEnough() { @@ -329,7 +329,7 @@ function testPositionalArgNotEnough() { /** * test that arguments with choices enforce them. * - * @expectedException InvalidArgumentException + * @expectedException ConsoleException * @return void */ function testPositionalArgWithChoices() { diff --git a/cake/tests/cases/libs/cake_log.test.php b/cake/tests/cases/libs/cake_log.test.php index 52c5c5abc32..72fe1e8e8b6 100644 --- a/cake/tests/cases/libs/cake_log.test.php +++ b/cake/tests/cases/libs/cake_log.test.php @@ -17,7 +17,7 @@ * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Log'); +App::import('Core', 'CakeLog'); App::import('Core', 'log/FileLog'); /** @@ -70,7 +70,7 @@ function testImportingLoggers() { /** * test all the errors from failed logger imports * - * @expectedException Exception + * @expectedException CakeLogException * @return void */ function testImportingLoggerFailure() { @@ -80,7 +80,7 @@ function testImportingLoggerFailure() { /** * test that loggers have to implement the correct interface. * - * @expectedException Exception + * @expectedException CakeLogException * @return void */ function testNotImplementingInterface() { diff --git a/cake/tests/cases/libs/cake_request.test.php b/cake/tests/cases/libs/cake_request.test.php index af4ad93cb59..f423ac19d79 100644 --- a/cake/tests/cases/libs/cake_request.test.php +++ b/cake/tests/cases/libs/cake_request.test.php @@ -17,9 +17,7 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -if (!class_exists('dispatcher')) { - require CAKE . 'dispatcher.php'; -} +App::import('Core', 'Dispatcher'); App::import('Core', 'CakeRequest'); class CakeRequestTestCase extends CakeTestCase { @@ -614,7 +612,7 @@ function testisAjaxFlashAndFriends() { /** * test __call expcetions * - * @expectedException Exception + * @expectedException CakeException * @return void */ function test__callExceptionOnUnknownMethod() { diff --git a/cake/tests/cases/libs/cake_response.test.php b/cake/tests/cases/libs/cake_response.test.php index eee0cfc695e..d0d2a9e5845 100644 --- a/cake/tests/cases/libs/cake_response.test.php +++ b/cake/tests/cases/libs/cake_response.test.php @@ -55,7 +55,7 @@ public function testCharset() { /** * Tests the statusCode method * -* @expectedException OutOfRangeException +* @expectedException CakeException */ public function testStatusCode() { $response = new CakeResponse(); diff --git a/cake/tests/cases/libs/cake_session.test.php b/cake/tests/cases/libs/cake_session.test.php index 51d37dc146f..02fda57e7c8 100644 --- a/cake/tests/cases/libs/cake_session.test.php +++ b/cake/tests/cases/libs/cake_session.test.php @@ -367,7 +367,7 @@ function testDelete() { /** * testWatchVar method * - * @expectedException Exception + * @expectedException CakeSessionException * @access public * @return void */ @@ -380,16 +380,16 @@ function testWatchVarWrite() { } /** - * undocumented function + * Test that deleting watched vars causes exceptions * - * @expectedException Exception + * @expectedException CakeSessionException * @return void */ function testWatchVarDelete() { + TestCakeSession::write('Watching', 'I am watching you.'); + TestCakeSession::watch('Watching'); TestCakeSession::delete('Watching'); - - $this->assertFalse(TestCakeSession::watch('Invalid.key')); } /** diff --git a/cake/tests/cases/libs/config/php_reader.test.php b/cake/tests/cases/libs/config/php_reader.test.php index 53898f97f40..539f56666e9 100644 --- a/cake/tests/cases/libs/config/php_reader.test.php +++ b/cake/tests/cases/libs/config/php_reader.test.php @@ -44,7 +44,7 @@ function testRead() { /** * Test an exception is thrown by reading files that don't exist. * - * @expectedException RuntimeException + * @expectedException ConfigureException * @return void */ function testReadWithNonExistantFile() { @@ -66,7 +66,7 @@ function testReadEmptyFile() { /** * test reading keys with ../ doesn't work * - * @expectedException InvalidArgumentException + * @expectedException ConfigureException * @return void */ function testReadWithDots() { diff --git a/cake/tests/cases/libs/controller/components/acl.test.php b/cake/tests/cases/libs/controller/components/acl.test.php index 600b690691d..544ff44b1aa 100644 --- a/cake/tests/cases/libs/controller/components/acl.test.php +++ b/cake/tests/cases/libs/controller/components/acl.test.php @@ -218,7 +218,7 @@ function tearDown() { * test that construtor throws an exception when Acl.classname is a * non-existant class * - * @expectedException Exception + * @expectedException CakeException * @return void */ function testConstrutorException() { @@ -243,7 +243,7 @@ function testAdapter() { /** * test that adapter() whines when the class is not an AclBase * - * @expectedException Exception + * @expectedException CakeException * @return void */ function testAdapterException() { diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index a5a37bb7e88..143570711b2 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -6700,7 +6700,7 @@ function testHtml5Inputs() { /** * - * @expectedException Exception + * @expectedException CakeException * @return void */ function testHtml5InputException() {