### Install phpunit/php-code-coverage Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/README.md Instructions for installing the phpunit/php-code-coverage library using Composer. It can be added as a project dependency or a development-time dependency. ```bash composer require phpunit/php-code-coverage ``` ```bash composer require --dev phpunit/php-code-coverage ``` -------------------------------- ### PHP Code Coverage Usage Example Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/README.md A PHP code snippet demonstrating how to use the phpunit/php-code-coverage library to collect and process code coverage data. It includes setting up a filter, starting and stopping coverage collection, and generating an HTML report. ```php includeFiles( [ '/path/to/file.php', '/path/to/another_file.php', ] ); $coverage = new CodeCoverage( (new Selector)->forLineCoverage($filter), $filter ); $coverage->start(''); // ... $coverage->stop(); (new HtmlReport)->process($coverage, '/tmp/code-coverage-report'); ``` -------------------------------- ### BankAccount Class Code Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/CoverageForBankAccount/BankAccount.php.html The PHP code for the BankAccount class, including methods for getting the balance, depositing money, and withdrawing money. It also includes a protected method for setting the balance with validation. ```php balance; } protected function setBalance($balance) { if ($balance >= 0) { $this->balance = $balance; } else { throw new RuntimeException; } } public function depositMoney($balance) { $this->setBalance($this->getBalance() + $balance); return $this->getBalance(); } public function withdrawMoney($balance) { $this->setBalance($this->getBalance() - $balance); return $this->getBalance(); } } ``` -------------------------------- ### Code Coverage Paths Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_path.html This section outlines the execution paths within the BankAccount class and their respective coverage status. It details the flow of execution for each method, indicating which parts of the paths are covered. ```php Paths ##### BankAccount->depositMoney [20](#20) %s [21](#21) %s [22](#22) %s [23](#23) [24](#24) %s [25](#25) %s ##### BankAccount->getBalance [6](#6) %s [7](#7) %s [8](#8) %s [9](#9) %s ##### BankAccount->setBalance [11](#11) %s [12](#12) %s [13](#13) %s [14](#14) %s [18](#18) %s [11](#11) %s [12](#12) %s [13](#13) %s [16](#16) %s ##### BankAccount->withdrawMoney [27](#27) %s [28](#28) %s [29](#29) %s [30](#30) [31](#31) %s [32](#32) %s ``` -------------------------------- ### PHP_CodeCoverage 1.2.7 Fixes Source: https://github.com/sebastianbergmann/php-code-coverage/wiki/ChangeLog-for-PHP_CodeCoverage-1.2 Includes bundled `html5shiv.js` and fixes an issue related to the `@coversNothing` annotation not working as documented (sebastianbergmann/phpunit#702) in version 1.2.7. ```php * The `html5shiv.js` is now bundled * Fixed sebastianbergmann/phpunit#702: `@coversNothing` didn't work as documented ``` -------------------------------- ### File Coverage Details Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/CoverageForFileWithIgnoredLines/index.html Provides code coverage details for individual files, including line, function, and class coverage percentages. It links to the source file and shows coverage status. ```php ![](_icons/file-code.svg)[source_with_ignore.php](source_with_ignore.php.html) 100.00% covered (success) 100.00% 1 / 1 100.00% covered (success) 100.00% 1 / 1 n/a 0 / 0 ``` -------------------------------- ### Generation Information Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/PathCoverageForSourceWithoutNamespace/index.html Details about the generation of the code coverage report, including the version of php-code-coverage used and the tool it was generated with. ```text Generated by php-code-coverage [version] using [tool] ([link]) at [timestamp]. ``` -------------------------------- ### PHP Code Coverage Summary Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/Text/BankAccountWithUncovered-line.txt Provides a summary of code coverage metrics including percentages for classes, methods, and lines across the project. It also details coverage for individual classes like 'BankAccount'. ```php Code Coverage Report: %s Summary: Classes: 0.00% (0/2) Methods: 37.50% (3/8) Lines: 31.25% (5/16) BankAccount Methods: 75.00% ( 3/ 4) Lines: 62.50% ( 5/ 8) ``` -------------------------------- ### Complexity Metrics in Reports Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/ChangeLog-12.3.md Adds coverage and complexity columns to class and method complexity tables, and includes CRAP (Change Risk Anti-Pattern) in graph tooltips for enhanced analysis. ```php Add coverage and complexity columns to class and method complexity tables Add CRAP to graph tooltip ``` -------------------------------- ### Generation Information Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/CoverageForBankAccount/index.html Information about the tool used to generate the code coverage report, including the version and source repository. ```php Generated by [php-code-coverage %s](https://github.com/sebastianbergmann/php-code-coverage) using [%s](%s) at %s. ``` -------------------------------- ### PHP Code Coverage Report Structure Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/PathCoverageForSourceWithoutNamespace/source_without_namespace.php.html This snippet represents the overall structure and summary of a PHP code coverage report. It outlines the key metrics like lines, branches, paths, functions, and classes coverage, along with their respective percentages and counts. ```php ({ axis: { x: { type: "category", categories: barLabels, }, y: { label: { text: `#${name}`, position: 'outer-top', }, }, }, bindto: `#${name}CoverageDistribution`, data: { columns: [ [fullName].concat(values), ], colors: { [fullName]: "rgba(69, 114, 167, 0.75)", }, type: "bar", }, bar: { width: { ratio: 0.9, }, }, grid: { focus: { show: false, }, x: { show: true, }, y: { show: true, }, }, legend: { show: false, }, tooltip: { contents: function (data) { return `
Coverage ${barLabels[data[0].x]}
${data[0].value} ${name}
`; }, grouped: false, }, }); bb.generate( barConfig('classes', "Class Coverage", [0,0,0,0,0,0,0,0,0,0,0,2]) ); bb.generate( barConfig('methods', "Method Coverage", [0,0,0,0,0,0,0,0,0,0,0,2]) ); const scatterConfig = (name, complexityData) => ({ axis: { x: { label: { text: 'Code Coverage (in percent)', position: 'outer-right', }, tick: { values: [0, 20, 40, 60, 80, 100], }, }, y: { label: { text: 'Cyclomatic Complexity', position: 'outer-top', }, min: 0, padding: { bottom: 0, top: 5, }, }, }, bindto: `#${name}Complexity`, data: { columns: [ ["complexity_x"].concat(complexityData.map(d => d[0])), ["complexity"].concat(complexityData.map(d => d[1])), ], onclick: function(data, element) { window.location = complexityData[data.index][2]; }, type: "scatter", xs: { "complexity": "complexity_x", }, }, grid: { focus: { show: true, y: true, }, x: { show: true, }, y: { show: true, }, }, legend: { show: false, }, tooltip: { contents: function (data) { const coverage = Math.round(data[0].x); const complexity = data[0].value; const targetName = complexityData[data[0].index][3]; const crap = complexityData[data[0].index][4]; return `
${targetName}
Coverage${coverage}%
Complexity${complexity}
Crap${crap}
`; }, grouped: false, }, }); const classComplexityData = JSON.parse(document.getElementById('complexity_class').textContent); bb.generate( scatterConfig("class", classComplexityData) ); const methodComplexityData = JSON.parse(document.getElementById('complexity_method').textContent); bb.generate( scatterConfig("method", methodComplexityData), ); ``` -------------------------------- ### PHP Code Coverage Report Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_path.html This snippet represents the overall code coverage summary for a PHP file. It displays the percentage of covered lines, branches, paths, functions, and classes, along with counts of executed vs. total elements. It also includes CRAP scores and details for specific functions and classes. ```php ``` -------------------------------- ### File Coverage Details Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/CoverageForBankAccount/index.html Details the code coverage for a specific file, including lines, functions, and classes covered, along with their respective coverage percentages and status. ```php ![](_icons/file-code.svg)[BankAccount.php](BankAccount.php.html) 62.50% covered (warning) 62.50% 5 / 8 75.00% covered (warning) 75.00% 3 / 4 0.00% covered (danger) 0.00% 0 / 1 ``` -------------------------------- ### PHP Code Coverage Metrics Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/PathCoverageForSourceWithoutNamespace/index.html Displays the code coverage statistics for lines, branches, paths, functions, and methods. The current coverage is 0.00% across all categories. ```php ``` -------------------------------- ### BankAccount Method Coverage Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_path.html This section details the code coverage for each method within the BankAccount class. It shows the percentage of lines, branches, paths, and functions covered for each method, along with the number of covered elements out of the total. ```php BankAccount 62.50% covered (warning) 62.50% 5 / 8 42.86% covered (danger) 42.86% 3 / 7 60.00% covered (warning) 60.00% 3 / 5 75.00% covered (warning) 75.00% 3 / 4 6.60 0.00% covered (danger) 0.00% 0 / 1 getBalance 100.00% covered (success) 100.00% 1 / 1 100.00% covered (success) 100.00% 1 / 1 100.00% covered (success) 100.00% 1 / 1 100.00% covered (success) 100.00% 1 / 1 1 setBalance 0.00% covered (danger) 0.00% 0 / 3 0.00% covered (danger) 0.00% 0 / 4 0.00% covered (danger) 0.00% 0 / 2 0.00% covered (danger) 0.00% 0 / 1 6 depositMoney 100.00% covered (success) 100.00% 2 / 2 100.00% covered (success) 100.00% 1 / 1 100.00% covered (success) 100.00% 1 / 1 100.00% covered (success) 100.00% 1 / 1 1 withdrawMoney 100.00% covered (success) 100.00% 2 / 2 100.00% covered (success) 100.00% 1 / 1 100.00% covered (success) 100.00% 1 / 1 100.00% covered (success) 100.00% 1 / 1 1 ``` -------------------------------- ### PHP Code Coverage Summary Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/Text/NamespacedBankAccount.txt Provides a summary of code coverage metrics including classes, methods, and lines. It indicates the percentage of executable code that was tested. ```php Code Coverage Report: %s Summary: Classes: 0.00% (0/1) Methods: 75.00% (3/4) Lines: 62.50% (5/8) SomeNamespace\BankAccount Methods: ( 0/ 0) Lines: ( 0/ 0) SomeNamespace\BankAccountTrait Methods: 75.00% ( 3/ 4) Lines: 62.50% ( 5/ 8) ``` -------------------------------- ### Complexity Scatter Plot Configuration Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/PathCoverageForSourceWithoutNamespace/dashboard.html Configures and generates scatter plots to visualize the relationship between code coverage and cyclomatic complexity for classes and methods. Clicking on a data point navigates to the corresponding source file. ```javascript const scatterConfig = (name, complexityData) => ({ axis: { x: { label: { text: 'Code Coverage (in percent)', position: 'outer-right', }, tick: { values: [0, 20, 40, 60, 80, 100], }, }, y: { label: { text: 'Cyclomatic Complexity', position: 'outer-top', }, min: 0, padding: { bottom: 0, top: 5, }, }, }, bindto: `#${name}Complexity`, data: { columns: [ ["complexity_x"].concat(complexityData.map(d => d[0])), ["complexity"].concat(complexityData.map(d => d[1])), ], onclick: function(data, element) { window.location = complexityData[data.index][2]; }, type: "scatter", xs: { "complexity": "complexity_x", }, }, grid: { focus: { show: true, y: true, }, x: { show: true, }, y: { show: true, }, }, legend: { show: false, }, tooltip: { contents: function (data) { const coverage = Math.round(data[0].x); const complexity = data[0].value; const targetName = complexityData[data[0].index][3]; return `
${targetName}
Coverage${coverage}%
Complexity${complexity}
`; }, grouped: false, }, }); const classComplexityData = JSON.parse(document.getElementById('complexity_class').textContent); bb.generate( scatterConfig("class", classComplexityData) ); const methodComplexityData = JSON.parse(document.getElementById('complexity_method').textContent); bb.generate( scatterConfig("method", methodComplexityData), ); ``` -------------------------------- ### Code Path Analysis for foo function Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_path.html This section details the code paths identified by Xdebug for the 'foo' function. It lists the source code lines that constitute each path, highlighting potential complexities and execution flows within the function. ```php function &foo($bar) { $baz = function () {}; $a = true ? true : false; $a = true ? true : false; $a = true ? true : false; $b = "{$a}"; $c = "${b}"; } ``` -------------------------------- ### BankAccount Class Coverage Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_branch.html Provides a summary of code coverage for the BankAccount class and its methods. It includes percentages for lines, branches, paths, functions, and classes, along with CRAP scores. ```php BankAccount 62.50% covered (warning) 62.50% 5 / 8 42.86% covered (danger) 42.86% 3 / 7 60.00% covered (warning) 60.00% 3 / 5 75.00% covered (warning) 75.00% 3 / 4 6.60 0.00% covered (danger) 0.00% 0 / 1 ``` -------------------------------- ### depositMoney Method Coverage Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php.html This snippet presents the code coverage for the depositMoney method. It indicates that this method is fully covered by tests, including its calls to other methods. ```php public function depositMoney($balance)     {         $this->setBalance($this->getBalance() + $balance);         return $this->getBalance();     } ``` -------------------------------- ### PHP_CodeCoverage 1.2.3 Fixes and Features Source: https://github.com/sebastianbergmann/php-code-coverage/wiki/ChangeLog-for-PHP_CodeCoverage-1.2 Introduces several changes in version 1.2.3, including not relying on the autoloader class map for blacklisting, support for parentheses in `@covers` annotations, changes to how whitelisted but uncovered files are handled, and fixes for non-English locales, percentage display, and one-line `@covers` annotations. ```php * Implemented #116: Do not rely on autoloader class map to populate blacklist * Added support for parentheses after method names in the `@covers` annotation * When `addUncoveredFilesFromWhitelist=FALSE` is set then files that are whitelisted but not covered by a single test are now excluded from the code coverage * Fixed #81: Non-english locales broke the coverage bars in the HTML report * Fixed #118: Percentage for tested classes and traits displayed incorrectly * Fixed #121: One line `@covers` annotations did not work ``` -------------------------------- ### JavaScript Charting for Complexity and Risk Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/CoverageForBankAccount/dashboard.html Generates scatter plots to visualize the relationship between code coverage and cyclomatic complexity for classes and methods. It includes tooltips displaying coverage, complexity, and CRAP scores, with click functionality to navigate to the source. ```javascript const scatterConfig = (name, complexityData) => ({ axis: { x: { label: { text: 'Code Coverage (in percent)', position: 'outer-right', }, tick: { values: [0, 20, 40, 60, 80, 100], }, }, y: { label: { text: 'Cyclomatic Complexity', position: 'outer-top', }, min: 0, padding: { bottom: 0, top: 5, }, }, }, bindto: `#${name}Complexity`, data: { columns: [ ["complexity_x"].concat(complexityData.map(d => d[0])), ["complexity"].concat(complexityData.map(d => d[1])), ], onclick: function(data, element) { window.location = complexityData[data.index][2]; }, type: "scatter", xs: { "complexity": "complexity_x", }, }, grid: { focus: { show: true, y: true, }, x: { show: true, }, y: { show: true, }, }, legend: { show: false, }, tooltip: { contents: function (data) { const coverage = Math.round(data[0].x); const complexity = data[0].value; const targetName = complexityData[data[0].index][3]; const crap = complexityData[data[0].index][4]; return `
${targetName}
Coverage${coverage}%
Complexity${complexity}
Crap${crap}
`; }, grouped: false, }, }); const classComplexityData = JSON.parse(document.getElementById('complexity_class').textContent); bb.generate( scatterConfig("class", classComplexityData) ); const methodComplexityData = JSON.parse(document.getElementById('complexity_method').textContent); bb.generate( scatterConfig("method", methodComplexityData), ); ``` -------------------------------- ### Code Coverage Summary Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/Text/ignored-lines.txt Provides a summary of code coverage metrics, including the percentage of lines, methods, and classes covered by tests. This specific report indicates full line coverage but no class or method coverage. ```text Code Coverage Report: %s Summary: Classes: (0/0) Methods: (0/0) Lines: 100.00% (1/1) ``` -------------------------------- ### PHP Code Coverage Ignore Annotations Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/CoverageForFileWithIgnoredLines/source_with_ignore.php.html Demonstrates the use of @codeCoverageIgnore and @codeCoverageIgnoreStart/@codeCoverageIgnoreEnd annotations in PHP to exclude specific lines, methods, or blocks from code coverage analysis. ```php = 0) {             $this->balance = $balance;         } else {             throw new RuntimeException;         }     } ``` -------------------------------- ### JavaScript for Coverage Distribution Charts Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/PathCoverageForBankAccount/dashboard.html Generates bar charts for class and method coverage distribution using the C3.js library. It configures chart axes, data, colors, and tooltips to visualize coverage percentages. ```javascript const barLabels = [ '0%', '0-10%', '10-20%', '20-30%', '30-40%', '40-50%', '50-60%', '60-70%', '70-80%', '80-90%', '90-100%', '100%' ]; const barConfig = (name, fullName, values) => ({ axis: { x: { type: "category", categories: barLabels, }, y: { label: { text: `#${name}`, position: 'outer-top', }, }, }, bindto: `#${name}CoverageDistribution`, data: { columns: [ [fullName].concat(values), ], colors: { [fullName]: "rgba(69, 114, 167, 0.75)", }, type: "bar", }, bar: { width: { ratio: 0.9, }, }, grid: { focus: { show: false, }, x: { show: true, }, y: { show: true, }, }, legend: { show: false, }, tooltip: { contents: function (data) { return `
Coverage ${barLabels[data[0].x]}
${data[0].value} ${name}
`; }, grouped: false, }, }); bb.generate( barConfig('classes', "Class Coverage", [0,0,0,0,0,0,0,0,0,0,0,1]) ); bb.generate( barConfig('methods', "Method Coverage", [0,0,0,0,0,0,0,0,0,0,0,0]) ); ``` -------------------------------- ### PHP Code Coverage Report Structure Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/PathCoverageForSourceWithoutNamespace/source_without_namespace.php_branch.html This snippet represents the overall structure and summary statistics of a PHP code coverage report. It includes total coverage percentages for lines, branches, paths, functions, and classes, along with counts of covered vs. total elements. ```php balance;     }     protected function setBalance($balance)     {         if ($balance >= 0) {             $this->balance = $balance;         } else {             throw new RuntimeException;         }     }     public function depositMoney($balance)     {         $this->setBalance($this->getBalance() + $balance);         return $this->getBalance();     }     public function withdrawMoney($balance)     {         $this->setBalance($this->getBalance() - $balance);         return $this->getBalance();     } } ``` -------------------------------- ### Code Coverage Summary Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/CoverageForFileWithIgnoredLines/index.html Displays the overall code coverage statistics, including percentages for lines, functions, and classes. It also indicates the number of elements covered versus the total number. ```php Total 100.00% covered (success) 100.00% 1 / 1 100.00% covered (success) 100.00% 1 / 1 n/a 0 / 0 ``` -------------------------------- ### PHP Code Coverage Metrics Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/CoverageForClassWithAnonymousFunction/index.html Displays the code coverage statistics for lines, functions, and classes. It shows the percentage of covered code and the number of covered items out of the total. ```php Code Coverage for %s 1. %s 2. ([Dashboard](dashboard.html)) **Code Coverage** **Lines** **Functions and Methods** **Classes and Traits** Total 100.00% covered (success) 100.00% 8 / 8 100.00% covered (success) 100.00% 1 / 1 100.00% covered (success) 100.00% 1 / 1 ![](_icons/file-code.svg)[source_with_class_and_anonymous_function.php](source_with_class_and_anonymous_function.php.html) 100.00% covered (success) 100.00% 8 / 8 100.00% covered (success) 100.00% 1 / 1 100.00% covered (success) 100.00% 1 / 1 * * * #### Legend **Low**: 0% to 50% **Medium**: 50% to 90% **High**: 90% to 100% Generated by [php-code-coverage %s](https://github.com/sebastianbergmann/php-code-coverage) using [%s](%s) at %s. ``` -------------------------------- ### Fix for Class Complexity Scatter Chart Tooltips Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/ChangeLog-12.3.md Addresses an issue where class complexity scatter chart tooltips were showing incorrect class information, as reported in issue #1081. ```php #1081: Class complexity scatter chart tooltips show incorrect class ``` -------------------------------- ### Report Generation Information Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/CoverageForFileWithIgnoredLines/index.html Indicates the tool used to generate the report, including the version of php-code-coverage and the driver/library used, along with the generation timestamp. ```php Generated by [php-code-coverage %s](https://github.com/sebastianbergmann/php-code-coverage) using [%s](%s) at %s. ``` -------------------------------- ### PHP_CodeCoverage 2.0.8 Improvements and Fixes Source: https://github.com/sebastianbergmann/php-code-coverage/wiki/ChangeLog-for-PHP_CodeCoverage-2.0 Details changes in version 2.0.8, including modifications to dashboard sections for methods to display only the method name and fixes for issues with `vfs://` and `xdebug://` files, as well as line ignoring on HHVM. ```php * The "Insufficient Coverage" and "Project Risks" dashboard sections for methods only list the method name (instead of "ClassName::methodName") now. This solves an issue with long class and method names. * Fixed an issue related to `vfs://` and `xdebug://` files * Fixed an issue with processing lines that should be ignored on HHVM ``` -------------------------------- ### getBalance Method Coverage Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php.html This snippet shows the code coverage for the getBalance method within the BankAccount class. It indicates that this method is fully covered by tests. ```php public function getBalance()     {         return $this->balance;     } ``` -------------------------------- ### JavaScript Charting for Coverage Distribution Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/HTML/CoverageForBankAccount/dashboard.html Generates bar charts to visualize code coverage distribution for classes and methods. It uses the 'bb' charting library and custom configurations for data display and tooltips. ```javascript const barLabels = [ '0%', '0-10%', '10-20%', '20-30%', '30-40%', '40-50%', '50-60%', '60-70%', '70-80%', '80-90%', '90-100%', '100%' ]; const barConfig = (name, fullName, values) => ({ axis: { x: { type: "category", categories: barLabels, }, y: { label: { text: `#${name}`, position: 'outer-top', }, }, }, bindto: `#${name}CoverageDistribution`, data: { columns: [ [fullName].concat(values), ], colors: { [fullName]: "rgba(69, 114, 167, 0.75)", }, type: "bar", }, bar: { width: { ratio: 0.9, }, }, grid: { focus: { show: false, }, x: { show: true, }, y: { show: true, }, }, legend: { show: false, }, tooltip: { contents: function (data) { return `
Coverage ${barLabels[data[0].x]}
${data[0].value} ${name}
`; }, grouped: false, }, }); bb.generate( barConfig('classes', "Class Coverage", [0,0,0,0,0,0,0,1,0,0,0,0]) ); bb.generate( barConfig('methods', "Method Coverage", [1,0,0,0,0,0,0,0,0,0,0,3]) ); ``` -------------------------------- ### OpenClover XML Format Support Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/ChangeLog-12.3.md Introduces experimental support for reporting code coverage in OpenClover XML format. The generated XML validates against the OpenClover XML schema definition, with the exception of the `` element. This feature may undergo changes in future releases to improve schema compliance. ```php Support for reporting code coverage information in OpenClover XML format; unlike the existing Clover XML reporter, which remains unchanged, the XML documents generated by this new reporter validate against the OpenClover project's XML schema definition, with one exception: we do not generate the `` element. This feature is experimental and the generated XML might change in order to improve compliance with the OpenClover project's XML schema definition further. Such changes will be made in bugfix and/or minor releases even if they break backward compatibility. ``` -------------------------------- ### PHP Code Coverage Summary Source: https://github.com/sebastianbergmann/php-code-coverage/blob/main/tests/_files/Report/Text/BankAccountWithoutUncovered-line.txt Provides a summary of code coverage across classes, methods, and lines for a PHP project. It indicates the percentage of executable code that is covered by automated tests. ```php Code Coverage Report: %s Summary: Classes: 0.00% (0/1) Methods: 75.00% (3/4) Lines: 62.50% (5/8) ```