Skip to content
Permalink
Browse files

Update doc blocks and expand tests.

  • Loading branch information...
markstory committed Aug 24, 2013
1 parent 409e3a5 commit 4f3f90c2c74d4aa91cf1f020f14a1a0d1bbd8a5c
@@ -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
@@ -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;
}
@@ -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;
@@ -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.'
));
]);
}
/**
@@ -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;
}
@@ -1,7 +1,5 @@
<?php
/**
* MissingDatasourceConfigException class
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
@@ -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.';
}
@@ -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() {
@@ -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() {
@@ -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.
You can’t perform that action at this time.