Skip to content

Commit 5035316

Browse files
committed
Fix(testing): Register shutdown handler to delete temp input file
- Register shutdown function to delete the temporary input file via FileSystem::delete - Avoid leftover test artifacts by removing fixture-derived files on process exit - Return $inputFilePath and ensure it is cleaned up after tests
1 parent e91db1f commit 5035316

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/Testing/PHPUnit/AbstractRectorTestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ protected function doTestFile(string $fixtureFilePath, bool $includeFixtureDirec
152152

153153
// to remove later in tearDown()
154154
$this->inputFilePath = $inputFilePath;
155+
register_shutdown_function([FileSystem::class, 'delete'], $inputFilePath);
155156

156157
if ($fixtureFilePath === $inputFilePath) {
157158
throw new ShouldNotHappenException('Fixture file and input file cannot be the same: ' . $fixtureFilePath);

0 commit comments

Comments
 (0)