<commit_before><?php
/**
 * CakeTestSuiteDispatcher controls dispatching TestSuite web based requests.
 *
 * PHP versions 4 and 5
 *
 * CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
 * Copyright 2005-2009, 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          https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
 * @package       cake
 * @subpackage    cake.cake.tests.lib
 * @since         CakePHP(tm) v 1.3
 * @license       http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
 */
require_once CAKE_TESTS_LIB . 'test_manager.php';
require_once CAKE_TESTS_LIB . 'cake_test_menu.php';

/**
 * CakeTestSuiteDispatcher handles web requests to the test suite and runs the correct action.
 *
 * @package cake.tests.libs
 */
class CakeTestSuiteDispatcher {
/**
 * 'Request' parameters
 *
 * @var array
 */
	var $params = array(
		'codeCoverage' => false,
		'group' => null,
		'case' => null,
		'app' => false,
		'plugin' => null,
		'output' => 'html',
		'show' => 'groups'
	);

/**
 * Runs the actions required by the URL parameters.
 *
 * @return void
 */
	function dispatch() {
		CakeTestMenu::testHeader();
		CakeTestMenu::testSuiteHeader();

		$this->_checkSimpleTest();
		$this->_parseParams();

		if ($this->params['group']) {
			$this->_runGroupTest();
		} elseif ($this->params['case']) {
			$this->_runTestCase();
		} elseif (isset($_GET['show']) && $_GET['show'] == 'cases') {
			CakeTestMenu::testCaseList();
		} else {
			CakeTestMenu::groupTestList();
		}

		CakeTestMenu::footer();
		$output = ob_get_clean();
		echo $output;
	}

/**
 * Checks that simpleTest is installed.  Will exit if it doesn't
 *
 * @return void
 */
	function _checkSimpleTest() {
		if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) {
			CakeTestMenu::testHeader();
			include CAKE_TESTS_LIB . 'simpletest.php';
			CakeTestMenu::footer();
			exit();
		}
	}

/**
 * Checks for the xdebug extension required to do code coverage. Displays an error
 * if xdebug isn't installed.
 *
 * @return void
 */
	function _checkXdebug() {
		if (!extension_loaded('xdebug')) {
			CakeTestMenu::testHeader();
			include CAKE_TESTS_LIB . 'xdebug.php';
			CakeTestMenu::footer();
			exit();
		}
	}

/**
 * Sets the Manager to use for the request.
 *
 * @return string The manager class name
 * @static
 */
	function getManager() {
		$className = ucwords($this->params['output']) . 'TestManager';
		if (class_exists($className)) {
			$this->_manager = $className;
			return;
		} else {
			$this->_manager = 'TextTestManager';
		}
	}

/**
 * Gets the reporter based on the request parameters
 *
 * @return void
 */
	function &getReporter() {
		static $Reporter = NULL;
		if (!$Reporter) {
			$coreClass = 'Cake' . $this->params['output'] . 'Reporter';
			$coreFile = CAKE_TESTS_LIB . 'cake_' . strtolower($this->params['output']) . '_reporter.php';
			
			$appClass = $this->params['output'] . 'Reporter';
			$appFile = APPLIBS . 'test_suite' . DS . strtolower($this->params['output']) . '_reporter.php';
			if (file_exists($coreFile)) {
				require_once $coreFile;
				$Reporter =& new $coreClass();
			} elseif (file_exists($appFile)) {
				require_once $appFile;
				$Reporter =& new $appClass();
			}
		}
		return $Reporter;
	}

/**
 * Parse url params into a 'request'
 *
 * @return void
 */
	function _parseParams() {
		if (!isset($_SERVER['SERVER_NAME'])) {
			$_SERVER['SERVER_NAME'] = '';
		}
		foreach ($this->params as $key => $value) {
			if (isset($_GET[$key])) {
				$this->params[$key] = $_GET[$key];
			}
		}
		if (isset($_GET['code_coverage'])) {
			$this->params['codeCoverage'] = true;
			require_once CAKE_TESTS_LIB . 'code_coverage_manager.php';
			$this->_checkXdebug();
		}
		$this->getManager();
	}

/**
 * Runs the group test case.
 *
 * @return void
 */
	function _runGroupTest() {
		if ('all' == $this->params['group']) {
			TestManager::runAllTests(CakeTestsGetReporter());
		} else {
			if ($this->params['codeCoverage']) {
				CodeCoverageManager::start($this->params['group'], CakeTestSuiteDispatcher::getReporter());
			}
			TestManager::runGroupTest(ucfirst($this->params['group']), CakeTestSuiteDispatcher::getReporter());
			if ($this->params['codeCoverage']) {
				CodeCoverageManager::report();
			}
		}
		CakeTestMenu::runMore();
		CakeTestMenu::analyzeCodeCoverage();
	}

/**
 * Runs a test case file.
 *
 * @return void
 */
	function _runTestCase() {
		if ($this->params['codeCoverage']) {
			CodeCoverageManager::start($_GET['case'], CakeTestsGetReporter());
		}

		TestManager::runTestCase($_GET['case'], CakeTestsGetReporter());

		if ($this->params['codeCoverage']) {
			CodeCoverageManager::report();
		}
		CakeTestMenu::runMore();
		CakeTestMenu::analyzeCodeCoverage();
	}
}
?><commit_msg>Fixing occurances of CakeTestsGetReporter and fixing issues loading reporters.<commit_after><?php
/**
 * CakeTestSuiteDispatcher controls dispatching TestSuite web based requests.
 *
 * PHP versions 4 and 5
 *
 * CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
 * Copyright 2005-2009, 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          https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
 * @package       cake
 * @subpackage    cake.cake.tests.lib
 * @since         CakePHP(tm) v 1.3
 * @license       http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
 */
require_once CAKE_TESTS_LIB . 'test_manager.php';
require_once CAKE_TESTS_LIB . 'cake_test_menu.php';

/**
 * CakeTestSuiteDispatcher handles web requests to the test suite and runs the correct action.
 *
 * @package cake.tests.libs
 */
class CakeTestSuiteDispatcher {
/**
 * 'Request' parameters
 *
 * @var array
 */
	var $params = array(
		'codeCoverage' => false,
		'group' => null,
		'case' => null,
		'app' => false,
		'plugin' => null,
		'output' => 'html',
		'show' => 'groups'
	);

/**
 * Runs the actions required by the URL parameters.
 *
 * @return void
 */
	function dispatch() {
		CakeTestMenu::testHeader();
		CakeTestMenu::testSuiteHeader();

		$this->_checkSimpleTest();
		$this->_parseParams();

		if ($this->params['group']) {
			$this->_runGroupTest();
		} elseif ($this->params['case']) {
			$this->_runTestCase();
		} elseif (isset($_GET['show']) && $_GET['show'] == 'cases') {
			CakeTestMenu::testCaseList();
		} else {
			CakeTestMenu::groupTestList();
		}

		CakeTestMenu::footer();
		$output = ob_get_clean();
		echo $output;
	}

/**
 * Checks that simpleTest is installed.  Will exit if it doesn't
 *
 * @return void
 */
	function _checkSimpleTest() {
		if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) {
			CakeTestMenu::testHeader();
			include CAKE_TESTS_LIB . 'simpletest.php';
			CakeTestMenu::footer();
			exit();
		}
	}

/**
 * Checks for the xdebug extension required to do code coverage. Displays an error
 * if xdebug isn't installed.
 *
 * @return void
 */
	function _checkXdebug() {
		if (!extension_loaded('xdebug')) {
			CakeTestMenu::testHeader();
			include CAKE_TESTS_LIB . 'xdebug.php';
			CakeTestMenu::footer();
			exit();
		}
	}

/**
 * Sets the Manager to use for the request.
 *
 * @return string The manager class name
 * @static
 */
	function getManager() {
		$className = ucwords($this->params['output']) . 'TestManager';
		if (class_exists($className)) {
			$this->_manager = $className;
			return;
		} else {
			$this->_manager = 'TextTestManager';
		}
	}

/**
 * Gets the reporter based on the request parameters
 *
 * @return void
 */
	function &getReporter() {
		static $Reporter = NULL;
		if (!$Reporter) {
			$coreClass = 'Cake' . ucwords($this->params['output']) . 'Reporter';
			$coreFile = CAKE_TESTS_LIB . 'cake_' . strtolower($this->params['output']) . '_reporter.php';

			$appClass = $this->params['output'] . 'Reporter';
			$appFile = APPLIBS . 'test_suite' . DS . strtolower($this->params['output']) . '_reporter.php';
			if (include_once $coreFile) {
				$Reporter =& new $coreClass();
			} elseif (include_once $appFile) {
				$Reporter =& new $appClass();
			}
		}
		return $Reporter;
	}

/**
 * Parse url params into a 'request'
 *
 * @return void
 */
	function _parseParams() {
		if (!isset($_SERVER['SERVER_NAME'])) {
			$_SERVER['SERVER_NAME'] = '';
		}
		foreach ($this->params as $key => $value) {
			if (isset($_GET[$key])) {
				$this->params[$key] = $_GET[$key];
			}
		}
		if (isset($_GET['code_coverage'])) {
			$this->params['codeCoverage'] = true;
			require_once CAKE_TESTS_LIB . 'code_coverage_manager.php';
			$this->_checkXdebug();
		}
		$this->getManager();
	}

/**
 * Runs the group test case.
 *
 * @return void
 */
	function _runGroupTest() {
		if ('all' == $this->params['group']) {
			TestManager::runAllTests(CakeTestsGetReporter());
		} else {
			if ($this->params['codeCoverage']) {
				CodeCoverageManager::start($this->params['group'], CakeTestSuiteDispatcher::getReporter());
			}
			TestManager::runGroupTest(ucfirst($this->params['group']), CakeTestSuiteDispatcher::getReporter());
			if ($this->params['codeCoverage']) {
				CodeCoverageManager::report();
			}
		}
		CakeTestMenu::runMore();
		CakeTestMenu::analyzeCodeCoverage();
	}

/**
 * Runs a test case file.
 *
 * @return void
 */
	function _runTestCase() {
		if ($this->params['codeCoverage']) {
			CodeCoverageManager::start($_GET['case'], CakeTestSuiteDispatcher::getReporter());
		}

		TestManager::runTestCase($_GET['case'], CakeTestSuiteDispatcher::getReporter());

		if ($this->params['codeCoverage']) {
			CodeCoverageManager::report();
		}
		CakeTestMenu::runMore();
		CakeTestMenu::analyzeCodeCoverage();
	}
}
?>
{'fraction_non_alphanumeric': 0.16920490506329114, 'fraction_numerical': 0.003955696202531646, 'mean_word_length': 3.964653902798233, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 73, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4929988', 'n_tokens_mistral': 3738, 'n_tokens_neox': 3325, 'n_words': 716}