fix(tia): restrict Xdebug coverage to the source scope before tracing (#2091)

* fix(tia): restrict Xdebug coverage to the source scope before tracing

* fix(tia): set the Xdebug exclude filter before the bootstrap and keep case twins traced

---------

Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
This commit is contained in:
Jhon Farias
2026-12-04 09:43:25 +01:00
committed by GitHub
parent 586add8ff2
commit cd5bae7e91
10 changed files with 395 additions and 28 deletions
@@ -215,3 +215,28 @@ it('tells an include path through a symlink to a directory with a separator in i
}
}
})->skipOnWindows();
it('builds the source scope from the coverage filter and the source of the configuration', function (): void {
mkdir($this->projectRoot.'/vendor/acme', 0755, true);
file_put_contents($this->projectRoot.'/phpunit.xml', "<?xml version=\"1.0\"?>\n<phpunit><source><include><directory>lib</directory></include></source></phpunit>\n");
$realRoot = (string) realpath($this->projectRoot);
$withoutFilter = ConfigurationFile::fromArguments(['--configuration', $this->projectRoot.'/phpunit.xml'])
->sourceScope($this->projectRoot)
?->coverageExcludePaths($this->projectRoot);
$withFilter = ConfigurationFile::fromArguments(['--configuration', $this->projectRoot.'/phpunit.xml', '--coverage-filter', $realRoot.'/vendor/acme'])
->sourceScope($this->projectRoot)
?->coverageExcludePaths($this->projectRoot);
rmdir($this->projectRoot.'/vendor/acme');
rmdir($this->projectRoot.'/vendor');
expect($withoutFilter)->toBe([$realRoot.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR])
->and($withFilter)->toBe([]);
});
it('gives no source scope when the configuration cannot be read', function (): void {
file_put_contents($this->projectRoot.'/phpunit.xml', '<phpunit');
expect(ConfigurationFile::at($this->projectRoot.'/phpunit.xml')->sourceScope($this->projectRoot))->toBeNull();
});