diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index a8f7e359d36..5f211ee45d6 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -169,7 +169,7 @@ public function inOptions($options, $prompt = null, $default = null) { $valid = false; $max = count($options); while (!$valid) { - $len = strlen((count($options)+1)); + $len = strlen(count($options) + 1); foreach ($options as $i => $option) { $this->out(sprintf("%${len}d. %s", $i + 1, $option)); } @@ -410,14 +410,15 @@ public function fieldValidation($fieldName, $metaData, $primaryKey = 'id') { $this->out(__d('cake_console', 'Please select one of the following validation options:')); $this->hr(); + $optionText = ''; for ($i = 1, $m = $defaultChoice / 2; $i < $m; $i++) { - $strAux = sprintf("%2d. %s", $i, $this->_validations[$i]); - $strAux = $strAux.str_repeat(" ", 31 - strlen($strAux)); - $strAux .= sprintf("%2d. %s", $m + $i, $this->_validations[$m + $i]); - $this->out($strAux); - } - $this->out(__d('cake_console', "%s - Do not do any validation on this field.", $defaultChoice)); - $this->hr(); + $line = sprintf("%2d. %s", $i, $this->_validations[$i]); + $optionText .= $line . str_repeat(" ", 31 - strlen($line)); + $optionText .= sprintf("%2d. %s", $m + $i, $this->_validations[$m + $i]); + } + $this->out($optionText); + $this->out(__d('cake_console', "%s - Do not do any validation on this field.", $defaultChoice)); + $this->hr(); } $prompt = __d('cake_console', "... or enter in a valid regex validation string.\n"); @@ -848,7 +849,7 @@ public function listAll($useDbConfig = null) { } if ($this->interactive === true) { $this->out(__d('cake_console', 'Possible Models based on your current database:')); - $len = strlen(($count + 1)); + $len = strlen($count + 1); for ($i = 0; $i < $count; $i++) { $this->out(sprintf("%${len}d. %s", $i + 1, $this->_modelNames[$i])); } diff --git a/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php index 8e7325d20f0..2e3c5d9d16b 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php @@ -335,7 +335,7 @@ public function testInteractiveFieldValidationWithBogusResponse() { $this->Task->expects($this->any())->method('in') ->will($this->onConsecutiveCalls('999999', '23', 'n')); - $this->Task->expects($this->at(7))->method('out') + $this->Task->expects($this->at(10))->method('out') ->with($this->stringContains('make a valid')); $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));