PEAR2_Pyrus_DeveloperPEAR2_Pyrus_Developer-0.4.0/www/pear2.php.net/PEAR2_Pyrus_Developer/CoverageAnalyzer/templates/Summary.tpl.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
$coverage = $context->retrieveProjectCoverage();
list($covered, $total, $dead) = $coverage;
?>
  <h2>Code Coverage Files</h2>
  <h3>Total lines: <?php echo $total; ?>, covered lines: <?php echo $covered; ?>, dead lines: <?php echo $dead; ?></h3>

    <?php
    $percent = 0;
    if ($total > 0) {
        $percent = round(($covered / $total) * 100, 1);
    }

    function getClass($percent)
    {
        if ($percent < 50) {
            return 'bad';
        } elseif ($percent < 75) {
            return 'ok';
        } else {
            return 'good';
        }
    }
    
    ?>
    <p class="<?php echo getClass($percent); ?>"><?php echo $percent; ?>% code coverage</p>
    <p>
    <a href="<?php echo $parent->context->getRootLink(); ?>?test=TOC">Code Coverage per PHPT test</a>
    </p>

  <table>
   <thead>
    <tr>
        <th>Coverage %</th>
        <th>Source File</th>
        <th>Uncovered % of total uncovered</th>
    </tr>
   </thead>
   <tbody>
   <?php foreach ($context as $sourceFile):
   list($sourceCovered, $sourceTotal, $sourceDead) = $sourceFile->coverageInfo();
   ?>
   <tr>
    <td class="<?php echo getClass($sourceFile->coveragePercentage()); ?>"><?php echo $sourceFile->coveragePercentage() . '%'; ?></td>
    <td><a href="<?php echo $parent->context->getFileLink($sourceFile->name()); ?>"><?php echo $sourceFile->shortName(); ?></a></td>
    <td><?php echo round(($sourceTotal - $sourceCovered)/($total - $covered)*100, 2); ?>%</td>
   </tr>
   <?php endforeach; ?>
   </tbody>
  </table>
EOF