From f84871ae47a4298f419a31d108ca7366519306c6 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 12 Dec 2010 20:55:33 -0500 Subject: [PATCH] Fixing strict errors that were causing shell tests to fail. Fixing test case for bake test that has been getting skipped. --- cake/console/shells/bake.php | 2 +- cake/console/shells/tasks/model.php | 2 +- cake/libs/folder.php | 28 +++++-------------- cake/tests/cases/console/shells/bake.test.php | 13 ++++----- 4 files changed, 15 insertions(+), 30 deletions(-) diff --git a/cake/console/shells/bake.php b/cake/console/shells/bake.php index 77dd36201ce..7e4dbb016bd 100644 --- a/cake/console/shells/bake.php +++ b/cake/console/shells/bake.php @@ -186,7 +186,7 @@ public function all() { } else { $this->error(__('Bake All could not continue without a valid model')); } - $this->_stop(); + return $this->_stop(); } /** diff --git a/cake/console/shells/tasks/model.php b/cake/console/shells/tasks/model.php index 7616ef14cf6..ffa06640a70 100644 --- a/cake/console/shells/tasks/model.php +++ b/cake/console/shells/tasks/model.php @@ -701,7 +701,7 @@ public function doMoreAssociations($model, $associations) { protected function _generatePossibleKeys() { $possible = array(); foreach ($this->_tables as $otherTable) { - $tempOtherModel = & new Model(array('table' => $otherTable, 'ds' => $this->connection)); + $tempOtherModel = new Model(array('table' => $otherTable, 'ds' => $this->connection)); $modelFieldsTemp = $tempOtherModel->schema(true); foreach ($modelFieldsTemp as $fieldName => $field) { if ($field['type'] == 'integer' || $field['type'] == 'string') { diff --git a/cake/libs/folder.php b/cake/libs/folder.php index 551e05876fb..733315a1aa4 100644 --- a/cake/libs/folder.php +++ b/cake/libs/folder.php @@ -240,10 +240,8 @@ function _findRecursive($pattern, $sort = false) { * * @param string $path Path to check * @return boolean true if windows path, false otherwise - * @access public - * @static */ - function isWindowsPath($path) { + public static function isWindowsPath($path) { return (preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\'); } @@ -252,10 +250,8 @@ function isWindowsPath($path) { * * @param string $path Path to check * @return bool true if path is absolute. - * @access public - * @static */ - function isAbsolute($path) { + public static function isAbsolute($path) { return !empty($path) && ($path[0] === '/' || preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\'); } @@ -264,10 +260,8 @@ function isAbsolute($path) { * * @param string $path Path to check * @return string Set of slashes ("\\" or "/") - * @access public - * @static */ - function normalizePath($path) { + public static function normalizePath($path) { return Folder::correctSlashFor($path); } @@ -276,10 +270,8 @@ function normalizePath($path) { * * @param string $path Path to check * @return string Set of slashes ("\\" or "/") - * @access public - * @static */ - function correctSlashFor($path) { + public static function correctSlashFor($path) { return (Folder::isWindowsPath($path)) ? '\\' : '/'; } @@ -288,10 +280,8 @@ function correctSlashFor($path) { * * @param string $path Path to check * @return string Path with ending slash - * @access public - * @static */ - function slashTerm($path) { + public static function slashTerm($path) { if (Folder::isSlashTerm($path)) { return $path; } @@ -304,10 +294,8 @@ function slashTerm($path) { * @param string $path Path * @param string $element Element to and at end of path * @return string Combined path - * @access public - * @static */ - function addPathElement($path, $element) { + public static function addPathElement($path, $element) { return rtrim($path, DS) . DS . $element; } @@ -755,10 +743,8 @@ function realpath($path) { * * @param string $path Path to check * @return boolean true if path ends with slash, false otherwise - * @access public - * @static */ - function isSlashTerm($path) { + public static function isSlashTerm($path) { $lastChar = $path[strlen($path) - 1]; return $lastChar === '/' || $lastChar === '\\'; } diff --git a/cake/tests/cases/console/shells/bake.test.php b/cake/tests/cases/console/shells/bake.test.php index 6f68e8bb3c4..89383b1ff6e 100644 --- a/cake/tests/cases/console/shells/bake.test.php +++ b/cake/tests/cases/console/shells/bake.test.php @@ -20,9 +20,9 @@ */ App::import('Shell', 'Shell', false); App::import('Shell', 'Bake', false); -App::import('Shell', 'tasks/model', false); -App::import('Shell', 'tasks/controller', false); -App::import('Shell', 'tasks/db_config', false); +App::import('Shell', 'tasks/model'); +App::import('Shell', 'tasks/controller'); +App::import('Shell', 'tasks/db_config'); App::import('Core', 'Controller'); require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; @@ -94,12 +94,11 @@ public function testAllWithModelName() { $this->Shell->Controller->expects($this->once())->method('bake')->will($this->returnValue(true)); $this->Shell->View->expects($this->once())->method('execute'); - $this->Shell->expects($this->at(1))->method('out')->with('Bake All'); - $this->Shell->expects($this->at(3))->method('out')->with('User Model was baked.'); + $this->Shell->expects($this->once())->method('_stop'); + $this->Shell->expects($this->at(0))->method('out')->with('Bake All'); $this->Shell->expects($this->at(5))->method('out')->with('Bake All complete'); - $this->Shell->expects($this->at(7))->method('out')->with('User Views were baked.'); - $this->Shell->expects($this->at(8))->method('out')->with('Bake All complete'); + $this->Shell->connection = ''; $this->Shell->params = array(); $this->Shell->args = array('User'); $this->Shell->all();