Testing an extension, which means executing a test run and asserting on what it produced.
public function testItWritesAReportForACoveredFile(): void
{
$process = new Process([
'vendor/bin/phpunit',
'--configuration', __DIR__ . '/fixtures/phpunit.xml',
'--coverage-filter', __DIR__ . '/fixtures/src',
]);
$process->mustRun();
$report = json_decode(
file_get_contents(__DIR__ . '/fixtures/coverage.json'),
true, flags: JSON_THROW_ON_ERROR,
);
self::assertSame(100.0, $report['files']['src/Covered.php']['percent']);
}
A subprocess rather than an in-process run, because the extension registers against a runner that has already started in the outer test. It is slow — about four seconds per case — and there are eleven cases, which is an acceptable suite for a package whose entire job is to produce a file.