ancarda / high-test-coverage
Classes and Interfaces to help you get higher test coverage
1.1.3
2022-02-26 11:30 UTC
Requires
- php: ^7.3|^8.0
Requires (Dev)
- ancarda/coverage-enforcer: ^1.0
- composer/package-versions-deprecated: 1.11.99.1
- infection/infection: ^0.18.2
- phpstan/phpstan: ^0.12.82
- phpstan/phpstan-phpunit: ^0.12.18
- phpstan/phpstan-strict-rules: ^0.12.9
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2024-11-26 18:28:56 UTC
README
Classes and Interfaces to help you get higher test coverage
High Test Coverage is a collection of classes and interfaces designed to help
you get higher test coverage when using impure parts of the PHP Standard
Library. It provides a RandomInt
interface which you can use in place of the
random_int
function, like so:
Pull down with composer:
composer require --dev ancarda/high-test-coverage
Example Usage
<?php use Ancarda\HighTestCoverage\RandomInt\RandomInt; final class Genie { public function __construct(private RandomInt $randomInt) {} public function fortune(): string { return 'Your lucky number is ' . $this->randomInt(1, 10); } }
In production, this class would be given an instance of RandomInt\Real
,
likely via your Dependency Injection container. Under test, you would use one
of the many built-in classes, such as Fixed
or OneShot
, like so:
<?php use Ancarda\HighTestCoverage\RandomInt\Fixed; final class GenieTest extends TestCase { public function testFortune(): void { $genie = new Genie(new Fixed(42)); self::assertSame('Your lucky number is 42', $genie->fortune()); } }
Useful Links
- Source Code: https://git.sr.ht/~ancarda/high-test-coverage
- Issue Tracker: https://todo.sr.ht/~ancarda/high-test-coverage
- Mailing List: https://lists.sr.ht/~ancarda/high-test-coverage