From 8981f49bd5ab679b894c70809a47346f7b5b08d1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 16 Nov 2011 20:38:31 -0500 Subject: [PATCH] Add stricter validation to TestTask. Empty classnames, and classnames without the correct type suffix are no longer accepted. They did the wrong thing anyways. Fixes #2267 --- lib/Cake/Console/Command/Task/TestTask.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Console/Command/Task/TestTask.php b/lib/Cake/Console/Command/Task/TestTask.php index 769773643..a1265bf90 100644 --- a/lib/Cake/Console/Command/Task/TestTask.php +++ b/lib/Cake/Console/Command/Task/TestTask.php @@ -205,12 +205,14 @@ class TestTask extends BakeTask { $this->out(++$key . '. ' . $option); $keys[] = $key; } - $selection = $this->in(__d('cake_console', 'Choose an existing class, or enter the name of a class that does not exist')); - if (isset($options[$selection - 1])) { - $selection = $options[$selection - 1]; - } - if ($type !== 'Model') { - $selection = substr($selection, 0, $typeLength * - 1); + while (empty($selection)) { + $selection = $this->in(__d('cake_console', 'Choose an existing class, or enter the name of a class that does not exist')); + if (is_numeric($selection) && isset($options[$selection - 1])) { + $selection = $options[$selection - 1]; + } + if ($type !== 'Model') { + $selection = substr($selection, 0, $typeLength * - 1); + } } return $selection; }