Grabbing the first available config defined in connection manager as a default for baking. Fixing a couple of failing test cases

This commit is contained in:
Jose Lorenzo Rodriguez 2011-10-03 11:54:40 -04:30
parent 84f805419d
commit d08f916179
3 changed files with 10 additions and 12 deletions

View file

@ -355,14 +355,14 @@ class DbConfigTask extends Shell {
App::uses('ConnectionManager', 'Model'); App::uses('ConnectionManager', 'Model');
$configs = ConnectionManager::enumConnectionObjects(); $configs = ConnectionManager::enumConnectionObjects();
$useDbConfig = 'default'; $useDbConfig = current($configs);
if (!is_array($configs) || empty($configs)) { if (!is_array($configs) || empty($configs)) {
return $this->execute(); return $this->execute();
} }
$connections = array_keys($configs); $connections = array_keys($configs);
if (count($connections) > 1) { if (count($connections) > 1) {
$useDbConfig = $this->in(__d('cake_console', 'Use Database Config') .':', $connections, 'default'); $useDbConfig = $this->in(__d('cake_console', 'Use Database Config') .':', $connections, $useDbConfig);
} }
return $useDbConfig; return $useDbConfig;
} }

View file

@ -190,15 +190,10 @@ class TestTask extends BakeTask {
* @return string Class name the user chose. * @return string Class name the user chose.
*/ */
public function getClassName($objectType) { public function getClassName($objectType) {
$type = strtolower($objectType); $type = ucfirst(strtolower($objectType));
$typeLength = strlen($type);
$type = $this->classTypes[$type];
if ($this->plugin) { if ($this->plugin) {
if ($type === 'helper') {
$type = 'View/Helper';
} elseif ($type === 'component') {
$type = 'Controller/Component';
} elseif ($type === 'behavior') {
$type = 'Model/Behavior';
}
$plugin = $this->plugin . '.'; $plugin = $this->plugin . '.';
$options = App::objects($plugin . $type); $options = App::objects($plugin . $type);
} else { } else {
@ -212,7 +207,10 @@ class TestTask extends BakeTask {
} }
$selection = $this->in(__d('cake_console', 'Choose an existing class, or enter the name of a class that does not exist')); $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])) { if (isset($options[$selection - 1])) {
return $options[$selection - 1]; $selection = $options[$selection - 1];
}
if ($type !== 'Model') {
$selection = substr($selection, 0, $typeLength * - 1);
} }
return $selection; return $selection;
} }

View file

@ -543,7 +543,7 @@ class TestTaskTest extends CakeTestCase {
CakePlugin::load('TestPlugin'); CakePlugin::load('TestPlugin');
$this->Task->plugin = 'TestPlugin'; $this->Task->plugin = 'TestPlugin';
$path = $testApp . 'TestPlugin' . DS . 'Test' . DS . 'Case' . DS . 'View' . DS . 'Helper' . DS . 'OtherHelperHelperTest.php'; $path = $testApp . 'TestPlugin' . DS . 'Test' . DS . 'Case' . DS . 'View' . DS . 'Helper' . DS . 'OtherHelperTest.php';
$this->Task->expects($this->any()) $this->Task->expects($this->any())
->method('in') ->method('in')
->will($this->onConsecutiveCalls( ->will($this->onConsecutiveCalls(