Browse Source

Small fixes for validation formatting.

* Remove additional out() calls.
* Remove extra punctuation.
* Fix code standards.
* Fix failing test.
mark_story 14 years ago
parent
commit
f6b50a948e

+ 10 - 9
lib/Cake/Console/Command/Task/ModelTask.php

@@ -169,7 +169,7 @@ class ModelTask extends BakeTask {
 		$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 @@ class ModelTask extends BakeTask {
 				$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 @@ class ModelTask extends BakeTask {
 		}
 		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]));
 			}

+ 1 - 1
lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php

@@ -335,7 +335,7 @@ class ModelTaskTest extends CakeTestCase {
 		$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));