On this page
Class HtmlCoverageReport
Generates code coverage reports in HTML from data obtained from PHPUnit
- BaseCoverageReport
- HtmlCoverageReport 
Copyright: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
License: MIT License
Location: Cake/TestSuite/Coverage/HtmlCoverageReport.php
Properties summary
- 
    $_coveredprotectedHolds the total number of covered rows.integer
- 
    $_totalprotectedHolds the total number of processed rows.integer
Inherited Properties
Method Summary
- 
    _guessSubjectName() protectedGuess the class name the test was for based on the test case filename.
- 
    _paintLine() protectedRenders the HTML for a single line in the HTML diff.
- 
    coverageFooter() publicGenerate an HTML snippet for coverage footers
- 
    coverageHeader() publicGenerate an HTML snippet for coverage headers
- 
    coverageScript() publicgenerate some javascript for the coverage report.
- 
    generateDiff() publicGenerates an HTML diff for $file based on $coverageData.
- 
    report() publicGenerates report HTML to display.
Method Detail
_guessSubjectName()source protected
_guessSubjectName( ReflectionClass $testReflection )Guess the class name the test was for based on the test case filename.
Parameters
- 
     ReflectionClass $testReflection
- The class to reflect
Returns
stringPossible test subject name.
_paintLine()source protected
_paintLine( string $line , integer $linenumber , string $class , array $coveringTests )Renders the HTML for a single line in the HTML diff.
Parameters
- 
     string $line
- The line content.
- 
     integer $linenumber
- The line number
- 
     string $class
- The classname to use.
- 
     array $coveringTests
- The tests covering the line.
Returns
stringcoverageHeader()source public
coverageHeader( string $filename , string $percent )Generate an HTML snippet for coverage headers
Parameters
- 
     string $filename
- The file name being covered
- 
     string $percent
- The percentage covered
Returns
stringcoverageScript()source public
coverageScript( )generate some javascript for the coverage report.
Returns
stringgenerateDiff()source public
generateDiff( string $filename , array $fileLines , array $coverageData )Generates an HTML diff for $file based on $coverageData.
Handles both PHPUnit3.5 and 3.6 formats.
3.5 uses -1 for uncovered, and -2 for dead. 3.6 uses array() for uncovered and null for dead.
Parameters
- 
     string $filename
- Name of the file having coverage generated
- 
     array $fileLines
- File data as an array. See file() for how to get one of these.
- 
     array $coverageData
- Array of coverage data to use to generate HTML diffs with
Returns
stringHTML diff.
report()source public
report( )Generates report HTML to display.
Returns
stringCompiled HTML report.
Methods inherited from BaseCoverageReport
__construct()source public
__construct( array $coverage , CakeBaseReporter $reporter )Constructor
Parameters
- 
     array $coverage
- Array of coverage data from PHPUnit_Test_Result
- CakeBaseReporter- $reporter
- A reporter to use for the coverage report.
_calculateCoveredLines()source protected
_calculateCoveredLines( array $fileLines , array $coverageData )Calculates how many lines are covered and what the total number of executable lines is.
Handles both PHPUnit3.5 and 3.6 formats.
3.5 uses -1 for uncovered, and -2 for dead. 3.6 uses array() for uncovered and null for dead.
Parameters
- 
     array $fileLines
- The lines in the file.
- 
     array $coverageData
- The raw coverage data.
Returns
arrayArray of covered, total lines.
_setParams()source protected
_setParams( CakeBaseReporter $reporter )Pulls params out of the reporter.
Parameters
- CakeBaseReporter- $reporter
- Reporter to suck params out of.
filterCoverageDataByPath()source public
filterCoverageDataByPath( string $path )Filters the coverage data by path. Files not in the provided path will be removed.
Parameters
- 
     string $path
- Path to filter files by.
Returns
arrayArray of coverage data for files that match the given path.
getPathFilter()source public
getPathFilter( )Gets the base path that the files we are interested in live in.
Returns
stringPath
setCoverage()source public
setCoverage( array $coverage )Set the coverage data array
Parameters
- 
     array $coverage
- Coverage data to use.
Properties detail
© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
 https://api.cakephp.org/2.10/class-HtmlCoverageReport.html