Skip to content

Commit

Permalink
Update doc blocks and expand tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 24, 2013
1 parent 409e3a5 commit 4f3f90c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
8 changes: 5 additions & 3 deletions lib/Cake/Database/ConnectionManager.php
Expand Up @@ -23,9 +23,9 @@
use Cake\Error;

/**
* Manages loaded instances of DataSource objects
* Manages and loads instances of Connection
*
* Provides an interface to loading and creating connection objects. Acts as
* Provides an interface to loading and creating connection objects. Acts as
* a registry for the connections defined in an application.
*
* Provides an interface for loading and enumerating connections defined in
Expand Down Expand Up @@ -144,7 +144,9 @@ public static function configured() {
* @return boolean true
*/
public static function drop($name) {
static::$_registry->unload($name);
if (isset(static::$_registry)) {
static::$_registry->unload($name);
}
unset(static::$_config[$name]);
return true;
}
Expand Down
12 changes: 5 additions & 7 deletions lib/Cake/Database/ConnectionRegistry.php
Expand Up @@ -11,7 +11,7 @@
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @since CakePHP(tm) v 0.10.x.1402
* @since CakePHP(tm) v3.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Database;
Expand Down Expand Up @@ -50,15 +50,14 @@ protected function _resolveClassName($class) {
* Part of the template method for Cake\Utility\ObjectRegistry::load()
*
* @param string $class The classname that is missing.
* @param string $plugin The plugin the cache is missing in.
* @param string $plugin The plugin the driver is missing in.
* @throws Cake\Database\Exception\MissingDriverException
*/
protected function _throwMissingClassError($class, $plugin) {
throw new MissingDriverException(array(
throw new MissingDriverException([
'class' => $class,
'plugin' => $plugin,
'message' => 'Driver "%s" was not found in.'
));
]);
}

/**
Expand All @@ -67,11 +66,10 @@ protected function _throwMissingClassError($class, $plugin) {
* Part of the template method for Cake\Utility\ObjectRegistry::load()
*
* @param string|Driver $class The classname or object to make.
* @param array $settings An array of settings to use for the driver engine.
* @param array $settings An array of settings to use for the driver.
* @return Connection A connection with the correct driver.
*/
protected function _create($class, $settings) {
$isObject = is_object($class);
if (is_object($class)) {
$instance = $class;
}
Expand Down
7 changes: 1 addition & 6 deletions lib/Cake/Error/MissingDatasourceConfigException.php
@@ -1,7 +1,5 @@
<?php
/**
* MissingDatasourceConfigException class
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
Expand All @@ -12,19 +10,16 @@
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/2.0/en/development/testing.html
* @package Cake.Error
* @since CakePHP(tm) v 3.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace Cake\Error;

/**
* Exception class to be thrown when a datasource configuration is not found
*
* @package Cake.Error
*/
class MissingDatasourceConfigException extends Exception {

protected $_messageTemplate = 'The datasource configuration "%s" was not found in datasources.php';
protected $_messageTemplate = 'The datasource configuration "%s" was not found.';

}
4 changes: 4 additions & 0 deletions lib/Cake/Test/TestCase/Database/ConnectionManagerTest.php
Expand Up @@ -85,6 +85,7 @@ public function testConfigInvalidOptions() {
* Test for errors on duplicate config.
*
* @expectedException Cake\Error\Exception
* @expectedExceptionMessage Cannot reconfigure existing adapter "test_variant"
* @return void
*/
public function testConfigDuplicateConfig() {
Expand All @@ -100,6 +101,7 @@ public function testConfigDuplicateConfig() {
* Test get() failing on missing config.
*
* @expectedException Cake\Error\Exception
* @expectedExceptionMessage The datasource configuration "test_variant" was not found.
* @return void
*/
public function testGetFailOnMissingConfig() {
Expand Down Expand Up @@ -170,6 +172,8 @@ public function testDrop() {
$this->assertTrue(ConnectionManager::drop('test_variant'));
$result = ConnectionManager::configured();
$this->assertNotContains('test_variant', $result);

$this->assertTrue(ConnectionManager::drop('probably_does_not_exist'), 'Should always return true.');
}

}

0 comments on commit 4f3f90c

Please sign in to comment.