mirror of
https://github.com/pestphp/pest.git
synced 2026-12-06 07:42:17 +01:00
fix(tia): fingerprint the generated configuration like the restarter does (#2065)
* fix(tia): fingerprint the generated configuration like the restarter does * test(tia): pass one configuration option per call --------- Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Pest\Plugins\Configuration;
|
||||
use Pest\Plugins\Tia\ConfigurationFile;
|
||||
|
||||
beforeEach(function (): void {
|
||||
@@ -14,8 +15,12 @@ beforeEach(function (): void {
|
||||
});
|
||||
|
||||
afterEach(function (): void {
|
||||
@unlink($this->projectRoot.'/phpunit.xml');
|
||||
@unlink($this->projectRoot.'/phpunit.copy.xml');
|
||||
foreach (['phpunit.xml', 'phpunit.copy.xml'] as $file) {
|
||||
if (is_file($this->projectRoot.'/'.$file)) {
|
||||
unlink($this->projectRoot.'/'.$file);
|
||||
}
|
||||
}
|
||||
|
||||
@rmdir($this->projectRoot);
|
||||
});
|
||||
|
||||
@@ -40,3 +45,50 @@ it('gives a run with --no-configuration its own fingerprint', function (): void
|
||||
->toBe('none')
|
||||
->not->toBe(ConfigurationFile::projectDefault()->fingerprint($this->projectRoot));
|
||||
});
|
||||
|
||||
it('fingerprints the configuration Pest generates the way the Xdebug restarter does', function (array $leftovers): void {
|
||||
unlink($this->projectRoot.'/phpunit.xml');
|
||||
|
||||
foreach ($leftovers as $leftover) {
|
||||
file_put_contents($this->projectRoot.'/'.$leftover, '');
|
||||
}
|
||||
|
||||
$workingDirectory = (string) getcwd();
|
||||
chdir($this->projectRoot);
|
||||
$configuration = new Configuration;
|
||||
|
||||
try {
|
||||
$arguments = $configuration->handleArguments(['pest', '--tia']);
|
||||
$generatedPath = $configuration->generatedConfigurationPath();
|
||||
|
||||
expect($generatedPath)->toBeString()
|
||||
->and(basename((string) $generatedPath))->not->toBeIn($leftovers)
|
||||
->and(ConfigurationFile::fromArguments($arguments, $generatedPath)->fingerprint($this->projectRoot))
|
||||
->toBeNull()
|
||||
->toBe(ConfigurationFile::fromArguments(['pest', '--tia'])->fingerprint($this->projectRoot));
|
||||
} finally {
|
||||
$configuration->terminate();
|
||||
chdir($workingDirectory);
|
||||
|
||||
foreach ($leftovers as $leftover) {
|
||||
unlink($this->projectRoot.'/'.$leftover);
|
||||
}
|
||||
}
|
||||
})->with([
|
||||
'first name' => [[]],
|
||||
'fallback name' => [['.pest.xml']],
|
||||
'random name' => [['.pest.xml', '.pest-fallback.xml']],
|
||||
]);
|
||||
|
||||
it('fingerprints an explicit configuration apart from the one Pest generates', function (): void {
|
||||
$generatedPath = $this->projectRoot.'/.pest.xml';
|
||||
file_put_contents($generatedPath, '');
|
||||
|
||||
try {
|
||||
expect(ConfigurationFile::fromArguments(['-c'.$this->projectRoot.'/phpunit.copy.xml'], $generatedPath)->fingerprint($this->projectRoot))
|
||||
->toBe(ConfigurationFile::at($this->projectRoot.'/phpunit.copy.xml')->fingerprint($this->projectRoot))
|
||||
->not->toBe(ConfigurationFile::fromArguments(['--configuration', $generatedPath], $generatedPath)->fingerprint($this->projectRoot));
|
||||
} finally {
|
||||
unlink($generatedPath);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user