Skip to content

Commit

Permalink
Grabbing the first available config defined in connection manager as …
Browse files Browse the repository at this point in the history
…a default for baking. Fixing a couple of failing test cases
  • Loading branch information
lorenzo committed Oct 3, 2011
1 parent 84f8054 commit d08f916
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/Cake/Console/Command/Task/DbConfigTask.php
Expand Up @@ -355,14 +355,14 @@ public function getConfig() {
App::uses('ConnectionManager', 'Model');
$configs = ConnectionManager::enumConnectionObjects();

$useDbConfig = 'default';
$useDbConfig = current($configs);
if (!is_array($configs) || empty($configs)) {
return $this->execute();
}
$connections = array_keys($configs);

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;
}
Expand Down
16 changes: 7 additions & 9 deletions lib/Cake/Console/Command/Task/TestTask.php
Expand Up @@ -190,15 +190,10 @@ public function getObjectType() {
* @return string Class name the user chose.
*/
public function getClassName($objectType) {
$type = strtolower($objectType);
$type = ucfirst(strtolower($objectType));
$typeLength = strlen($type);
$type = $this->classTypes[$type];
if ($this->plugin) {
if ($type === 'helper') {
$type = 'View/Helper';
} elseif ($type === 'component') {
$type = 'Controller/Component';
} elseif ($type === 'behavior') {
$type = 'Model/Behavior';
}
$plugin = $this->plugin . '.';
$options = App::objects($plugin . $type);
} else {
Expand All @@ -212,7 +207,10 @@ public function getClassName($objectType) {
}
$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])) {
return $options[$selection - 1];
$selection = $options[$selection - 1];
}
if ($type !== 'Model') {
$selection = substr($selection, 0, $typeLength * - 1);
}
return $selection;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php
Expand Up @@ -543,7 +543,7 @@ public function testInteractiveWithPlugin() {
CakePlugin::load('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())
->method('in')
->will($this->onConsecutiveCalls(
Expand Down

0 comments on commit d08f916

Please sign in to comment.