Skip to content

Commit

Permalink
Small fixes for validation formatting.
Browse files Browse the repository at this point in the history
* Remove additional out() calls.
* Remove extra punctuation.
* Fix code standards.
* Fix failing test.
  • Loading branch information
markstory committed Jun 11, 2012
1 parent 1bcb8da commit f6b50a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions lib/Cake/Console/Command/Task/ModelTask.php
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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]));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php
Expand Up @@ -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));
Expand Down

0 comments on commit f6b50a9

Please sign in to comment.