Skip to content

Commit

Permalink
Adding tests for merging of report data.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed May 8, 2010
1 parent ac5f731 commit fad99ad
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions cake/tests/cases/libs/html_coverage_report.test.php
Expand Up @@ -35,6 +35,69 @@ function testGetPathFilter() {
$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
*
Expand Down

0 comments on commit fad99ad

Please sign in to comment.