From 4d4d9e78f8210a64ba6a0628038b177082a4f8bf Mon Sep 17 00:00:00 2001 From: Mark Story Date: Fri, 23 Apr 2010 22:04:16 -0400 Subject: [PATCH] Adding App::setObjects() as a temporary way to modify App's cache of plugins. This allows the DispatcherTest to successfully run. --- cake/libs/configure.php | 13 +++++++++++++ cake/tests/cases/dispatcher.test.php | 7 ++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/cake/libs/configure.php b/cake/libs/configure.php index 9ba578f7c..1a6e7645b 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -786,6 +786,19 @@ class App extends Object { return $_this->__objects[$name]; } +/** + * Allows you to modify the object listings that App maintains inside of it + * Useful for testing + * + * @param string $type Type of object listing you are changing + * @param array $values The values $type should be set to. + * @return void + */ + public static function setObjects($type, $values) { + $_this = App::getInstance(); + $_this->__objects[$type] = $values; + } + /** * Finds classes based on $name or specific file(s) to search. * diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index ebd32790c..bce5c7a9c 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -1464,8 +1464,7 @@ class DispatcherTest extends CakeTestCase { $plugins[] = 'MyPlugin'; $plugins[] = 'ArticlesTest'; - $app = App::getInstance(); - $app->__objects['plugin'] = $plugins; + App::setObjects('plugin', $plugins); Router::reload(); $Dispatcher =& new TestDispatcher(); @@ -1560,9 +1559,7 @@ class DispatcherTest extends CakeTestCase { $plugins = App::objects('plugin'); $plugins[] = 'MyPlugin'; - $app = App::getInstance(); - $app->__objects['plugin'] = $plugins; - + App::setObjects('plugin', $plugins); Router::reload(); $Dispatcher =& new TestDispatcher();