<commit_before><?php
/* SVN FILE: $Id$ */
/**
 * Short description for file.
 *
 * Long description for file
 *
 * PHP versions 4 and 5
 *
 * CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
 * Copyright 2005-2007, Cake Software Foundation, Inc.
 *								1785 E. Sahara Avenue, Suite 490-204
 *								Las Vegas, Nevada 89104
 *
 *  Licensed under The Open Group Test Suite License
 *  Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright		Copyright 2005-2007, Cake Software Foundation, Inc.
 * @link				https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
 * @package			cake
 * @subpackage		cake.cake.tests.libs
 * @since			CakePHP(tm) v 1.2.0.4667
 * @version			$Revision$
 * @modifiedby		$LastChangedBy$
 * @lastmodified	$Date$
 * @license			http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
 */
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_model.php';
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_fixture.php';
vendor('simpletest'.DS.'unit_tester');
/**
 * Short description for class.
 *
 * @package    cake
 * @subpackage cake.cake.tests.lib
 */
class CakeTestCase extends UnitTestCase {
/**
 * Methods used internally.
 *
 * @var array
 * @access private
 */
	var $methods = array('start', 'end', 'startcase', 'endcase', 'starttest', 'endtest');
/**
 * Called when a test case (group of methods) is about to start (to be overriden when needed.)
 * 
 * @param string $method	Test method about to get executed.
 * 
 * @access protected
 */
	function startCase() {
	}
/**
 * Called when a test case (group of methods) has been executed (to be overriden when needed.)
 * 
 * @param string $method	Test method about that was executed.
 * 
 * @access protected
 */
	function endCase() {
	}
/**
 * Called when a test case method is about to start (to be overriden when needed.)
 * 
 * @param string $method	Test method about to get executed.
 * 
 * @access protected
 */
	function startTest($method) {
	}
/**
 * Called when a test case method has been executed (to be overriden when needed.)
 * 
 * @param string $method	Test method about that was executed.
 * 
 * @access protected
 */
	function endTest($method) {
	}
/**
 * Executes a Cake URL, optionally getting the view rendering or what is returned
 * when params['requested'] is set.
 *
 * @param string $url	Cake URL to execute (e.g: /articles/view/455)
 * @param string $requested	Set to true if params['requested'] should be set, false otherwise
 * @param array $data	Data that will be sent to controller. E.g: array('Article' => array('id'=>4))
 * @param string $method	Method to simulate posting of data to controller ('get' or 'post')
 * 
 * @return mixed	What is returned from action (if $requested is true), or view rendered html
 * 
 * @access protected
 */
	function requestAction($url, $requested = true, $data = null, $method = 'post') {
		$params = array();
		
		if (!$requested) {
			$params['return'] = true;
		}
		
		if (is_array($data) && !empty($data)) {
			$data = array('data' => $data);
			
			if (low($method) == 'get') {
				$_GET = $data;
			} else {
				$_POST = $data;
			}
		}
		
		return @Object::requestAction($url, $params);
	}
/**
 * Announces the start of a test.
 *
 * @param string $method Test method just started.
 *
 * @access public
 */
	function before($method) {
		parent::before($method);

		if (isset($this->fixtures) && (!is_array($this->fixtures) || empty($this->fixtures))) {
			unset($this->fixtures);
		}

		// Set up DB connection
		if (isset($this->fixtures) && low($method) == 'start') {
			// Try for test DB
			restore_error_handler();
			@$db =& ConnectionManager::getDataSource('test');
			set_error_handler('simpleTestErrorHandler');

			// Try for default DB
			if (!$db->isConnected()) {
				$db =& ConnectionManager::getDataSource('default');
			}

			// Add test prefix
			$config = $db->config;
			$config['prefix'] .= 'test_suite_';<commit_msg>Fixed issue in CakeTestCase::requestAction() when wanting to get resulting HTML<commit_after><?php
/* SVN FILE: $Id$ */
/**
 * Short description for file.
 *
 * Long description for file
 *
 * PHP versions 4 and 5
 *
 * CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
 * Copyright 2005-2007, Cake Software Foundation, Inc.
 *								1785 E. Sahara Avenue, Suite 490-204
 *								Las Vegas, Nevada 89104
 *
 *  Licensed under The Open Group Test Suite License
 *  Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright		Copyright 2005-2007, Cake Software Foundation, Inc.
 * @link				https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
 * @package			cake
 * @subpackage		cake.cake.tests.libs
 * @since			CakePHP(tm) v 1.2.0.4667
 * @version			$Revision$
 * @modifiedby		$LastChangedBy$
 * @lastmodified	$Date$
 * @license			http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
 */
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_model.php';
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_fixture.php';
vendor('simpletest'.DS.'unit_tester');
/**
 * Short description for class.
 *
 * @package    cake
 * @subpackage cake.cake.tests.lib
 */
class CakeTestCase extends UnitTestCase {
/**
 * Methods used internally.
 *
 * @var array
 * @access private
 */
	var $methods = array('start', 'end', 'startcase', 'endcase', 'starttest', 'endtest');
/**
 * Called when a test case (group of methods) is about to start (to be overriden when needed.)
 * 
 * @param string $method	Test method about to get executed.
 * 
 * @access protected
 */
	function startCase() {
	}
/**
 * Called when a test case (group of methods) has been executed (to be overriden when needed.)
 * 
 * @param string $method	Test method about that was executed.
 * 
 * @access protected
 */
	function endCase() {
	}
/**
 * Called when a test case method is about to start (to be overriden when needed.)
 * 
 * @param string $method	Test method about to get executed.
 * 
 * @access protected
 */
	function startTest($method) {
	}
/**
 * Called when a test case method has been executed (to be overriden when needed.)
 * 
 * @param string $method	Test method about that was executed.
 * 
 * @access protected
 */
	function endTest($method) {
	}
/**
 * Executes a Cake URL, optionally getting the view rendering or what is returned
 * when params['requested'] is set.
 *
 * @param string $url	Cake URL to execute (e.g: /articles/view/455)
 * @param boolean $requested	Set to true if params['requested'] should be set, false otherwise
 * @param array $data	Data that will be sent to controller. E.g: array('Article' => array('id'=>4))
 * @param string $method	Method to simulate posting of data to controller ('get' or 'post')
 * 
 * @return mixed	What is returned from action (if $requested is true), or view rendered html
 * 
 * @access protected
 */
	function requestAction($url, $requested = true, $data = null, $method = 'post') {
		$params = array();
		
		if (!$requested) {
			$params['return'] = true;
		}
		
		if (is_array($data) && !empty($data)) {
			$data = array('data' => $data);
			
			if (low($method) == 'get') {
				$_GET = $data;
			} else {
				$_POST = $data;
			}
		}
		
		$dispatcher =& new Dispatcher();
		if (in_array('return', $params)) {
			$params['return'] = 0;
			ob_start();
			@$dispatcher->dispatch($url, $params);
			
			$result = ob_get_clean();
		} else {
			$params['return'] = 1;
			$params['bare'] = 1;
			$params['requested'] = 1;
			
			$result = @$dispatcher->dispatch($url, $params);
		}
		
		return $result;
	}
/**
 * Announces the start of a test.
 *
 * @param string $method Test method just started.
 *
 * @access public
 */
	function before($method) {
		parent::before($method);

		if (isset($this->fixtures) && (!is_array($this->fixtures) || empty($this->fixtures))) {
			unset($this->fixtures);
		}

		// Set up DB connection
		if (isset($this->fixtures) && low($method) == 'start') {
			// Try for test DB
			restore_error_handler();
			@$db =& ConnectionManager::getDataSource('test');
			set_error_handler('simpleTestErrorHandler');

			// Try for default DB
			if (!$db->isConnected()) {
				$db =& ConnectionManager::getDataSource('default');
			}

			// Add test prefix
			$config = $db->config;
			$config['prefix'] .= 'test_suite_';
{'fraction_non_alphanumeric': 0.1461062157656585, 'fraction_numerical': 0.010954989283162658, 'mean_word_length': 3.467553191489362, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 27, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, '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': '2734792', 'n_tokens_mistral': 2975, 'n_tokens_neox': 2623, 'n_words': 852}