<commit_before><?php
/**
 * TestManager for CakePHP Test suite.
 *
 * PHP versions 4 and 5
 *
 * CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
 * 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
 * @package       cake
 * @subpackage    cake.cake.tests.lib
 * @since         CakePHP(tm) v 1.2.0.4433
 * @license       http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
 */
define('CORE_TEST_CASES', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'cases');
define('CORE_TEST_GROUPS', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'groups');
define('APP_TEST_CASES', TESTS . 'cases');
define('APP_TEST_GROUPS', TESTS . 'groups');

PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'DEFAULT');
require_once CAKE_TESTS_LIB . 'cake_test_suite.php';

/**
 * TestManager is the base class that handles loading and initiating the running
 * of TestCase and TestSuite classes that the user has selected.
 *
 * @package       cake
 * @subpackage    cake.cake.tests.lib
 */
class TestManager {
/**
 * Extension suffix for test case files.
 *
 * @var string
 */
	protected static $_testExtension = '.test.php';

/**
 * Is this test an AppTest?
 *
 * @var boolean
 */
	public $appTest = false;

/**
 * Is this test a plugin test?
 *
 * @var mixed boolean false or string name of the plugin being used.
 */
	public $pluginTest = false;

/**
 * String to filter test case method names by.
 *
 * @var string
 */
	public $filter = false;

/**
 * TestSuite container for single or grouped test files
 *
 * @var PHPUnit_Framework_TestSuite
 */
	protected $_testSuite = null;

/**
 * Object instance responsible for managing the test fixtures
 *
 * @var CakeFixtureManager
 */
	protected $_fixtureManager = null;

/**
 * Constructor for the TestManager class
 *
 * @return void
 */
	public function __construct($params = array()) {
		require_once(CAKE_TESTS_LIB . 'cake_test_case.php');
		if (isset($params['app'])) {
			$this->appTest = true;
		}
		if (isset($params['plugin'])) {
			$this->pluginTest = htmlentities($params['plugin']);
		}
		if (
			isset($params['filter']) && 
			$params['filter'] !== false &&
			preg_match('/^[a-zA-Z0-9_]/', $params['filter'])
		) {
			$this->filter = '/' . $params['filter'] . '/';
		}
	}

/**
 * Runs all tests in the Application depending on the current appTest setting
 *
 * @param PHPUnit_Framework_TestListener $reporter Reporter instance to attach to the test case.
 * @return mixed
 */
	public function runAllTests(&$reporter) {
		$testCases = $this->_getTestFileList($this->_getTestsPath($reporter->params));

		if ($this->appTest) {
			$test = $this->getTestSuite(__('All App Tests', true));
		} else if ($this->pluginTest) {
			$test =  $this->getTestSuite(sprintf(__('All %s Plugin Tests', true), Inflector::humanize($this->pluginTest)));
		} else {
			$test =  $this->getTestSuite(__('All Core Tests', true));
		}

		foreach ($testCases as $testCase) {
			$test->addTestFile($testCase);
		}

		return $this->run($reporter);
	}

/**
 * Runs a specific test case file
 *
 * @param string $testCaseFile Filename of the test to be run.
 * @param PHPUnit_Framework_TestListener $reporter Reporter instance to attach to the test case.
 * @throws InvalidArgumentException if the supplied $testCaseFile does not exists
 * @return mixed Result of test case being run.
 */
	public function runTestCase($testCaseFile, PHPUnit_Framework_TestListener $reporter, $codeCoverage = false) {
		$testCaseFileWithPath = $this->_getTestsPath($reporter->params) . DS . $testCaseFile;

		if (!file_exists($testCaseFileWithPath) || strpos($testCaseFileWithPath, '..')) {
			throw new InvalidArgumentException(sprintf(__('Unable to load test file %s'), htmlentities($testCaseFile)));
		}

		$testSuite = $this->getTestSuite(sprintf(__('Individual test case: %s', true), $testCaseFile));
		$testSuite->addTestFile($testCaseFileWithPath);
		return $this->run($reporter, $codeCoverage);<commit_msg>Adding a params var to the TestManager to hold through the lifecicle of the object<commit_after><?php
/**
 * TestManager for CakePHP Test suite.
 *
 * PHP versions 4 and 5
 *
 * CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
 * 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
 * @package       cake
 * @subpackage    cake.cake.tests.lib
 * @since         CakePHP(tm) v 1.2.0.4433
 * @license       http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
 */
define('CORE_TEST_CASES', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'cases');
define('CORE_TEST_GROUPS', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'groups');
define('APP_TEST_CASES', TESTS . 'cases');
define('APP_TEST_GROUPS', TESTS . 'groups');

PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'DEFAULT');
require_once CAKE_TESTS_LIB . 'cake_test_suite.php';

/**
 * TestManager is the base class that handles loading and initiating the running
 * of TestCase and TestSuite classes that the user has selected.
 *
 * @package       cake
 * @subpackage    cake.cake.tests.lib
 */
class TestManager {
/**
 * Extension suffix for test case files.
 *
 * @var string
 */
	protected static $_testExtension = '.test.php';

/**
 * Is this test an AppTest?
 *
 * @var boolean
 */
	public $appTest = false;

/**
 * Is this test a plugin test?
 *
 * @var mixed boolean false or string name of the plugin being used.
 */
	public $pluginTest = false;

/**
 * String to filter test case method names by.
 *
 * @var string
 */
	public $filter = false;

/**
 * TestSuite container for single or grouped test files
 *
 * @var PHPUnit_Framework_TestSuite
 */
	protected $_testSuite = null;

/**
 * Object instance responsible for managing the test fixtures
 *
 * @var CakeFixtureManager
 */
	protected $_fixtureManager = null;

/**
 * Params to configure test runner
 *
 * @var CakeFixtureManager
 */
	public $params = array();

/**
 * Constructor for the TestManager class
 *
 * @return void
 */
	public function __construct($params = array()) {
		require_once(CAKE_TESTS_LIB . 'cake_test_case.php');

		$this->params = $params;
		if (isset($params['app'])) {
			$this->appTest = true;
		}
		if (isset($params['plugin'])) {
			$this->pluginTest = htmlentities($params['plugin']);
		}
		if (
			isset($params['filter']) && 
			$params['filter'] !== false &&
			preg_match('/^[a-zA-Z0-9_]/', $params['filter'])
		) {
			$this->filter = '/' . $params['filter'] . '/';
		}
	}

/**
 * Runs all tests in the Application depending on the current appTest setting
 *
 * @param PHPUnit_Framework_TestListener $reporter Reporter instance to attach to the test case.
 * @return mixed
 */
	public function runAllTests(&$reporter) {
		$testCases = $this->_getTestFileList($this->_getTestsPath($reporter->params));

		if ($this->appTest) {
			$test = $this->getTestSuite(__('All App Tests', true));
		} else if ($this->pluginTest) {
			$test =  $this->getTestSuite(sprintf(__('All %s Plugin Tests', true), Inflector::humanize($this->pluginTest)));
		} else {
			$test =  $this->getTestSuite(__('All Core Tests', true));
		}

		foreach ($testCases as $testCase) {
			$test->addTestFile($testCase);
		}

		return $this->run($reporter);
	}

/**
 * Runs a specific test case file
 *
 * @param string $testCaseFile Filename of the test to be run.
 * @param PHPUnit_Framework_TestListener $reporter Reporter instance to attach to the test case.
 * @throws InvalidArgumentException if the supplied $testCaseFile does not exists
 * @return mixed Result of test case being run.
 */
	public function runTestCase($testCaseFile, PHPUnit_Framework_TestListener $reporter, $codeCoverage = false) {
		$this->loadCase($testCaseFile);
		return $this->run($reporter, $codeCoverage);
{'fraction_non_alphanumeric': 0.13852969348659003, 'fraction_numerical': 0.008381226053639846, 'mean_word_length': 4.028898254063817, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3927917', 'n_tokens_mistral': 2763, 'n_tokens_neox': 2578, 'n_words': 730}