mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
feat: move Coverage out of external plugin
This commit is contained in:
@ -17,6 +17,12 @@
|
||||
✓ it gets executed before each test
|
||||
✓ it gets executed before each test once again
|
||||
|
||||
PASS Tests\Features\Coverage
|
||||
✓ it has plugin
|
||||
✓ it adds coverage if --coverage exist
|
||||
✓ it adds coverage if --min exist
|
||||
✓ it generates coverage based on file input
|
||||
|
||||
PASS Tests\Features\Datasets
|
||||
✓ it throws exception if dataset does not exist
|
||||
✓ it throws exception if dataset already exist
|
||||
@ -276,5 +282,5 @@
|
||||
✓ it is a test
|
||||
✓ it uses correct parent class
|
||||
|
||||
Tests: 4 incompleted, 7 skipped, 168 passed
|
||||
Tests: 4 incompleted, 7 skipped, 172 passed
|
||||
|
||||
58
tests/Features/Coverage.php
Normal file
58
tests/Features/Coverage.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
use Pest\Plugins\Coverage as CoveragePlugin;
|
||||
use Pest\Support\Coverage;
|
||||
use Pest\TestSuite;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
|
||||
it('has plugin')->assertTrue(class_exists(CoveragePlugin::class));
|
||||
|
||||
it('adds coverage if --coverage exist', function () {
|
||||
$plugin = new CoveragePlugin(new ConsoleOutput());
|
||||
$testSuite = TestSuite::getInstance();
|
||||
|
||||
expect($plugin->coverage)->toBeFalse();
|
||||
$arguments = $plugin->handleArguments([]);
|
||||
expect($arguments)->toEqual([]);
|
||||
expect($plugin->coverage)->toBeFalse();
|
||||
|
||||
$arguments = $plugin->handleArguments(['--coverage']);
|
||||
expect($arguments)->toEqual(['--coverage-php', Coverage::getPath()]);
|
||||
expect($plugin->coverage)->toBeTrue();
|
||||
});
|
||||
|
||||
it('adds coverage if --min exist', function () {
|
||||
$plugin = new CoveragePlugin(new ConsoleOutput());
|
||||
expect($plugin->coverageMin)->toEqual(0.0);
|
||||
|
||||
expect($plugin->coverage)->toBeFalse();
|
||||
$plugin->handleArguments([]);
|
||||
expect($plugin->coverageMin)->toEqual(0.0);
|
||||
|
||||
$plugin->handleArguments(['--min=2']);
|
||||
expect($plugin->coverageMin)->toEqual(2.0);
|
||||
|
||||
$plugin->handleArguments(['--min=2.4']);
|
||||
expect($plugin->coverageMin)->toEqual(2.4);
|
||||
});
|
||||
|
||||
it('generates coverage based on file input', function () {
|
||||
expect(Coverage::getMissingCoverage(new class() {
|
||||
public function lineCoverageData(): array
|
||||
{
|
||||
return [
|
||||
1 => ['foo'],
|
||||
2 => ['bar'],
|
||||
4 => [],
|
||||
5 => [],
|
||||
6 => [],
|
||||
7 => null,
|
||||
100 => null,
|
||||
101 => ['foo'],
|
||||
102 => [],
|
||||
];
|
||||
}
|
||||
}))->toEqual([
|
||||
'4..6', '102',
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user