From 4622ec44c229144206b2af6e8701d8756bffee73 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 16 Aug 2010 23:33:07 -0400 Subject: [PATCH] Updating the skel and app test.php's to not make a global variable for the dispatcher. This dramatically improves the performance of the web test runner. --- app/webroot/test.php | 3 +-- cake/console/templates/skel/webroot/test.php | 13 ++++++------- cake/tests/lib/cake_test_suite_dispatcher.php | 10 ++++++++++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/webroot/test.php b/app/webroot/test.php index 2c2e9a82b..2c8b842e9 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -90,5 +90,4 @@ if (Configure::read('debug') < 1) { require_once CAKE_TESTS_LIB . 'cake_test_suite_dispatcher.php'; -$Dispatcher = new CakeTestSuiteDispatcher(); -$Dispatcher->dispatch(); +CakeTestSuiteDispatcher::run(); diff --git a/cake/console/templates/skel/webroot/test.php b/cake/console/templates/skel/webroot/test.php index 097a23dd1..2c8b842e9 100644 --- a/cake/console/templates/skel/webroot/test.php +++ b/cake/console/templates/skel/webroot/test.php @@ -5,15 +5,15 @@ * PHP versions 4 and 5 * * CakePHP(tm) Tests - * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) + * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * * Licensed under The Open Group Test Suite License * Redistributions of files must retain the above copyright notice. * - * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) - * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests + * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) + * @link http://book.cakephp.org/view/1196/Testing * @package cake - * @subpackage cake.cake.tests.libs + * @subpackage cake.app.webroot * @since CakePHP(tm) v 1.2.0.4433 * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ @@ -85,10 +85,9 @@ if (isset($corePath[0])) { } if (Configure::read('debug') < 1) { - die(__('Debug setting does not allow access to this url.')); + die(__('Debug setting does not allow access to this url.', true)); } require_once CAKE_TESTS_LIB . 'cake_test_suite_dispatcher.php'; -$Dispatcher = new CakeTestSuiteDispatcher(); -$Dispatcher->dispatch(); +CakeTestSuiteDispatcher::run(); diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index f7f1ed9db..19d83af56 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -113,6 +113,16 @@ class CakeTestSuiteDispatcher { return $value; } +/** + * Static method to initialize the test runner, keeps global space clean + * + * @return void + */ + public static function run() { + $dispatcher = new CakeTestSuiteDispatcher(); + $dispatcher->dispatch(); + } + /** * Checks that PHPUnit is installed. Will exit if it doesn't *