Permalink
Browse files

Small fixes for validation formatting.

* Remove additional out() calls.
* Remove extra punctuation.
* Fix code standards.
* Fix failing test.
  • Loading branch information...
1 parent 1bcb8da commit f6b50a948e6aa526acbbb577dc1f507206695c9f @markstory markstory committed Jun 11, 2012
View
19 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]));
}
View
2 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));

0 comments on commit f6b50a9

Please sign in to comment.