May 25, 2022
0
Level 5
PHPUnit test multiple fake files in same directory
I'm writing a unit test for a function that tests to see if certain files exist in a directory.
I have tried following a similar approach to the one at this Laracasts discussion, but there's an important piece missing.
I need to create a few fake (temporary) files in only one directory. When I attempt to create such files in a for loop, however, each file is put into its own directory, which I don't want.
for ($i = 1; $i <= 3; $i++) {
$tmp = \Illuminate\Http\Testing\File::create("testFile-{$i}.txt", 10);
}
Is there any way to mock creating multiple files with specific names in the same directory?
Please or to participate in this conversation.