Skip to content

Commit f6b50a9

Browse files
committed
Small fixes for validation formatting.
* Remove additional out() calls. * Remove extra punctuation. * Fix code standards. * Fix failing test.
1 parent 1bcb8da commit f6b50a9

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

lib/Cake/Console/Command/Task/ModelTask.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function inOptions($options, $prompt = null, $default = null) {
169169
$valid = false;
170170
$max = count($options);
171171
while (!$valid) {
172-
$len = strlen((count($options)+1));
172+
$len = strlen(count($options) + 1);
173173
foreach ($options as $i => $option) {
174174
$this->out(sprintf("%${len}d. %s", $i + 1, $option));
175175
}
@@ -410,14 +410,15 @@ public function fieldValidation($fieldName, $metaData, $primaryKey = 'id') {
410410
$this->out(__d('cake_console', 'Please select one of the following validation options:'));
411411
$this->hr();
412412

413+
$optionText = '';
413414
for ($i = 1, $m = $defaultChoice / 2; $i < $m; $i++) {
414-
$strAux = sprintf("%2d. %s", $i, $this->_validations[$i]);
415-
$strAux = $strAux.str_repeat(" ", 31 - strlen($strAux));
416-
$strAux .= sprintf("%2d. %s", $m + $i, $this->_validations[$m + $i]);
417-
$this->out($strAux);
418-
}
419-
$this->out(__d('cake_console', "%s - Do not do any validation on this field.", $defaultChoice));
420-
$this->hr();
415+
$line = sprintf("%2d. %s", $i, $this->_validations[$i]);
416+
$optionText .= $line . str_repeat(" ", 31 - strlen($line));
417+
$optionText .= sprintf("%2d. %s", $m + $i, $this->_validations[$m + $i]);
418+
}
419+
$this->out($optionText);
420+
$this->out(__d('cake_console', "%s - Do not do any validation on this field.", $defaultChoice));
421+
$this->hr();
421422
}
422423

423424
$prompt = __d('cake_console', "... or enter in a valid regex validation string.\n");
@@ -848,7 +849,7 @@ public function listAll($useDbConfig = null) {
848849
}
849850
if ($this->interactive === true) {
850851
$this->out(__d('cake_console', 'Possible Models based on your current database:'));
851-
$len = strlen(($count + 1));
852+
$len = strlen($count + 1);
852853
for ($i = 0; $i < $count; $i++) {
853854
$this->out(sprintf("%${len}d. %s", $i + 1, $this->_modelNames[$i]));
854855
}

lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public function testInteractiveFieldValidationWithBogusResponse() {
335335
$this->Task->expects($this->any())->method('in')
336336
->will($this->onConsecutiveCalls('999999', '23', 'n'));
337337

338-
$this->Task->expects($this->at(7))->method('out')
338+
$this->Task->expects($this->at(10))->method('out')
339339
->with($this->stringContains('make a valid'));
340340

341341
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));

0 commit comments

Comments
 (0)