Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing issue where DbConfigTask would try to rebuild

database configuration.

This could happen when using commands like `Console/cake bake controller`.
Using ConnectionManager ensures that the database config file will be loaded
if its available.
  • Loading branch information...
commit 84f805419de669d015da77ee7a296f909d7ef013 1 parent aae2b0c
@markstory markstory authored
View
6 lib/Cake/Console/Command/Task/DbConfigTask.php
@@ -353,14 +353,14 @@ public function bake($configs) {
*/
public function getConfig() {
App::uses('ConnectionManager', 'Model');
+ $configs = ConnectionManager::enumConnectionObjects();
$useDbConfig = 'default';
- $configs = get_class_vars($this->databaseClassName);
- if (!is_array($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');
}
View
30 lib/Cake/Test/Case/Console/Command/Task/DbConfigTaskTest.php
@@ -23,28 +23,6 @@
App::uses('Shell', 'Console');
App::uses('DbConfigTask', 'Console/Command/Task');
-class TEST_DATABASE_CONFIG {
- public $default = array(
- 'driver' => 'mysql',
- 'persistent' => false,
- 'host' => 'localhost',
- 'login' => 'user',
- 'password' => 'password',
- 'database' => 'database_name',
- 'prefix' => '',
- );
-
- public $otherOne = array(
- 'driver' => 'mysql',
- 'persistent' => false,
- 'host' => 'localhost',
- 'login' => 'user',
- 'password' => 'password',
- 'database' => 'other_one',
- 'prefix' => '',
- );
-}
-
/**
* DbConfigTest class
*
@@ -68,7 +46,6 @@ public function setUp() {
);
$this->Task->path = APP . 'Config' . DS;
- $this->Task->databaseClassName = 'TEST_DATABASE_CONFIG';
}
/**
@@ -87,9 +64,12 @@ public function tearDown() {
* @return void
*/
public function testGetConfig() {
- $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('otherOne'));
+ $this->Task->expects($this->at(0))
+ ->method('in')
+ ->will($this->returnValue('test'));
+
$result = $this->Task->getConfig();
- $this->assertEquals('otherOne', $result);
+ $this->assertEquals('test', $result);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.