<commit_before><?php

require_once CAKE . 'tests' . DS . 'lib' . DS . 'coverage' . DS . 'html_coverage_report.php';

class HtmlCoverageReportTest extends CakeTestCase {
/**
 * setup
 *
 * @return void
 */
	public function setUp() {
		$reporter = new CakeBaseReporter();
		$reporter->params = array('app' => false, 'plugin' => false, 'group' => false);
		$coverage = array();
		$this->Coverage = new HtmlCoverageReport($coverage, $reporter);
	}

/**
 * test getting the path filters.
 *
 * @return void
 */
	function testGetPathFilter() {
		$this->Coverage->appTest = false;
		$result = $this->Coverage->getPathFilter();
		$this->assertEquals(TEST_CAKE_CORE_INCLUDE_PATH, $result);

		$this->Coverage->appTest = true;
		$result = $this->Coverage->getPathFilter();
		$this->assertEquals(ROOT . DS . APP_DIR . DS, $result);

		$this->Coverage->appTest = false;
		$this->Coverage->pluginTest = 'test_plugin';
		$result = $this->Coverage->getPathFilter();
		$this->assertEquals(ROOT . DS . APP_DIR . DS . 'plugins' . DS .'test_plugin' . DS, $result);
	}

/**
 * teardown
 *
 * @return void
 */
	function tearDown() {
		unset($this->Coverage);
	}
}<commit_msg>Adding tests for merging of report data.<commit_after><?php

require_once CAKE . 'tests' . DS . 'lib' . DS . 'coverage' . DS . 'html_coverage_report.php';

class HtmlCoverageReportTest extends CakeTestCase {
/**
 * setup
 *
 * @return void
 */
	public function setUp() {
		$reporter = new CakeBaseReporter();
		$reporter->params = array('app' => false, 'plugin' => false, 'group' => false);
		$coverage = array();
		$this->Coverage = new HtmlCoverageReport($coverage, $reporter);
	}

/**
 * test getting the path filters.
 *
 * @return void
 */
	function testGetPathFilter() {
		$this->Coverage->appTest = false;
		$result = $this->Coverage->getPathFilter();
		$this->assertEquals(TEST_CAKE_CORE_INCLUDE_PATH, $result);

		$this->Coverage->appTest = true;
		$result = $this->Coverage->getPathFilter();
		$this->assertEquals(ROOT . DS . APP_DIR . DS, $result);

		$this->Coverage->appTest = false;
		$this->Coverage->pluginTest = 'test_plugin';
		$result = $this->Coverage->getPathFilter();
		$this->assertEquals(ROOT . DS . APP_DIR . DS . 'plugins' . DS .'test_plugin' . DS, $result);
	}

/**
 * test filtering coverage data.
 *
 * @return void
 */
	function testFilterCoverageDataByPathRemovingElements() {
		$data = array(
			array(
				'files' => array(
					TEST_CAKE_CORE_INCLUDE_PATH . 'dispatcher.php' => array(
						10 => -1,
						12 => 1
					),
					APP . 'app_model.php' => array(
						50 => 1,
						52 => -1
					)
				)
			)
		);
		$this->Coverage->setCoverage($data);
		$result = $this->Coverage->filterCoverageDataByPath(TEST_CAKE_CORE_INCLUDE_PATH);
		$this->assertTrue(isset($result[TEST_CAKE_CORE_INCLUDE_PATH . 'dispatcher.php']));
		$this->assertFalse(isset($result[APP . 'app_model.php']));
	}

/**
 * test that filterCoverageDataByPath correctly merges data sets in each test run.
 *
 * @return void
 */
	function testFilterCoverageDataCorrectlyMergingValues() {
		$data = array(
			array(
				'files' => array(
					TEST_CAKE_CORE_INCLUDE_PATH . 'dispatcher.php' => array(
						10 => -1,
						12 => 1
					),
				)
			),
			array(
				'files' => array(
					TEST_CAKE_CORE_INCLUDE_PATH . 'dispatcher.php' => array(
						10 => 1,
						12 => -1,
						50 => 1,
						51 => -1
					),
				)
			),
		);
		$this->Coverage->setCoverage($data);
		$result = $this->Coverage->filterCoverageDataByPath(TEST_CAKE_CORE_INCLUDE_PATH);

		$path = TEST_CAKE_CORE_INCLUDE_PATH . 'dispatcher.php';
		$this->assertTrue(isset($result[$path]));
		$this->assertEquals(1, $result[$path][10]);
		$this->assertEquals(1, $result[$path][12]);
		$this->assertEquals(1, $result[$path][50]);
		$this->assertEquals(-1, $result[$path][51]);
	}

/**
 * teardown
 *
 * @return void
 */
	function tearDown() {
		unset($this->Coverage);
	}
}
{'fraction_non_alphanumeric': 0.17707530197892574, 'fraction_numerical': 0.01079414032382421, 'mean_word_length': 3.5950413223140494, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '5101876', 'n_tokens_mistral': 1600, 'n_tokens_neox': 1358, 'n_words': 258}