fixed a couple bugs in code coverage gathering; renamed tunit.js to testify.js
This commit is contained in:
parent
3c27ef31f4
commit
725d847ce9
@ -19,12 +19,22 @@
|
||||
$refClasses[] = new ReflectionClass($class);
|
||||
}
|
||||
|
||||
$newData[$file] = array();
|
||||
|
||||
$newData[$file] = array(
|
||||
'classes' => array(),
|
||||
'procedural' => array(
|
||||
'loc' => 0,
|
||||
'dloc' => 0,
|
||||
'cloc' => 0
|
||||
)
|
||||
);
|
||||
foreach ($data as $line => $unitsCovered) {
|
||||
$loc = 1;
|
||||
$dloc = ($unitsCovered === self::DEAD) ? 1 : 0;
|
||||
$cloc = ($unitsCovered > 0) ? 1 : 0;
|
||||
|
||||
|
||||
|
||||
//find the class this line resides in, if any
|
||||
$class = null;
|
||||
foreach ($refClasses as $refClass) {
|
||||
@ -54,17 +64,9 @@
|
||||
|
||||
//procedural code
|
||||
if ($class === null) {
|
||||
if (isset($newData[$file]['procedural'])) {
|
||||
$newData[$file]['procedural']['loc'] += $loc;
|
||||
$newData[$file]['procedural']['dloc'] += $dloc;
|
||||
$newData[$file]['procedural']['cloc'] += $cloc;
|
||||
} else {
|
||||
$newData[$file]['procedural'] = array(
|
||||
'loc' => $loc,
|
||||
'dloc' => $dloc,
|
||||
'cloc' => $cloc
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -143,7 +145,7 @@
|
||||
//copy css over
|
||||
$template = dirname(__FILE__) . DIRECTORY_SEPARATOR . self::TEMPLATE_DIR . DIRECTORY_SEPARATOR;
|
||||
copy($template . 'style.css', $coverageDir . DIRECTORY_SEPARATOR . 'style.css');
|
||||
copy($template . 'Testify.js', $coverageDir . DIRECTORY_SEPARATOR . 'Testify.js');
|
||||
copy($template . 'testify.js', $coverageDir . DIRECTORY_SEPARATOR . 'testify.js');
|
||||
}
|
||||
|
||||
private static function writeHtmlFile($sourceFile, $baseDir, $coverageDir, array $classData, array $coverageData, $renderer) {
|
||||
|
@ -6,7 +6,7 @@
|
||||
<title>${title}</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
|
||||
<link rel="stylesheet" type="text/css" href="./style.css"/>
|
||||
<script type="text/javascript" src="./Testify.js"></script>
|
||||
<script type="text/javascript" src="./testify.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<title>${title}</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
|
||||
<link rel="stylesheet" type="text/css" href="./style.css"/>
|
||||
<script type="text/javascript" src="./Testify.js"></script>
|
||||
<script type="text/javascript" src="./testify.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -106,7 +106,7 @@
|
||||
|
||||
require_once $file;
|
||||
$ref = new ReflectionClass($className);
|
||||
if ($ref->isSubClassOf('TestCase')) {
|
||||
if ($ref->implementsInterface('Testable') && $ref->isInstantiable()) {
|
||||
$tests[] = $ref->newInstance($className);
|
||||
//add to filter
|
||||
CoverageFilter::addFile($file);
|
||||
|
@ -254,6 +254,9 @@
|
||||
}
|
||||
|
||||
public static function getClassNamesFromFile($file) {
|
||||
if (!is_file($file)) {
|
||||
return array();
|
||||
}
|
||||
$tokens = token_get_all(file_get_contents($file));
|
||||
$classes = array();
|
||||
for ($i = 0, $len = count($tokens); $i < $len; $i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user