|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/** |
| 6 | + * This file is part of fast-forward/dev-tools. |
| 7 | + * |
| 8 | + * This source file is subject to the license bundled |
| 9 | + * with this source code in the file LICENSE. |
| 10 | + * |
| 11 | + * @copyright Copyright (c) 2026 Felipe Sayão Lobato Abreu <github@mentordosnerds.com> |
| 12 | + * @license https://opensource.org/licenses/MIT MIT License |
| 13 | + * |
| 14 | + * @see https://github.com/php-fast-forward/dev-tools |
| 15 | + * @see https://github.com/php-fast-forward |
| 16 | + * @see https://datatracker.ietf.org/doc/html/rfc2119 |
| 17 | + */ |
| 18 | + |
| 19 | +namespace FastForward\DevTools\PhpUnit\Coverage; |
| 20 | + |
| 21 | +use PHPUnit\Framework\TestCase; |
| 22 | +use PHPUnit\Framework\Attributes\CoversClass; |
| 23 | +use PHPUnit\Framework\Attributes\DataProvider; |
| 24 | +use PHPUnit\Framework\Attributes\Test; |
| 25 | + |
| 26 | +#[CoversClass(CoverageSummary::class)] |
| 27 | +class CoverageSummaryTest extends TestCase |
| 28 | +{ |
| 29 | + /** |
| 30 | + * @return array |
| 31 | + */ |
| 32 | + public static function provideCoverageData(): array |
| 33 | + { |
| 34 | + return [[0, 0, 100.0], [50, 200, 25.0], [1, 3, 33.33333333333333]]; |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * @param int $executed |
| 39 | + * @param int $executable |
| 40 | + * @param float $expectedPercentage |
| 41 | + * |
| 42 | + * @return void |
| 43 | + */ |
| 44 | + #[Test] |
| 45 | + #[DataProvider('provideCoverageData')] |
| 46 | + public function executedLinesReturnsValue(int $executed, int $executable, float $expectedPercentage): void |
| 47 | + { |
| 48 | + $summary = new CoverageSummary($executed, $executable); |
| 49 | + self::assertSame($executed, $summary->executedLines()); |
| 50 | + } |
| 51 | +} |
0 commit comments