diff --git a/cake/console/libs/tasks/db_config.php b/cake/console/libs/tasks/db_config.php index 5445c6f22c6..70e8be0eadf 100644 --- a/cake/console/libs/tasks/db_config.php +++ b/cake/console/libs/tasks/db_config.php @@ -40,7 +40,7 @@ class DbConfigTask extends Shell { * @var array * @access private */ - private $__defaultConfig = array( + protected $_defaultConfig = array( 'name' => 'default', 'driver'=> 'mysql', 'persistent'=> 'false', 'host'=> 'localhost', 'login'=> 'root', 'password'=> 'password', 'database'=> 'project_name', 'schema'=> null, 'prefix'=> null, 'encoding' => null, 'port' => null @@ -174,9 +174,10 @@ protected function _interactive() { $config = compact('name', 'driver', 'persistent', 'host', 'login', 'password', 'database', 'prefix', 'encoding', 'port', 'schema'); - while ($this->__verify($config) == false) { + while ($this->_verify($config) == false) { $this->_interactive(); } + $dbConfigs[] = $config; $doneYet = $this->in('Do you wish to add another database configuration?', null, 'n'); @@ -195,8 +196,8 @@ protected function _interactive() { * * @return boolean True if user says it looks good, false otherwise */ - private function __verify($config) { - $config = array_merge($this->__defaultConfig, $config); + protected function _verify($config) { + $config = array_merge($this->_defaultConfig, $config); extract($config); $this->out(); $this->hr(); @@ -257,7 +258,7 @@ public function bake($configs) { $temp = get_class_vars(get_class($db)); foreach ($temp as $configName => $info) { - $info = array_merge($this->__defaultConfig, $info); + $info = array_merge($this->_defaultConfig, $info); if (!isset($info['schema'])) { $info['schema'] = null; diff --git a/cake/tests/cases/console/libs/tasks/db_config.test.php b/cake/tests/cases/console/libs/tasks/db_config.test.php index 7efc588c96d..b515d7e1daa 100644 --- a/cake/tests/cases/console/libs/tasks/db_config.test.php +++ b/cake/tests/cases/console/libs/tasks/db_config.test.php @@ -123,20 +123,21 @@ public function testInitialize() { */ public function testExecuteIntoInteractive() { $this->Task->initialize(); + $this->Task = $this->getMock('DbConfigTask', array('in', '_stop', 'createFile'), array(&$this->Dispatcher)); $this->Task->expects($this->once())->method('_stop'); - $this->Task->expects($this->at(3))->method('in')->will($this->returnValue('default')); - $this->Task->expects($this->at(4))->method('in')->will($this->returnValue('mysql')); - $this->Task->expects($this->at(5))->method('in')->will($this->returnValue('n')); - $this->Task->expects($this->at(6))->method('in')->will($this->returnValue('localhost')); - $this->Task->expects($this->at(7))->method('in')->will($this->returnValue('n')); - $this->Task->expects($this->at(8))->method('in')->will($this->returnValue('root')); - $this->Task->expects($this->at(9))->method('in')->will($this->returnValue('password')); - $this->Task->expects($this->at(10))->method('in')->will($this->returnValue('cake_test')); - $this->Task->expects($this->at(11))->method('in')->will($this->returnValue('n')); - $this->Task->expects($this->at(12))->method('in')->will($this->returnValue('n')); - $this->Task->expects($this->at(13))->method('_verify')->will($this->returnValue(true)); - $this->Task->expects($this->at(14))->method('in')->will($this->returnValue('y')); + $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('default')); //name + $this->Task->expects($this->at(1))->method('in')->will($this->returnValue('mysql')); //db type + $this->Task->expects($this->at(2))->method('in')->will($this->returnValue('n')); //persistant + $this->Task->expects($this->at(3))->method('in')->will($this->returnValue('localhost')); //server + $this->Task->expects($this->at(4))->method('in')->will($this->returnValue('n')); //port + $this->Task->expects($this->at(5))->method('in')->will($this->returnValue('root')); //user + $this->Task->expects($this->at(6))->method('in')->will($this->returnValue('password')); //password + $this->Task->expects($this->at(10))->method('in')->will($this->returnValue('cake_test')); //db + $this->Task->expects($this->at(11))->method('in')->will($this->returnValue('n')); //prefix + $this->Task->expects($this->at(12))->method('in')->will($this->returnValue('n')); //encoding + $this->Task->expects($this->at(13))->method('in')->will($this->returnValue('y')); //looks good + $this->Task->expects($this->at(14))->method('in')->will($this->returnValue('n')); //another $result = $this->Task->execute(); }