Skip to content

Commit 1bf5357

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 1bf5357

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/Testing/PHPUnit/AbstractRectorTestCase.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ private function createInputFilePath(string $fixtureFilePath): string
296296
}
297297

298298
$fixtureBasename = pathinfo($trimmedFixtureFilePath, PATHINFO_BASENAME);
299-
return $inputFileDirectory . '/' . $fixtureBasename;
299+
$inputFilePath = $inputFileDirectory . '/' . $fixtureBasename;
300+
register_shutdown_function([FileSystem::class, 'delete'], $inputFilePath);
301+
302+
return $inputFilePath;
300303
}
301304
}

0 commit comments

Comments
 (0)