ockcyp/covers-validator
Validate and normalize cover image uploads in Laravel: checks size, dimensions, aspect ratio, and file type; returns clear validation errors and helpers for cover/thumbnail rules. Easy drop-in rules for forms, APIs, and media pipelines.
PHPUnit @covers tags validator
PHPUnit fails to generate a coverage report when tests have invalid @covers tags.
This tool allows you to determine the tests that have invalid @covers tags without you needing to run the coverage.
Usually coverage reports are run less often than the tests as they take a long time to run. This tool validates your @covers tags quicker than you run your tests.
Trying to @cover or @use not existing class or interface "NonExistentClass".
Trying to @cover or @use not existing method "ExistingClass::nonExistantMethod".
See: phpunit/issues/1758 Also see: phpunit/issues/1791
Abandoned alternative: dunkelfrosch/phpcoverfish
Recommended way of installing covers-validator is via Composer.
composer require --dev ockcyp/covers-validator
Download the covers-validator.phar asset
from the latest release
or any other release from the releases.
Then run using the following:
php covers-validator.phar
[!NOTE] The usage documentation assumes you installed covers-validator using Composer, so please replace any reference to "vendor/bin/covers-validator" with "php covers-validator.phar".
[!NOTE] Only releases since v0.3.0 can be used as a phar.
Latest release of covers-validator supports PHP 7.1+ and PHPUnit 7+. Please use a previous release with older PHP and PHPUnit versions.
| PHPUnit version | Covers-validator release |
|---|---|
| < 6.0 | 0.5.x |
| 6.0 - 9.x | 1.5 |
| 7.0 - 9.x | 1.6 |
| 7.0 - 10.x | >= 1.7.0 |
Run the validator using the following:
vendor/bin/covers-validator
[!TIP] The command returns exit code 1 when any of the covers tags are invalid. Use this to fail your builds.
Give optional -c argument to load a particular PHPUnit configuration file:
vendor/bin/covers-validator -c tests/Fixtures/configuration.xml
Override the bootstrap value specified in PHPUnit configuration:
vendor/bin/covers-validator --bootstrap tests/bootstrap.php
Disable output by providing the -q argument
vendor/bin/covers-validator -q
Adjust the verbosity:
| Verbosity | Shows |
|---|---|
-v |
Valid tests |
-vv |
Loaded configuration file |
-vvv |
Test name before validation is done |
Invalid - OckCyp\CoversValidator\Tests\Fixtures\TwoTestCoveringNonExistentClassTest::testDummyTest
There were 1 test(s) with invalid @covers tags.
Configuration file loaded: /home/omer/Projects/Personal/covers-validator/tests/Fixtures/configuration-all.xml
Validating OckCyp\CoversValidator\Tests\Fixtures\TwoTestCoveringExistingClassTest::testDummyTest...
Valid - OckCyp\CoversValidator\Tests\Fixtures\TwoTestCoveringExistingClassTest::testDummyTest
Validating OckCyp\CoversValidator\Tests\Fixtures\TwoTestCoveringNonExistentClassTest::testDummyTest...
Invalid - OckCyp\CoversValidator\Tests\Fixtures\TwoTestCoveringNonExistentClassTest::testDummyTest
There were 1 test(s) with invalid @covers tags.
To run the tests, execute:
vendor/bin/phpunit
We use Semantic Versioning for versioning. For the versions available, see the releases or the CHANGELOG.md file.
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.txt file for details.
How can I help you explore Laravel packages today?