Posted by Phantom784 on June 11, 2010 at 1:45pm
I'm writing a test of a function that imports data about users from a .csv file. As usernames are randomly generated for testing, I'm dynamically writing this file based on the generated usernames before uploading it. Naturally, I'm removing it before the test is finished running, but if the test crashes for some reason, the file will be left. Is there a way to specify a custom cleanup routine when someone presses "Clean environment" on the testing page that will delete this .csv file, or something else I can do to cleanly handle this situation?
Edit: I realized the best solution is probably to use php's "tempnam()" function to generate a filename in the /tmp folder to use.