Download the PHP package esi/phpunit-coverage-check without Composer
On this page you can find all versions of the php package esi/phpunit-coverage-check. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download esi/phpunit-coverage-check
More information about esi/phpunit-coverage-check
Files in esi/phpunit-coverage-check
Package phpunit-coverage-check
Short Description Check the code coverage using the clover report of PHPUnit.
License MIT
Homepage https://github.com/ericsizemore/phpunit-coverage-check
Informations about the package phpunit-coverage-check
PHPUnit Coverage Check
PHPUnit Coverage Check - Check the code coverage using the clover report of PHPUnit.
This library will read the clover (or openclover in PHPUnit 12.2+) XML report from PHPUnit and calculate the coverage score. Based on the given threshold, the application will exit OK if the coverage is higher than the threshold or exit with code 1 if the coverage is lower than the threshold.
This library can be used in multiple ways:
- In your continuous deployment environment
- By adding it to a pre-commit hook
- Requiring it as a dev dependency in your
composer.jsonand running it with a composer script.
See Usage for more information.
[!IMPORTANT] This project is not in any way an official
PHPUnitproject. Meaning it is not associated with, or endorsed by, thePHPUnitproject or its authorSebastian Bergmann.
GitHub Action
A GitHub action is available and can be found in the PHPUnit Coverage Check Action repository, or on the GitHub Marketplace.
Installation
Composer
PHPUnit Coverage Check can be installed using Composer. Add this repository as a dev-dependency to the composer.json file.
To use PHPUnit Coverage Check on an older version of PHP:
-
PHP 8.1, use version 1.0.0 (and check 1.x's readme as usage is slightly different):
- PHP 8.2, use version 2.0.0 (and check 2.x's readme)
Phar
Download the phpunit-coverage-check.phar from an available release. It is recommended to check the signature when downloading the Phar from a GitHub Release (with phpunit-coverage-check.phar.asc).
The Phar files of PHPUnit Coverage Check are signed with a public key associated to [email protected]..
The key(s) associated with this E-Mail address can be queried at keys.openpgp.org.
Install with Phive
You can also install the PHPUnit Coverage Check Phar with Phive.
If not already using Phive, you can read more about it here, also Phive installation and usage.
Usage
There are two parameters that must be passed to return the code coverage.
- The location of the clover XML file that PHPUnit has generated.
- The coverage threshold that is acceptable or 'passing.' Min = 1, Max = 100.
Generate the clover.xml file by using PHPUnit:
Prior to PHPUnit 12.2 (or if you prefer the old clover format of PHPUnit)
You can also add the coverage report generation to your PHPUnit configuration file (phpunit.xml.dist for example). You would need to add the following lines inside the <coverage> tag:
PHPUnit 12.2 and later, for OpenClover
For the experimental OpenClover report in PHPUnit 12.2+
- For more information, see the PHPUnit Documentation.
- Information about the configuration file and commandline options.
- Also see the release notes for PHPUnit 12.2.0.
If installed with Composer
You can use the Api directly if you wish. The Esi\CoverageCheck\CoverageCheck::nonConsoleCall() method will process and return the data, like how the console application displays it.
An example usage:
If using the Phar
With --only-percentage (or -O) enabled, the CLI command will only return the resulting coverage percentage.
--show-files
With --show-files (or -F), --only-percentage will be ignored. This option parses the clover file for coverage information for each file in the project/package, determine coverage, and display the information in a table.
For example:
Passing coverage example output
Mixed pass/fail coverage example output
--table-width
The --table-width (or -W) option will only have an affect if used with the --show-files option. The only requirement for this particular option is that you must pass an integer
value. For example:
About
Requirements
- PHPUnit Coverage Check works with PHP 8.3.0 or above.
- For PHP 8.2 please use v2.0.x of PHPUnit Coverage Check.
- For PHP 8.1 please use v1.0.x of PHPUnit Coverage Check.
Credits
This library is a fork of/based upon rregeer/phpunit-coverage-check by Richard Regeer.
Most of this library has been rewritten from the ground up, to replace and improve the majority of the original library. The overall idea, and key pieces of the calculation, are thanks to the original library. Many thanks and much appreciation to Richard Regeer for his wonderful work.
- Author: Eric Sizemore
- Thanks to Richard Regeer for the original
phpunit-coverage-checklibrary this library is forked from. - Thanks to SensioLabs Security Checker for inspiration in creating my implementation of the
coverage:checkcommand. - Thanks to Box for their wonderful project that makes Phar generation a breeze.
- Thanks to all Contributors.
Contributing
See CONTRIBUTING.
Bugs and feature requests are tracked on GitHub.
Contributor Covenant Code of Conduct
See CODE_OF_CONDUCT.md
Backward Compatibility Promise
See backward-compatibility.md for more information on Backwards Compatibility.
Changelog
See the CHANGELOG for more information on what has changed recently.
License
See the LICENSE for more information on the license that applies to this project.
Security
See SECURITY for more information on the security disclosure process.
All versions of phpunit-coverage-check with dependencies
ext-libxml Version *
ext-simplexml Version *
symfony/console Version ~7.3.10


