diff --git a/cake/VERSION.txt b/cake/VERSION.txt index 1f0f7116b..e5c64475c 100644 --- a/cake/VERSION.txt +++ b/cake/VERSION.txt @@ -18,7 +18,8 @@ // @license MIT License (http://www.opensource.org/licenses/mit-license.php) // +--------------------------------------------------------------------------------------------+ // //////////////////////////////////////////////////////////////////////////////////////////////////// -1.3.5 +1.3.6 + diff --git a/cake/basics.php b/cake/basics.php index 602bec763..c41301ea1 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -264,14 +264,14 @@ if (!function_exists('sortByKey')) { * @link http://book.cakephp.org/view/1130/env */ function env($key) { - if ($key == 'HTTPS') { + if ($key === 'HTTPS') { if (isset($_SERVER['HTTPS'])) { return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'); } return (strpos(env('SCRIPT_URI'), 'https://') === 0); } - if ($key == 'SCRIPT_NAME') { + if ($key === 'SCRIPT_NAME') { if (env('CGI_MODE') && isset($_ENV['SCRIPT_URL'])) { $key = 'SCRIPT_URL'; } diff --git a/cake/config/config.php b/cake/config/config.php index a36b17f9d..071441c21 100644 --- a/cake/config/config.php +++ b/cake/config/config.php @@ -17,4 +17,4 @@ * @since CakePHP(tm) v 1.1.11.4062 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -return $config['Cake.version'] = '1.3.5'; +return $config['Cake.version'] = '1.3.6'; diff --git a/cake/console/cake.php b/cake/console/cake.php index 2db99284e..02468c38f 100644 --- a/cake/console/cake.php +++ b/cake/console/cake.php @@ -23,3 +23,4 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR. 'shell_dispatcher.php'); return ShellDispatcher::run($argv); + diff --git a/cake/console/libs/help_formatter.php b/cake/console/libs/help_formatter.php index 7af4cadf1..002689899 100644 --- a/cake/console/libs/help_formatter.php +++ b/cake/console/libs/help_formatter.php @@ -17,6 +17,8 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::import('Core', 'String', false); + /** * HelpFormatter formats help for console shells. Can format to either * text or XML formats. Uses ConsoleOptionParser methods to generate help. diff --git a/cake/console/shells/app_shell.php b/cake/console/shells/app_shell.php new file mode 100644 index 000000000..59fcc2a09 --- /dev/null +++ b/cake/console/shells/app_shell.php @@ -0,0 +1,33 @@ +connection to the active task if a connection param is set. * */ public function startup() { @@ -121,7 +128,6 @@ class BakeShell extends Shell { * */ public function all() { - $this->hr(); $this->out('Bake All'); $this->hr(); @@ -156,7 +162,6 @@ class BakeShell extends Shell { $modelBaked = $this->Model->bake($object, false); if ($modelBaked && $modelExists === false) { - $this->out(sprintf(__('%s Model was baked.'), $model)); if ($this->_checkUnitTest()) { $this->Model->bakeFixture($model); $this->Model->bakeTest($model); @@ -167,7 +172,6 @@ class BakeShell extends Shell { if ($modelExists === true) { $controller = $this->_controllerName($name); if ($this->Controller->bake($controller, $this->Controller->bakeActions($controller))) { - $this->out(sprintf(__('%s Controller was baked.'), $name)); if ($this->_checkUnitTest()) { $this->Controller->bakeTest($controller); } @@ -175,9 +179,9 @@ class BakeShell extends Shell { if (App::import('Controller', $controller)) { $this->View->args = array($controller); $this->View->execute(); - $this->out(sprintf(__('%s Views were baked.'), $name)); } - $this->out(__('Bake All complete')); + $this->out('', 1, Shell::QUIET); + $this->out(__('Bake All complete'), 1, Shell::QUIET); array_shift($this->args); } else { $this->error(__('Bake All could not continue without a valid model')); diff --git a/cake/console/shells/command_list.php b/cake/console/shells/command_list.php index 613f65dd7..cd05af4ba 100644 --- a/cake/console/shells/command_list.php +++ b/cake/console/shells/command_list.php @@ -111,7 +111,7 @@ class CommandListShell extends Shell { continue; } foreach ($shells as $shell) { - if ($shell !== 'shell.php') { + if ($shell !== 'shell.php' && $shell !== 'app_shell.php') { $shell = str_replace('.php', '', $shell); $shellList[$shell][$type] = $type; } diff --git a/cake/console/shells/shell.php b/cake/console/shells/shell.php index 8ce538105..11cb62d11 100644 --- a/cake/console/shells/shell.php +++ b/cake/console/shells/shell.php @@ -164,6 +164,14 @@ class Shell extends Object { if ($this->stdin == null) { $this->stdin = new ConsoleInput('php://stdin'); } + + $parent = get_parent_class($this); + if ($this->tasks !== null && $this->tasks !== false) { + $this->_mergeVars(array('tasks'), $parent, true); + } + if ($this->uses !== null && $this->uses !== false) { + $this->_mergeVars(array('uses'), $parent, false); + } } /** diff --git a/cake/console/shells/tasks/controller.php b/cake/console/shells/tasks/controller.php index e88dc2059..f56f55d3b 100644 --- a/cake/console/shells/tasks/controller.php +++ b/cake/console/shells/tasks/controller.php @@ -302,6 +302,8 @@ class ControllerTask extends BakeTask { * @return string Baked controller */ public function bake($controllerName, $actions = '', $helpers = null, $components = null) { + $this->out("\nBaking controller class for $controllerName...", 1, Shell::QUIET); + $isScaffold = ($actions === 'scaffold') ? true : false; $this->Template->set('plugin', Inflector::camelize($this->plugin)); diff --git a/cake/console/shells/tasks/fixture.php b/cake/console/shells/tasks/fixture.php index 1313ab1dd..333359121 100644 --- a/cake/console/shells/tasks/fixture.php +++ b/cake/console/shells/tasks/fixture.php @@ -254,7 +254,7 @@ class FixtureTask extends BakeTask { $this->Template->set($vars); $content = $this->Template->generate('classes', 'fixture'); - $this->out("\nBaking test fixture for $model..."); + $this->out("\nBaking test fixture for $model...", 1, Shell::QUIET); $this->createFile($path . $filename, $content); return $content; } diff --git a/cake/console/shells/tasks/model.php b/cake/console/shells/tasks/model.php index 7e8de3e36..6abd25344 100644 --- a/cake/console/shells/tasks/model.php +++ b/cake/console/shells/tasks/model.php @@ -742,7 +742,7 @@ class ModelTask extends BakeTask { $path = $this->getPath(); $filename = $path . Inflector::underscore($name) . '.php'; - $this->out("\nBaking model class for $name..."); + $this->out("\nBaking model class for $name...", 1, Shell::QUIET); $this->createFile($filename, $out); ClassRegistry::flush(); return $out; diff --git a/cake/console/shells/tasks/test.php b/cake/console/shells/tasks/test.php index bb277bbcc..173a65079 100644 --- a/cake/console/shells/tasks/test.php +++ b/cake/console/shells/tasks/test.php @@ -115,7 +115,7 @@ class TestTask extends BakeTask { */ public function bake($type, $className) { if ($this->typeCanDetectFixtures($type) && $this->isLoadableClass($type, $className)) { - $this->out(__('Bake is detecting possible fixtures..')); + $this->out(__('Bake is detecting possible fixtures...')); $testSubject = $this->buildTestSubject($type, $className); $this->generateFixtureList($testSubject); } elseif ($this->interactive) { @@ -134,6 +134,7 @@ class TestTask extends BakeTask { if ($this->plugin) { $plugin = $this->plugin . '.'; } + $this->out("\nBaking test case for $className $type...", 1, Shell::QUIET); $this->Template->set('fixtures', $this->_fixtures); $this->Template->set('plugin', $plugin); diff --git a/cake/console/shells/tasks/view.php b/cake/console/shells/tasks/view.php index 2acbfdeaa..14d67b7fe 100644 --- a/cake/console/shells/tasks/view.php +++ b/cake/console/shells/tasks/view.php @@ -366,6 +366,7 @@ class ViewTask extends BakeTask { if (empty($content)) { return false; } + $this->out("\nBaking `$action` view file...", 1, Shell::QUIET); $path = $this->getPath(); $filename = $path . $this->controllerPath . DS . Inflector::underscore($action) . '.ctp'; return $this->createFile($filename, $content); diff --git a/cake/console/shells/testsuite.php b/cake/console/shells/testsuite.php index dacf09dd0..67f2743d5 100644 --- a/cake/console/shells/testsuite.php +++ b/cake/console/shells/testsuite.php @@ -56,7 +56,7 @@ class TestSuiteShell extends Shell { ))->addOption('log-dbus', array( 'help' => __('Log test execution to DBUS.'), 'default' => false - ))->addOption('--coverage-html', array( + ))->addOption('coverage-html', array( 'help' => __(' Generate code coverage report in HTML format.'), 'default' => false ))->addOption('coverage-clover', array( @@ -280,8 +280,7 @@ class TestSuiteShell extends Shell { if (empty($testCases)) { $this->out(__("No test cases available \n\n")); - $this->help(); - $this->_stop(); + return $this->out($this->OptionParser->help()); } $this->out($title); diff --git a/cake/libs/app.php b/cake/libs/app.php index 4261447b7..2812219c1 100644 --- a/cake/libs/app.php +++ b/cake/libs/app.php @@ -324,9 +324,6 @@ class App { */ public static function core($type = null) { static $paths = false; - if ($paths === false) { - $paths = Cache::read('core_paths', '_cake_core_'); - } if (!$paths) { $paths = array(); $libs = dirname(__FILE__) . DS; @@ -347,8 +344,6 @@ class App { $paths['shells'][] = $cake . 'console' . DS . 'shells' . DS; // Provide BC path to vendors/shells $paths['shells'][] = $path . 'vendors' . DS . 'shells' . DS; - - Cache::write('core_paths', array_filter($paths), '_cake_core_'); } if ($type && isset($paths[$type])) { return $paths[$type]; @@ -513,8 +508,6 @@ class App { if ($name != null && !class_exists($name . $ext['class'])) { if ($load = self::__mapped($name . $ext['class'], $type, $plugin)) { if (self::__load($load)) { - self::__overload($type, $name . $ext['class'], $parent); - if (self::$return) { return include($load); } @@ -554,7 +547,6 @@ class App { if ($directory !== null) { self::$__cache = true; self::__map($directory . $file, $name . $ext['class'], $type, $plugin); - self::__overload($type, $name . $ext['class'], $parent); if (self::$return) { return include($directory . $file); @@ -696,17 +688,6 @@ class App { return false; } -/** - * Used to overload objects as needed. - * - * @param string $type Model or Helper - * @param string $name Class name to overload - * @access private - */ - private static function __overload($type, $name, $parent) { - - } - /** * Loads parent classes based on $type. * Returns a prefix or suffix needed for loading files. @@ -796,6 +777,9 @@ class App { if (!class_exists('Shell')) { App::import($type, 'Shell', false); } + if (!class_exists('AppShell')) { + App::import($type, 'AppShell', false); + } if ($plugin) { $path = $pluginPath . DS . 'console' . DS . 'shells' . DS; } diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 993cecf44..e91351874 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -520,7 +520,6 @@ class AuthComponent extends Component { $valid = $this->Acl->check($user, $this->action()); break; case 'crud': - $this->mapActions(); if (!isset($this->actionMap[$this->request['action']])) { trigger_error( sprintf(__('Auth::startup() - Attempted access of un-mapped action "%1$s" in controller "%2$s"'), $this->request['action'], $this->request['controller']), @@ -535,7 +534,6 @@ class AuthComponent extends Component { } break; case 'model': - $this->mapActions(); $action = $this->request['action']; if (isset($this->actionMap[$action])) { $action = $this->actionMap[$action]; diff --git a/cake/libs/controller/components/security.php b/cake/libs/controller/components/security.php index e4db0ceb5..da7f86e67 100644 --- a/cake/libs/controller/components/security.php +++ b/cake/libs/controller/components/security.php @@ -618,10 +618,15 @@ class SecurityComponent extends Component { } unset($check['_Token']); + $locked = str_rot13($locked); + if (preg_match('/(\A|;|{|})O\:[0-9]+/', $locked)) { + return false; + } + $lockedFields = array(); $fields = Set::flatten($check); $fieldList = array_keys($fields); - $locked = unserialize(str_rot13($locked)); + $locked = unserialize($locked); $multi = array(); foreach ($fieldList as $i => $key) { diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index bfe4c7fc1..d4341655b 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -415,23 +415,21 @@ class Controller extends Object { * @return void */ protected function __mergeVars() { - $pluginName = Inflector::camelize($this->plugin); - $pluginController = $pluginName . 'AppController'; + $pluginName = $pluginController = $plugin = null; - if (is_subclass_of($this, 'AppController') || is_subclass_of($this, $pluginController)) { + if (!empty($this->plugin)) { + $pluginName = Inflector::camelize($this->plugin); + $pluginController = $pluginName . 'AppController'; + if (!is_subclass_of($this, $pluginController)) { + $pluginController = null; + } + $plugin = $pluginName . '.'; + } + + if (is_subclass_of($this, 'AppController') || !empty($pluginController)) { $appVars = get_class_vars('AppController'); $uses = $appVars['uses']; $merge = array('components', 'helpers'); - $plugin = null; - - if (!empty($this->plugin)) { - $plugin = $pluginName . '.'; - if (!is_subclass_of($this, $pluginController)) { - $pluginController = null; - } - } else { - $pluginController = null; - } if ($uses == $this->uses && !empty($this->uses)) { if (!in_array($plugin . $this->modelClass, $this->uses)) { @@ -443,50 +441,18 @@ class Controller extends Object { array_unshift($this->uses, $plugin . $this->modelClass); } } elseif ($this->uses !== null || $this->uses !== false) { - $merge[] = 'uses'; - } - - foreach ($merge as $var) { - if (!empty($appVars[$var]) && is_array($this->{$var})) { - if ($var === 'components') { - $normal = Set::normalize($this->{$var}); - $app = Set::normalize($appVars[$var]); - if ($app !== $normal) { - $this->{$var} = Set::merge($app, $normal); - } - } else { - $this->{$var} = Set::merge( - $this->{$var}, array_diff($appVars[$var], $this->{$var}) - ); - } - } + $this->_mergeVars(array('uses'), 'AppController', false); } + $this->_mergeVars($merge, 'AppController', true); } if ($pluginController && $pluginName != null) { - $appVars = get_class_vars($pluginController); - $uses = $appVars['uses']; $merge = array('components', 'helpers'); if ($this->uses !== null || $this->uses !== false) { - $merge[] = 'uses'; - } - - foreach ($merge as $var) { - if (isset($appVars[$var]) && !empty($appVars[$var]) && is_array($this->{$var})) { - if ($var === 'components') { - $normal = Set::normalize($this->{$var}); - $app = Set::normalize($appVars[$var]); - if ($app !== $normal) { - $this->{$var} = Set::merge($app, $normal); - } - } else { - $this->{$var} = Set::merge( - $this->{$var}, array_diff($appVars[$var], $this->{$var}) - ); - } - } + $this->_mergeVars(array('uses'), $pluginController, false); } + $this->_mergeVars($merge, $pluginController); } } diff --git a/cake/libs/folder.php b/cake/libs/folder.php index 8a470cbd5..36cba374b 100644 --- a/cake/libs/folder.php +++ b/cake/libs/folder.php @@ -244,7 +244,7 @@ class Folder { * @static */ function isWindowsPath($path) { - return (bool)preg_match('/^[A-Z]:\\\\/i', $path); + return (preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\'); } /** @@ -256,7 +256,7 @@ class Folder { * @static */ function isAbsolute($path) { - return !empty($path) && ($path[0] === '/' || preg_match('/^[A-Z]:\\\\/i', $path)); + return !empty($path) && ($path[0] === '/' || preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\'); } /** diff --git a/cake/libs/i18n.php b/cake/libs/i18n.php index cbc84801f..d12cbb3dc 100644 --- a/cake/libs/i18n.php +++ b/cake/libs/i18n.php @@ -139,11 +139,11 @@ class I18n { $_this->domain = $domain . '_' . $_this->l10n->lang; - if (empty($_this->__domains[$domain][$_this->__lang])) { + if (!isset($_this->__domains[$domain][$_this->__lang])) { $_this->__domains[$domain][$_this->__lang] = Cache::read($_this->domain, '_cake_core_'); } - if (empty($_this->__domains[$domain][$_this->__lang][$_this->category])) { + if (!isset($_this->__domains[$domain][$_this->__lang][$_this->category])) { $_this->__bindTextDomain($domain); Cache::write($_this->domain, $_this->__domains[$domain][$_this->__lang], '_cake_core_'); } diff --git a/cake/libs/log/file_log.php b/cake/libs/log/file_log.php index ab319fc33..fbd4cff3e 100644 --- a/cake/libs/log/file_log.php +++ b/cake/libs/log/file_log.php @@ -67,9 +67,6 @@ class FileLog implements CakeLogInterface { $filename = $this->_path . $type . '.log'; } $output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $message . "\n"; - $log = new SplFileObject($filename, 'a+'); - if ($log->isWritable()) { - return $log->fwrite($output); - } + return file_put_contents($filename, $output, FILE_APPEND); } } diff --git a/cake/libs/model/behavior_collection.php b/cake/libs/model/behavior_collection.php index 9820d568b..3ce783c76 100644 --- a/cake/libs/model/behavior_collection.php +++ b/cake/libs/model/behavior_collection.php @@ -64,8 +64,8 @@ class BehaviorCollection extends ObjectCollection { $this->modelName = $modelName; if (!empty($behaviors)) { - foreach (Set::normalize($behaviors) as $behavior => $config) { - $this->load($behavior, $config); + foreach (BehaviorCollection::normalizeObjectArray($behaviors) as $behavior => $config) { + $this->load($config['class'], $config['settings']); } } } diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index d6954b97d..551a9ea6c 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -438,27 +438,15 @@ class Model extends Object { } if (is_subclass_of($this, 'AppModel')) { - $appVars = get_class_vars('AppModel'); $merge = array('_findMethods'); - if ($this->actsAs !== null || $this->actsAs !== false) { $merge[] = 'actsAs'; } $parentClass = get_parent_class($this); - if (strtolower($parentClass) !== 'appmodel') { - $parentVars = get_class_vars($parentClass); - foreach ($merge as $var) { - if (isset($parentVars[$var]) && !empty($parentVars[$var])) { - $appVars[$var] = Set::merge($appVars[$var], $parentVars[$var]); - } - } - } - - foreach ($merge as $var) { - if (isset($appVars[$var]) && !empty($appVars[$var]) && is_array($this->{$var})) { - $this->{$var} = Set::merge($appVars[$var], $this->{$var}); - } + if ($parentClass !== 'AppModel') { + $this->_mergeVars($merge, $parentClass); } + $this->_mergeVars($merge, 'AppModel'); } $this->Behaviors = new BehaviorCollection(); @@ -629,9 +617,9 @@ class Model extends Object { * * Example: Turn off the associated Model Support request, * to temporarily lighten the User model: - * + * * `$this->User->unbindModel( array('hasMany' => array('Supportrequest')) );` - * + * * unbound models that are not made permanent will reset with the next call to Model::find() * * @param array $params Set of bindings to unbind (indexed by binding type) @@ -1631,7 +1619,7 @@ class Model extends Object { } if ($options['atomic'] && $options['validate'] !== 'only') { - $db->begin($this); + $transactionBegun = $db->begin($this); } if (Set::numeric(array_keys($data))) { @@ -1671,8 +1659,12 @@ class Model extends Object { break; default: if ($options['atomic']) { - if ($validates && ($db->commit($this) !== false)) { - return true; + if ($validates) { + if ($transactionBegun) { + return $db->commit($this) !== false; + } else { + return true; + } } $db->rollback($this); return false; @@ -1782,7 +1774,11 @@ class Model extends Object { default: if ($options['atomic']) { if ($validates) { - return ($db->commit($this) !== false); + if ($transactionBegun) { + return $db->commit($this) !== false; + } else { + return true; + } } else { $db->rollback($this); } @@ -1865,7 +1861,7 @@ class Model extends Object { )); } - if ($db->delete($this)) { + if ($db->delete($this, array($this->alias . '.' . $this->primaryKey => $id))) { if (!empty($this->belongsTo)) { $this->updateCounterCache($keys[$this->alias]); } diff --git a/cake/libs/object.php b/cake/libs/object.php index 036917c1c..0f1d49030 100644 --- a/cake/libs/object.php +++ b/cake/libs/object.php @@ -198,6 +198,36 @@ class Object { } } +/** + * Merges this objects $property with the property in $class' definition. + * This classes value for the property will be merged on top of $class' + * + * This provides some of the DRY magic CakePHP provides. If you want to shut it off, redefine + * this method as an empty function. + * + * @param array $properties The name of the properties to merge. + * @param sting $class The class to merge the property with. + * @param boolean $normalize Set to true to run the properties through Set::normalize() before merging. + * @return void + */ + protected function _mergeVars($properties, $class, $normalize = true) { + $classProperties = get_class_vars($class); + foreach ($properties as $var) { + if ( + isset($classProperties[$var]) && + !empty($classProperties[$var]) && + is_array($this->{$var}) && + $this->{$var} != $classProperties[$var] + ) { + if ($normalize) { + $classProperties[$var] = Set::normalize($classProperties[$var]); + $this->{$var} = Set::normalize($this->{$var}); + } + $this->{$var} = Set::merge($classProperties[$var], $this->{$var}); + } + } + } + /** * You should choose a unique name for the persistent file * diff --git a/cake/libs/view/helper.php b/cake/libs/view/helper.php index 68466a25f..20e41953c 100644 --- a/cake/libs/view/helper.php +++ b/cake/libs/view/helper.php @@ -355,14 +355,13 @@ class Helper extends Object { if (!is_array($exclude)) { $exclude = array(); } - $keys = array_diff(array_keys($options), array_merge($exclude, array('escape'))); - $values = array_intersect_key(array_values($options), $keys); + $filtered = array_diff_key($options, array_merge(array_flip($exclude), array('escape' => true))); $escape = $options['escape']; $attributes = array(); - foreach ($keys as $index => $key) { - if ($values[$index] !== false && $values[$index] !== null) { - $attributes[] = $this->__formatAttribute($key, $values[$index], $escape); + foreach ($filtered as $key => $value) { + if ($value !== false && $value !== null) { + $attributes[] = $this->__formatAttribute($key, $value, $escape); } } $out = implode(' ', $attributes); diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index d48e0b94e..b347b69ed 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -218,7 +218,8 @@ class FormHelper extends AppHelper { $data = $this->fieldset[$modelEntity]; $recordExists = ( isset($this->request->data[$model]) && - !empty($this->request->data[$model][$data['key']]) + !empty($this->request->data[$model][$data['key']]) && + !is_array($this->request->data[$model][$data['key']]) ); if ($recordExists) { diff --git a/cake/libs/view/helpers/number.php b/cake/libs/view/helpers/number.php index 7bbed96d5..b7d612471 100644 --- a/cake/libs/view/helpers/number.php +++ b/cake/libs/view/helpers/number.php @@ -48,7 +48,7 @@ class NumberHelper extends AppHelper { 'decimals' => '.', 'negative' => '()','escape' => false ), 'EUR' => array( - 'before'=>'€', 'after' => 'c', 'zero' => 0, 'places' => 2, 'thousands' => '.', + 'before'=>'€', 'after' => false, 'zero' => 0, 'places' => 2, 'thousands' => '.', 'decimals' => ',', 'negative' => '()', 'escape' => false ) ); diff --git a/cake/libs/view/pages/home.ctp b/cake/libs/view/pages/home.ctp index 6a1c67065..c8939c85e 100644 --- a/cake/libs/view/pages/home.ctp +++ b/cake/libs/view/pages/home.ctp @@ -21,7 +21,7 @@ if (Configure::read() == 0): endif; ?>

- + 0): Debugger::checkSecurityKeys(); diff --git a/cake/tests/cases/console/libs/shell.test.php b/cake/tests/cases/console/shells/shell.test.php similarity index 95% rename from cake/tests/cases/console/libs/shell.test.php rename to cake/tests/cases/console/shells/shell.test.php index 51a3479d3..ff341468b 100644 --- a/cake/tests/cases/console/libs/shell.test.php +++ b/cake/tests/cases/console/shells/shell.test.php @@ -69,6 +69,20 @@ class TestShell extends Shell { protected function no_access() { } + + public function mergeVars($properties, $class, $normalize = true) { + return $this->_mergeVars($properties, $class, $normalize); + } +} + +/** + * Class for testing merging vars + * + * @package cake.tests.cases.console + */ +class TestMergeShell extends Shell { + var $tasks = array('DbConfig', 'Fixture'); + var $uses = array('Comment'); } /** @@ -134,6 +148,25 @@ class ShellTest extends CakeTestCase { $this->assertType('ConsoleOutput', $this->Shell->stderr); } +/** + * test merging vars + * + * @return void + */ + function testMergeVars() { + $this->Shell->tasks = array('DbConfig' => array('one', 'two')); + $this->Shell->uses = array('Posts'); + $this->Shell->mergeVars(array('tasks'), 'TestMergeShell'); + $this->Shell->mergeVars(array('uses'), 'TestMergeShell', false); + + $expected = array('DbConfig' => null, 'Fixture' => null, 'DbConfig' => array('one', 'two')); + $this->assertEquals($expected, $this->Shell->tasks); + + $expected = array('Fixture' => null, 'DbConfig' => array('one', 'two')); + $this->assertEquals($expected, Set::normalize($this->Shell->tasks), 'Normalized results are wrong.'); + $this->assertEquals(array('Comment', 'Posts'), $this->Shell->uses, 'Merged models are wrong.'); + } + /** * testInitialize method * diff --git a/cake/tests/cases/console/shells/tasks/controller.test.php b/cake/tests/cases/console/shells/tasks/controller.test.php index 61d00b4f1..f3601376e 100644 --- a/cake/tests/cases/console/shells/tasks/controller.test.php +++ b/cake/tests/cases/console/shells/tasks/controller.test.php @@ -304,11 +304,11 @@ class ControllerTaskTest extends CakeTestCase { $path = APP . 'plugins' . DS . 'controller_test' . DS . 'controllers' . DS . 'articles_controller.php'; - $this->Task->expects($this->at(0))->method('createFile')->with( + $this->Task->expects($this->at(1))->method('createFile')->with( $path, new PHPUnit_Framework_Constraint_IsAnything() ); - $this->Task->expects($this->at(1))->method('createFile')->with( + $this->Task->expects($this->at(3))->method('createFile')->with( $path, new PHPUnit_Framework_Constraint_PCREMatch('/ArticlesController extends ControllerTestAppController/') ); diff --git a/cake/tests/cases/console/shells/tasks/model.test.php b/cake/tests/cases/console/shells/tasks/model.test.php index b2072fdeb..ac2a2c7fc 100644 --- a/cake/tests/cases/console/shells/tasks/model.test.php +++ b/cake/tests/cases/console/shells/tasks/model.test.php @@ -42,7 +42,10 @@ class ModelTaskTest extends CakeTestCase { * @var array * @access public */ - public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag', 'core.category_thread'); + public $fixtures = array( + 'core.bake_article', 'core.bake_comment', 'core.bake_articles_bake_tag', + 'core.bake_tag', 'core.category_thread' + ); /** * setUp method @@ -116,25 +119,25 @@ class ModelTaskTest extends CakeTestCase { } $this->_useMockedOut(); - $this->Task->expects($this->at(1))->method('out')->with('1. Article'); - $this->Task->expects($this->at(2))->method('out')->with('2. ArticlesTag'); - $this->Task->expects($this->at(3))->method('out')->with('3. CategoryThread'); - $this->Task->expects($this->at(4))->method('out')->with('4. Comment'); - $this->Task->expects($this->at(5))->method('out')->with('5. Tag'); + $this->Task->expects($this->at(1))->method('out')->with('1. BakeArticle'); + $this->Task->expects($this->at(2))->method('out')->with('2. BakeArticlesBakeTag'); + $this->Task->expects($this->at(3))->method('out')->with('3. BakeComment'); + $this->Task->expects($this->at(4))->method('out')->with('4. BakeTag'); + $this->Task->expects($this->at(5))->method('out')->with('5. CategoryThread'); - $this->Task->expects($this->at(7))->method('out')->with('1. Article'); - $this->Task->expects($this->at(8))->method('out')->with('2. ArticlesTag'); - $this->Task->expects($this->at(9))->method('out')->with('3. CategoryThread'); - $this->Task->expects($this->at(10))->method('out')->with('4. Comment'); - $this->Task->expects($this->at(11))->method('out')->with('5. Tag'); + $this->Task->expects($this->at(7))->method('out')->with('1. BakeArticle'); + $this->Task->expects($this->at(8))->method('out')->with('2. BakeArticlesBakeTag'); + $this->Task->expects($this->at(9))->method('out')->with('3. BakeComment'); + $this->Task->expects($this->at(10))->method('out')->with('4. BakeTag'); + $this->Task->expects($this->at(11))->method('out')->with('5. CategoryThread'); $result = $this->Task->listAll('test'); - $expected = array('articles', 'articles_tags', 'category_threads', 'comments', 'tags'); + $expected = array('bake_articles', 'bake_articles_bake_tags', 'bake_comments', 'bake_tags', 'category_threads'); $this->assertEqual($result, $expected); $this->Task->connection = 'test'; $result = $this->Task->listAll(); - $expected = array('articles', 'articles_tags', 'category_threads', 'comments', 'tags'); + $expected = array('bake_articles', 'bake_articles_bake_tags', 'bake_comments', 'bake_tags', 'category_threads'); $this->assertEqual($result, $expected); } @@ -155,20 +158,14 @@ class ModelTaskTest extends CakeTestCase { * @return void */ function testGetNameValidOption() { - $count = count($this->Task->listAll('test')); - if ($count != count($this->fixtures)) { - $this->markTestSkipped('Additional tables detected.'); - } - + $listing = $this->Task->listAll('test'); $this->Task->expects($this->any())->method('in')->will($this->onConsecutiveCalls(1, 4)); $result = $this->Task->getName('test'); - $expected = 'Article'; - $this->assertEqual($result, $expected); + $this->assertEquals(Inflector::classify($listing[0]), $result); $result = $this->Task->getName('test'); - $expected = 'Comment'; - $this->assertEqual($result, $expected); + $this->assertEquals(Inflector::classify($listing[3]), $result); } /** @@ -190,8 +187,8 @@ class ModelTaskTest extends CakeTestCase { */ public function testGetTableName() { $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y')); - $result = $this->Task->getTable('Article', 'test'); - $expected = 'articles'; + $result = $this->Task->getTable('BakeArticle', 'test'); + $expected = 'bake_articles'; $this->assertEqual($result, $expected); } @@ -202,7 +199,7 @@ class ModelTaskTest extends CakeTestCase { */ function testGetTableNameCustom() { $this->Task->expects($this->any())->method('in')->will($this->onConsecutiveCalls('n', 'my_table')); - $result = $this->Task->getTable('Article', 'test'); + $result = $this->Task->getTable('BakeArticle', 'test'); $expected = 'my_table'; $this->assertEqual($result, $expected); } @@ -419,19 +416,19 @@ class ModelTaskTest extends CakeTestCase { * @return void */ public function testBelongsToGeneration() { - $model = new Model(array('ds' => 'test', 'name' => 'Comment')); + $model = new Model(array('ds' => 'test', 'name' => 'BakeComment')); $result = $this->Task->findBelongsTo($model, array()); $expected = array( 'belongsTo' => array( array( - 'alias' => 'Article', - 'className' => 'Article', - 'foreignKey' => 'article_id', + 'alias' => 'BakeArticle', + 'className' => 'BakeArticle', + 'foreignKey' => 'bake_article_id', ), array( - 'alias' => 'User', - 'className' => 'User', - 'foreignKey' => 'user_id', + 'alias' => 'BakeUser', + 'className' => 'BakeUser', + 'foreignKey' => 'bake_user_id', ), ) ); @@ -457,23 +454,23 @@ class ModelTaskTest extends CakeTestCase { * @return void */ public function testHasManyHasOneGeneration() { - $model = new Model(array('ds' => 'test', 'name' => 'Article')); + $model = new Model(array('ds' => 'test', 'name' => 'BakeArticle')); $this->Task->connection = 'test'; $this->Task->listAll(); $result = $this->Task->findHasOneAndMany($model, array()); $expected = array( 'hasMany' => array( array( - 'alias' => 'Comment', - 'className' => 'Comment', - 'foreignKey' => 'article_id', + 'alias' => 'BakeComment', + 'className' => 'BakeComment', + 'foreignKey' => 'bake_article_id', ), ), 'hasOne' => array( array( - 'alias' => 'Comment', - 'className' => 'Comment', - 'foreignKey' => 'article_id', + 'alias' => 'BakeComment', + 'className' => 'BakeComment', + 'foreignKey' => 'bake_article_id', ), ), ); @@ -506,23 +503,18 @@ class ModelTaskTest extends CakeTestCase { * @return void */ public function testHasAndBelongsToManyGeneration() { - $count = count($this->Task->listAll('test')); - if ($count != count($this->fixtures)) { - $this->markTestSkipped('Additional tables detected.'); - } - - $model = new Model(array('ds' => 'test', 'name' => 'Article')); + $model = new Model(array('ds' => 'test', 'name' => 'BakeArticle')); $this->Task->connection = 'test'; $this->Task->listAll(); $result = $this->Task->findHasAndBelongsToMany($model, array()); $expected = array( 'hasAndBelongsToMany' => array( array( - 'alias' => 'Tag', - 'className' => 'Tag', - 'foreignKey' => 'article_id', - 'joinTable' => 'articles_tags', - 'associationForeignKey' => 'tag_id', + 'alias' => 'BakeTag', + 'className' => 'BakeTag', + 'foreignKey' => 'bake_article_id', + 'joinTable' => 'bake_articles_bake_tags', + 'associationForeignKey' => 'bake_tag_id', ), ), ); @@ -537,23 +529,23 @@ class ModelTaskTest extends CakeTestCase { public function testDoAssociationsNonInteractive() { $this->Task->connection = 'test'; $this->Task->interactive = false; - $model = new Model(array('ds' => 'test', 'name' => 'Article')); + $model = new Model(array('ds' => 'test', 'name' => 'BakeArticle')); $result = $this->Task->doAssociations($model); $expected = array( 'hasMany' => array( array( - 'alias' => 'Comment', - 'className' => 'Comment', - 'foreignKey' => 'article_id', + 'alias' => 'BakeComment', + 'className' => 'BakeComment', + 'foreignKey' => 'bake_article_id', ), ), 'hasAndBelongsToMany' => array( array( - 'alias' => 'Tag', - 'className' => 'Tag', - 'foreignKey' => 'article_id', - 'joinTable' => 'articles_tags', - 'associationForeignKey' => 'tag_id', + 'alias' => 'BakeTag', + 'className' => 'BakeTag', + 'foreignKey' => 'bake_article_id', + 'joinTable' => 'bake_articles_bake_tags', + 'associationForeignKey' => 'bake_tag_id', ), ), ); @@ -567,8 +559,8 @@ class ModelTaskTest extends CakeTestCase { public function testBakeFixture() { $this->Task->plugin = 'test_plugin'; $this->Task->interactive = true; - $this->Task->Fixture->expects($this->at(0))->method('bake')->with('Article', 'articles'); - $this->Task->bakeFixture('Article', 'articles'); + $this->Task->Fixture->expects($this->at(0))->method('bake')->with('BakeArticle', 'bake_articles'); + $this->Task->bakeFixture('BakeArticle', 'bake_articles'); $this->assertEqual($this->Task->plugin, $this->Task->Fixture->plugin); $this->assertEqual($this->Task->connection, $this->Task->Fixture->connection); @@ -583,8 +575,8 @@ class ModelTaskTest extends CakeTestCase { public function testBakeTest() { $this->Task->plugin = 'test_plugin'; $this->Task->interactive = true; - $this->Task->Test->expects($this->at(0))->method('bake')->with('Model', 'Article'); - $this->Task->bakeTest('Article'); + $this->Task->Test->expects($this->at(0))->method('bake')->with('Model', 'BakeArticle'); + $this->Task->bakeTest('BakeArticle'); $this->assertEqual($this->Task->plugin, $this->Task->Test->plugin); $this->assertEqual($this->Task->connection, $this->Task->Test->connection); @@ -676,9 +668,9 @@ class ModelTaskTest extends CakeTestCase { 'time' => 'time' ) ); - $result = $this->Task->bake('Article', compact('validate')); - $this->assertPattern('/class Article extends AppModel \{/', $result); - $this->assertPattern('/\$name \= \'Article\'/', $result); + $result = $this->Task->bake('BakeArticle', compact('validate')); + $this->assertPattern('/class BakeArticle extends AppModel \{/', $result); + $this->assertPattern('/\$name \= \'BakeArticle\'/', $result); $this->assertPattern('/\$validate \= array\(/', $result); $expected = <<< STRINGEND array( @@ -708,9 +700,9 @@ STRINGEND; 'foreignKey' => 'something_else_id', ), array( - 'alias' => 'User', - 'className' => 'User', - 'foreignKey' => 'user_id', + 'alias' => 'BakeUser', + 'className' => 'BakeUser', + 'foreignKey' => 'bake_user_id', ), ), 'hasOne' => array( @@ -722,30 +714,30 @@ STRINGEND; ), 'hasMany' => array( array( - 'alias' => 'Comment', - 'className' => 'Comment', + 'alias' => 'BakeComment', + 'className' => 'BakeComment', 'foreignKey' => 'parent_id', ), ), 'hasAndBelongsToMany' => array( array( - 'alias' => 'Tag', - 'className' => 'Tag', - 'foreignKey' => 'article_id', - 'joinTable' => 'articles_tags', - 'associationForeignKey' => 'tag_id', + 'alias' => 'BakeTag', + 'className' => 'BakeTag', + 'foreignKey' => 'bake_article_id', + 'joinTable' => 'bake_articles_bake_tags', + 'associationForeignKey' => 'bake_tag_id', ), ) ); - $result = $this->Task->bake('Article', compact('associations')); + $result = $this->Task->bake('BakeArticle', compact('associations')); $this->assertPattern('/\$hasAndBelongsToMany \= array\(/', $result); $this->assertPattern('/\$hasMany \= array\(/', $result); $this->assertPattern('/\$belongsTo \= array\(/', $result); $this->assertPattern('/\$hasOne \= array\(/', $result); - $this->assertPattern('/Tag/', $result); + $this->assertPattern('/BakeTag/', $result); $this->assertPattern('/OtherModel/', $result); $this->assertPattern('/SomethingElse/', $result); - $this->assertPattern('/Comment/', $result); + $this->assertPattern('/BakeComment/', $result); } /** @@ -756,11 +748,11 @@ STRINGEND; public function testBakeWithPlugin() { $this->Task->plugin = 'controllerTest'; - $path = APP . 'plugins' . DS . 'controller_test' . DS . 'models' . DS . 'article.php'; + $path = APP . 'plugins' . DS . 'controller_test' . DS . 'models' . DS . 'bake_article.php'; $this->Task->expects($this->once())->method('createFile') - ->with($path, new PHPUnit_Framework_Constraint_PCREMatch('/Article extends ControllerTestAppModel/')); + ->with($path, new PHPUnit_Framework_Constraint_PCREMatch('/BakeArticle extends ControllerTestAppModel/')); - $this->Task->bake('Article', array(), array()); + $this->Task->bake('BakeArticle', array(), array()); $this->assertEqual(count(ClassRegistry::keys()), 0); $this->assertEqual(count(ClassRegistry::mapKeys()), 0); @@ -774,12 +766,12 @@ STRINGEND; public function testExecuteWithNamedModel() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('article'); - $filename = '/my/path/article.php'; + $this->Task->args = array('bake_article'); + $filename = '/my/path/bake_article.php'; $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1)); $this->Task->expects($this->once())->method('createFile') - ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class Article extends AppModel/')); + ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle extends AppModel/')); $this->Task->execute(); @@ -794,7 +786,7 @@ STRINGEND; */ static function nameVariations() { return array( - array('Articles'), array('Article'), array('article'), array('articles') + array('BakeArticles'), array('BakeArticle'), array('bake_article'), array('bake_articles') ); } @@ -810,10 +802,10 @@ STRINGEND; $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1)); $this->Task->args = array($name); - $filename = '/my/path/article.php'; + $filename = '/my/path/bake_article.php'; $this->Task->expects($this->at(0))->method('createFile') - ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class Article extends AppModel/')); + ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle extends AppModel/')); $this->Task->execute(); } @@ -825,12 +817,12 @@ STRINGEND; public function testExecuteWithNamedModelHasManyCreated() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('article'); - $filename = '/my/path/article.php'; + $this->Task->args = array('bake_article'); + $filename = '/my/path/bake_article.php'; $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1)); $this->Task->expects($this->at(0))->method('createFile') - ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch("/'Comment' \=\> array\(/")); + ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch("/'BakeComment' \=\> array\(/")); $this->Task->execute(); } @@ -854,26 +846,26 @@ STRINGEND; $this->Task->Fixture->expects($this->exactly(5))->method('bake'); $this->Task->Test->expects($this->exactly(5))->method('bake'); - $filename = '/my/path/article.php'; + $filename = '/my/path/bake_article.php'; $this->Task->expects($this->at(1))->method('createFile') - ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class Article/')); + ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle/')); - $filename = '/my/path/articles_tag.php'; + $filename = '/my/path/bake_articles_bake_tag.php'; $this->Task->expects($this->at(2))->method('createFile') - ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class ArticlesTag/')); + ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesBakeTag/')); - $filename = '/my/path/category_thread.php'; + $filename = '/my/path/bake_comment.php'; $this->Task->expects($this->at(3))->method('createFile') + ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeComment/')); + + $filename = '/my/path/bake_tag.php'; + $this->Task->expects($this->at(4)) + ->method('createFile')->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeTag/')); + + $filename = '/my/path/category_thread.php'; + $this->Task->expects($this->at(5))->method('createFile') ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class CategoryThread/')); - $filename = '/my/path/comment.php'; - $this->Task->expects($this->at(4))->method('createFile') - ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class Comment/')); - - $filename = '/my/path/tag.php'; - $this->Task->expects($this->at(5)) - ->method('createFile')->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class Tag/')); - $this->Task->execute(); $this->assertEqual(count(ClassRegistry::keys()), 0); @@ -895,26 +887,26 @@ STRINGEND; $this->Task->path = '/my/path/'; $this->Task->args = array('all'); $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true)); - $this->Task->skipTables = array('tags'); + $this->Task->skipTables = array('bake_tags'); $this->Task->Fixture->expects($this->exactly(4))->method('bake'); $this->Task->Test->expects($this->exactly(4))->method('bake'); - $filename = '/my/path/article.php'; + $filename = '/my/path/bake_article.php'; $this->Task->expects($this->at(1))->method('createFile') - ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class Article/')); + ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle/')); - $filename = '/my/path/articles_tag.php'; + $filename = '/my/path/bake_articles_bake_tag.php'; $this->Task->expects($this->at(2))->method('createFile') - ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class ArticlesTag/')); + ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesBakeTag/')); + + $filename = '/my/path/bake_comment.php'; + $this->Task->expects($this->at(3))->method('createFile') + ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeComment/')); $filename = '/my/path/category_thread.php'; - $this->Task->expects($this->at(3))->method('createFile') - ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class CategoryThread/')); - - $filename = '/my/path/comment.php'; $this->Task->expects($this->at(4))->method('createFile') - ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class Comment/')); + ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class CategoryThread/')); $this->Task->execute(); } @@ -950,10 +942,10 @@ STRINGEND; $this->Task->Test->expects($this->once())->method('bake'); $this->Task->Fixture->expects($this->once())->method('bake'); - $filename = '/my/path/article.php'; + $filename = '/my/path/bake_article.php'; $this->Task->expects($this->once())->method('createFile') - ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class Article/')); + ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle/')); $this->Task->execute(); diff --git a/cake/tests/cases/console/shells/testsuite.test.php b/cake/tests/cases/console/shells/testsuite.test.php index b132aa557..bfe463dbf 100644 --- a/cake/tests/cases/console/shells/testsuite.test.php +++ b/cake/tests/cases/console/shells/testsuite.test.php @@ -41,6 +41,7 @@ class TestSuiteShellTest extends CakeTestCase { array('in', 'out', 'hr', 'help', 'error', 'err', '_stop', 'initialize', 'run', 'clear'), array($out, $out, $in) ); + $this->Shell->OptionParser = $this->getMock('ConsoleOptionParser', array(), array(null, false)); } /** @@ -61,7 +62,7 @@ class TestSuiteShellTest extends CakeTestCase { $this->Shell->startup(); $this->Shell->args = array('unexistant-category'); $this->Shell->expects($this->at(0))->method('out')->with(__("No test cases available \n\n")); - $this->Shell->expects($this->once())->method('help'); + $this->Shell->OptionParser->expects($this->once())->method('help'); $this->Shell->available(); } diff --git a/cake/tests/cases/libs/cake_test_case.test.php b/cake/tests/cases/libs/cake_test_case.test.php index 21551bae5..f9e5e8410 100644 --- a/cake/tests/cases/libs/cake_test_case.test.php +++ b/cake/tests/cases/libs/cake_test_case.test.php @@ -60,7 +60,6 @@ class CakeTestCaseTest extends CakeTestCase { */ function tearDown() { Configure::write('debug', $this->_debug); - unset($this->Case); unset($this->Result); unset($this->Reporter); } @@ -77,6 +76,30 @@ class CakeTestCaseTest extends CakeTestCase { $this->assertEquals(0, $result->errorCount()); $this->assertTrue($result->wasSuccessful()); $this->assertEquals(0, $result->failureCount()); + + $input = 'My link'; + $pattern = array( + 'a' => array('href' => '/test.html', 'class' => 'active'), + 'My link', + '/a' + ); + $this->assertTrue($test->assertTags($input, $pattern), 'Double quoted attributes %s'); + + $input = "My link"; + $pattern = array( + 'a' => array('href' => '/test.html', 'class' => 'active'), + 'My link', + '/a' + ); + $this->assertTrue($test->assertTags($input, $pattern), 'Single quoted attributes %s'); + + $input = "My link"; + $pattern = array( + 'a' => array('href' => 'preg:/.*\.html/', 'class' => 'active'), + 'My link', + '/a' + ); + $this->assertTrue($test->assertTags($input, $pattern), 'Single quoted attributes %s'); } /** @@ -181,6 +204,7 @@ class CakeTestCaseTest extends CakeTestCase { $manager->expects($this->once())->method('unload'); $result = $test->run(); $this->assertEquals(1, $result->errorCount()); + } /** * testSkipIf diff --git a/cake/tests/cases/libs/controller/components/security.test.php b/cake/tests/cases/libs/controller/components/security.test.php index b338217ef..22274277a 100644 --- a/cake/tests/cases/libs/controller/components/security.test.php +++ b/cake/tests/cases/libs/controller/components/security.test.php @@ -608,6 +608,29 @@ DIGEST; $this->assertFalse($result, 'validatePost passed when fields were missing. %s'); } +/** + * Test that objects can't be passed into the serialized string. This was a vector for RFI and LFI + * attacks. Thanks to Felix Wilhelm + * + * @return void + */ + function testValidatePostObjectDeserialize() { + $this->Controller->Security->startup($this->Controller); + $key = $this->Controller->request->params['_Token']['key']; + $fields = 'a5475372b40f6e3ccbf9f8af191f20e1642fd877'; + + // a corrupted serialized object, so we can see if it ever gets to deserialize + $attack = 'O:3:"App":1:{s:5:"__map";a:1:{s:3:"foo";s:7:"Hacked!";s:1:"fail"}}'; + $fields .= urlencode(':' . str_rot13($attack)); + + $this->Controller->request->data = array( + 'Model' => array('username' => 'mark', 'password' => 'foo', 'valid' => '0'), + '_Token' => compact('key', 'fields') + ); + $result = $this->Controller->Security->validatePost($this->Controller); + $this->assertFalse($result, 'validatePost passed when key was missing. %s'); + } + /** * Tests validation of checkbox arrays * diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 4a8860a2f..02260dcb5 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -1241,7 +1241,7 @@ class ControllerTest extends CakeTestCase { ? array_merge($appVars['uses'], $testVars['uses']) : $testVars['uses']; - $this->assertEqual(count(array_diff($TestController->helpers, $helpers)), 0); + $this->assertEqual(count(array_diff_assoc(Set::normalize($TestController->helpers), Set::normalize($helpers))), 0); $this->assertEqual(count(array_diff($TestController->uses, $uses)), 0); $this->assertEqual(count(array_diff_assoc(Set::normalize($TestController->components), Set::normalize($components))), 0); diff --git a/cake/tests/cases/libs/controller/controller_merge_vars.test.php b/cake/tests/cases/libs/controller/controller_merge_vars.test.php index c09392908..a3199b3a2 100644 --- a/cake/tests/cases/libs/controller/controller_merge_vars.test.php +++ b/cake/tests/cases/libs/controller/controller_merge_vars.test.php @@ -19,6 +19,8 @@ * @since CakePHP(tm) v 1.2.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::import('Core', 'Controller'); + if (!class_exists('AppController')) { /** @@ -183,6 +185,27 @@ class ControllerMergeVarsTest extends CakeTestCase { $this->assertEqual($Controller->helpers, $expected, 'Duplication of settings occured. %s'); } +/** + * Test that helpers declared in appcontroller come before those in the subclass + * orderwise + * + * @return void + */ + function testHelperOrderPrecedence() { + $this->skipIf(defined('APP_CONTROLLER_EXISTS'), "APP_CONTROLLER_EXISTS cannot run {$this->name}"); + + $Controller =& new MergeVariablesController(); + $Controller->helpers = array('Custom', 'Foo' => array('something')); + $Controller->constructClasses(); + + $expected = array( + 'MergeVar' => array('format' => 'html', 'terse'), + 'Custom' => null, + 'Foo' => array('something') + ); + $this->assertSame($Controller->helpers, $expected, 'Order is incorrect.'); + } + /** * test merging of vars with plugin * @@ -201,13 +224,13 @@ class ControllerMergeVarsTest extends CakeTestCase { 'Auth' => array('setting' => 'val', 'otherVal'), 'Email' => array('ports' => 'open') ); - $this->assertEqual($Controller->components, $expected, 'Components are unexpected %s'); + $this->assertEquals($expected, $Controller->components, 'Components are unexpected.'); $expected = array( - 'Javascript', - 'MergeVar' => array('format' => 'html', 'terse') + 'MergeVar' => array('format' => 'html', 'terse'), + 'Javascript' => null ); - $this->assertEqual($Controller->helpers, $expected, 'Helpers are unexpected %s'); + $this->assertEquals($expected, $Controller->helpers, 'Helpers are unexpected.'); $Controller = new MergePostsController(); $Controller->components = array(); @@ -218,7 +241,7 @@ class ControllerMergeVarsTest extends CakeTestCase { 'MergeVar' => array('flag', 'otherFlag', 'redirect' => false), 'Auth' => array('setting' => 'val', 'otherVal'), ); - $this->assertEqual($Controller->components, $expected, 'Components are unexpected %s'); + $this->assertEquals($expected, $Controller->components, 'Components are unexpected.'); } /** diff --git a/cake/tests/cases/libs/folder.test.php b/cake/tests/cases/libs/folder.test.php index 68d2c706c..428520610 100644 --- a/cake/tests/cases/libs/folder.test.php +++ b/cake/tests/cases/libs/folder.test.php @@ -367,6 +367,7 @@ class FolderTest extends CakeTestCase { $this->assertFalse(Folder::isWindowsPath('0:\\cake\\is\\awesome')); $this->assertTrue(Folder::isWindowsPath('C:\\cake\\is\\awesome')); $this->assertTrue(Folder::isWindowsPath('d:\\cake\\is\\awesome')); + $this->assertTrue(Folder::isWindowsPath('\\\\vmware-host\\Shared Folders\\file')); } /** @@ -388,6 +389,7 @@ class FolderTest extends CakeTestCase { $this->assertTrue(Folder::isAbsolute('C:\\cake')); $this->assertTrue(Folder::isAbsolute('C:\\path\\to\\file')); $this->assertTrue(Folder::isAbsolute('d:\\path\\to\\file')); + $this->assertTrue(Folder::isAbsolute('\\\\vmware-host\\Shared Folders\\file')); } /** diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php index 545aff38f..8ea86d221 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php @@ -17,9 +17,7 @@ * @since CakePHP(tm) v 1.2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) { - define('CAKEPHP_UNIT_TEST_EXECUTION', 1); -} + require_once LIBS.'model'.DS.'model.php'; require_once LIBS.'model'.DS.'datasources'.DS.'datasource.php'; require_once LIBS.'model'.DS.'datasources'.DS.'dbo_source.php'; diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index d08c638c3..9df7be0fa 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -728,9 +728,10 @@ class DboMysqlTest extends CakeTestCase { $model->virtualFields = array( 'other__field' => 'SUM(id)' ); - + $this->Dbo->virtualFieldSeparator = '_$_'; $result = $this->Dbo->fields($model, null, array('data', 'other__field')); + $expected = array('`BinaryTest`.`data`', '(SUM(id)) AS `BinaryTest_$_other__field`'); $this->assertEqual($result, $expected); } diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php index 5a36e3899..3efa451bd 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php @@ -17,9 +17,7 @@ * @since CakePHP(tm) v 1.2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) { - define('CAKEPHP_UNIT_TEST_EXECUTION', 1); -} + require_once LIBS . 'model' . DS . 'datasources' . DS . 'dbo_source.php'; require_once LIBS . 'model' . DS . 'datasources' . DS . 'dbo' . DS . 'dbo_oracle.php'; diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index b7926570a..9ac868c3b 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -17,9 +17,7 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) { - define('CAKEPHP_UNIT_TEST_EXECUTION', 1); -} + App::import('Model', array('Model', 'DataSource', 'DboSource', 'DboMysql', 'App')); require_once dirname(dirname(__FILE__)) . DS . 'models.php'; diff --git a/cake/tests/cases/libs/model/model_integration.test.php b/cake/tests/cases/libs/model/model_integration.test.php index 292929b46..1e6c73e21 100644 --- a/cake/tests/cases/libs/model/model_integration.test.php +++ b/cake/tests/cases/libs/model/model_integration.test.php @@ -1309,12 +1309,12 @@ class ModelIntegrationTest extends BaseModelTest { $this->loadFixtures('Post'); $TestModel = ClassRegistry::init('MergeVarPluginPost'); - $this->assertEqual($TestModel->actsAs, array('Containable', 'Tree')); + $this->assertEqual($TestModel->actsAs, array('Containable' => null, 'Tree' => null)); $this->assertTrue(isset($TestModel->Behaviors->Containable)); $this->assertTrue(isset($TestModel->Behaviors->Tree)); $TestModel = ClassRegistry::init('MergeVarPluginComment'); - $expected = array('Containable', 'Containable' => array('some_settings')); + $expected = array('Containable' => array('some_settings')); $this->assertEqual($TestModel->actsAs, $expected); $this->assertTrue(isset($TestModel->Behaviors->Containable)); } diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php index a876cddd8..855dddfaf 100644 --- a/cake/tests/cases/libs/model/model_write.test.php +++ b/cake/tests/cases/libs/model/model_write.test.php @@ -3061,6 +3061,22 @@ class ModelWriteTest extends BaseModelTest { $Post->saveAll($data); } +/** + * test saveAll with nested saveAll call. + * + * @return void + */ + function testSaveAllNestedSaveAll() { + $this->loadFixtures('Sample'); + $TransactionTestModel =& new TransactionTestModel(); + + $data = array( + array('apple_id' => 1, 'name' => 'sample5'), + ); + + $this->assertTrue($TransactionTestModel->saveAll($data, array('atomic' => true))); + } + /** * testSaveAllTransaction method * diff --git a/cake/tests/cases/libs/model/models.php b/cake/tests/cases/libs/model/models.php index 7bbbb2219..8e20eb6be 100644 --- a/cake/tests/cases/libs/model/models.php +++ b/cake/tests/cases/libs/model/models.php @@ -19,9 +19,6 @@ * @since CakePHP(tm) v 1.2.0.6464 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) { - define('CAKEPHP_UNIT_TEST_EXECUTION', 1); -} PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); @@ -292,7 +289,7 @@ class Article extends CakeTestModel { */ class BeforeDeleteComment extends CakeTestModel { var $name = 'BeforeDeleteComment'; - + var $useTable = 'comments'; function beforeDelete($cascade = true) { @@ -3559,6 +3556,7 @@ class FruitNoWith extends CakeTestModel { ) ); } + class UuidTagNoWith extends CakeTestModel { public $name = 'UuidTag'; public $useTable = 'uuid_tags'; @@ -3581,7 +3579,18 @@ class ProductUpdateAll extends CakeTestModel { class GroupUpdateAll extends CakeTestModel { public $name = 'GroupUpdateAll'; public $useTable = 'group_update_all'; +} +class TransactionTestModel extends CakeTestModel { + var $name = 'TransactionTestModel'; + var $useTable = 'samples'; + + function afterSave($created) { + $data = array( + array('apple_id' => 1, 'name' => 'sample6'), + ); + $this->saveAll($data, array('atomic' => true, 'callbacks' => false)); + } } /** @@ -4888,4 +4897,4 @@ class MysqlTestModel extends Model { 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) ); } -} \ No newline at end of file +} diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 16b7472e7..92c3f0971 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -56,6 +56,8 @@ class RouterTest extends CakeTestCase { } $this->assertPattern('/^http(s)?:\/\//', Router::url('/', true)); $this->assertPattern('/^http(s)?:\/\//', Router::url(null, true)); + $this->assertPattern('/^http(s)?:\/\//', Router::url(array('full_base' => true))); + $this->assertIdentical(FULL_BASE_URL . '/', Router::url(array('full_base' => true))); } /** @@ -1707,8 +1709,8 @@ class RouterTest extends CakeTestCase { function testParsingWithPatternOnAction() { Router::reload(); Router::connect( - '/blog/:action/*', - array('controller' => 'blog_posts'), + '/blog/:action/*', + array('controller' => 'blog_posts'), array('action' => 'other|actions') ); $result = Router::parse('/blog/other'); @@ -1730,7 +1732,7 @@ class RouterTest extends CakeTestCase { 'named' => array() ); $this->assertEqual($expected, $result); - + $result = Router::url(array('controller' => 'blog_posts', 'action' => 'foo')); $this->assertEqual('/blog_posts/foo', $result); @@ -2265,6 +2267,31 @@ class RouterTest extends CakeTestCase { $this->assertEqual($url, Router::url($url)); } +/** + * Testing that patterns on the :action param work properly. + * + * @return void + */ + function testPatternOnAction() { + $route =& new CakeRoute( + '/blog/:action/*', + array('controller' => 'blog_posts'), + array('action' => 'other|actions') + ); + $result = $route->match(array('controller' => 'blog_posts', 'action' => 'foo')); + $this->assertFalse($result); + + $result = $route->match(array('controller' => 'blog_posts', 'action' => 'actions')); + $this->assertEquals('/blog/actions/', $result); + + $result = $route->parse('/blog/other'); + $expected = array('controller' => 'blog_posts', 'action' => 'other', 'pass' => array(), 'named' => array()); + $this->assertEqual($expected, $result); + + $result = $route->parse('/blog/foobar'); + $this->assertFalse($result); + } + /** * test setting redirect routes * diff --git a/cake/tests/cases/libs/set.test.php b/cake/tests/cases/libs/set.test.php index 9d0d1b08b..9fbc4086b 100644 --- a/cake/tests/cases/libs/set.test.php +++ b/cake/tests/cases/libs/set.test.php @@ -2990,4 +2990,50 @@ class SetTest extends CakeTestCase { ); $this->assertEqual($result, $expected); } + +/** + * test normalization + * + * @return void + */ + function testNormalizeStrings() { + $result = Set::normalize('one,two,three'); + $expected = array('one' => null, 'two' => null, 'three' => null); + $this->assertEqual($expected, $result); + + $result = Set::normalize('one two three', true, ' '); + $expected = array('one' => null, 'two' => null, 'three' => null); + $this->assertEqual($expected, $result); + + $result = Set::normalize('one , two , three ', true, ',', true); + $expected = array('one' => null, 'two' => null, 'three' => null); + $this->assertEqual($expected, $result); + } + +/** + * test normalizing arrays + * + * @return void + */ + function testNormalizeArrays() { + $result = Set::normalize(array('one', 'two', 'three')); + $expected = array('one' => null, 'two' => null, 'three' => null); + $this->assertEqual($expected, $result); + + $result = Set::normalize(array('one', 'two', 'three'), false); + $expected = array('one', 'two', 'three'); + $this->assertEqual($expected, $result); + + $result = Set::normalize(array('one' => 1, 'two' => 2, 'three' => 3, 'four'), false); + $expected = array('one' => 1, 'two' => 2, 'three' => 3, 'four' => null); + $this->assertEqual($expected, $result); + + $result = Set::normalize(array('one' => 1, 'two' => 2, 'three' => 3, 'four')); + $expected = array('one' => 1, 'two' => 2, 'three' => 3, 'four' => null); + $this->assertEqual($expected, $result); + + $result = Set::normalize(array('one' => array('a', 'b', 'c' => 'cee'), 'two' => 2, 'three')); + $expected = array('one' => array('a', 'b', 'c' => 'cee'), 'two' => 2, 'three' => null); + $this->assertEqual($expected, $result); + } } diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 7f0325f64..494fa778b 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -5679,6 +5679,31 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected, true); } +/** + * test that create() doesn't cause errors by multiple id's being in the primary key + * as could happen with multiple select or checkboxes. + * + * @return void + */ + function testCreateWithMultipleIdInData() { + $encoding = strtolower(Configure::read('App.encoding')); + + $this->Form->request->data['Contact']['id'] = array(1, 2); + $result = $this->Form->create('Contact'); + $expected = array( + 'form' => array( + 'id' => 'ContactAddForm', + 'method' => 'post', + 'action' => '/contacts/add', + 'accept-charset' => $encoding + ), + 'div' => array('style' => 'display:none;'), + 'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'), + '/div' + ); + $this->assertTags($result, $expected); + } + /** * test that create() doesn't add in extra passed params. * diff --git a/cake/tests/cases/libs/view/helpers/html.test.php b/cake/tests/cases/libs/view/helpers/html.test.php index dd4e85708..2defe93ab 100644 --- a/cake/tests/cases/libs/view/helpers/html.test.php +++ b/cake/tests/cases/libs/view/helpers/html.test.php @@ -90,6 +90,8 @@ class HtmlHelperTest extends CakeTestCase { $this->Html = new HtmlHelper($this->View); $this->Html->request = new CakeRequest(null, false); $this->Html->request->webroot = ''; + + Configure::write('Asset.timestamp', false); } /** @@ -262,7 +264,6 @@ class HtmlHelperTest extends CakeTestCase { */ function testImageTag() { $this->Html->request->webroot = ''; - Configure::write('Asset.timestamp', false); $result = $this->Html->image('test.gif'); $this->assertTags($result, array('img' => array('src' => 'img/test.gif', 'alt' => ''))); @@ -354,7 +355,6 @@ class HtmlHelperTest extends CakeTestCase { * @return void */ function testThemeAssetsInMainWebrootPath() { - Configure::write('Asset.timestamp', false); App::build(array( 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); @@ -402,7 +402,6 @@ class HtmlHelperTest extends CakeTestCase { * @return void */ function testCssLink() { - Configure::write('Asset.timestamp', false); Configure::write('Asset.filter.css', false); $result = $this->Html->css('screen'); @@ -528,7 +527,6 @@ class HtmlHelperTest extends CakeTestCase { * @return void */ function testScript() { - Configure::write('Asset.timestamp', false); $result = $this->Html->script('foo'); $expected = array( 'script' => array('type' => 'text/javascript', 'src' => 'js/foo.js') diff --git a/cake/tests/cases/libs/view/helpers/number.test.php b/cake/tests/cases/libs/view/helpers/number.test.php index 6260a82ad..1d1d04c4c 100644 --- a/cake/tests/cases/libs/view/helpers/number.test.php +++ b/cake/tests/cases/libs/view/helpers/number.test.php @@ -237,7 +237,7 @@ class NumberHelperTest extends CakeTestCase { $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'EUR'); - $expected = '99c'; + $expected = '€0,99'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'GBP'); @@ -259,7 +259,7 @@ class NumberHelperTest extends CakeTestCase { $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'EUR'); - $expected = '(99c)'; + $expected = '(€0,99)'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'GBP'); @@ -271,7 +271,7 @@ class NumberHelperTest extends CakeTestCase { $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'EUR', array('negative'=>'-')); - $expected = '-99c'; + $expected = '-€0,99'; $this->assertEqual($expected, $result); $result = $this->Number->currency($value, 'GBP', array('negative'=>'-')); @@ -337,6 +337,10 @@ class NumberHelperTest extends CakeTestCase { $result = $this->Number->currency('0.35', 'GBP'); $expected = '35p'; $this->assertEqual($expected, $result); + + $result = $this->Number->currency('0.35', 'EUR'); + $expected = '€0,35'; + $this->assertEqual($expected, $result); } /** diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 3a3e81895..2d0bda4a9 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -20,6 +20,10 @@ App::import('Core', 'View'); App::import('Helper', array('Html', 'Paginator', 'Form', 'Js')); +if (!defined('FULL_BASE_URL')) { + define('FULL_BASE_URL', 'http://cakephp.org'); +} + /** * PaginatorHelperTest class * @@ -1777,6 +1781,15 @@ class PaginatorHelperTest extends CakeTestCase { '/span', ); $this->assertTags($result, $expected); + + $this->Paginator->options(array('url' => array('full_base' => true))); + $result = $this->Paginator->first(); + $expected = array( + ' array('href' => FULL_BASE_URL . '/index/page:1/sort:Client.name/direction:DESC')), '<< first', '/a', + '/span', + ); + $this->assertTags($result, $expected); } /** diff --git a/cake/tests/cases/libs/view/media.test.php b/cake/tests/cases/libs/view/media.test.php index b08c54e23..39b9d190d 100644 --- a/cake/tests/cases/libs/view/media.test.php +++ b/cake/tests/cases/libs/view/media.test.php @@ -19,13 +19,6 @@ */ App::import('Core', array('Media', 'Controller', 'CakeResponse')); -if (!class_exists('ErrorHandler')) { - App::import('Core', array('Error')); -} -if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) { - define('CAKEPHP_UNIT_TEST_EXECUTION', 1); -} - /** * MediaViewTest class *