I want to mock the creation of a file using the vfsstream
class MyClass{
public function createFile($dirPath)
{
$name = time() . "-RT";
$file = $dirPath . '/' . $name . '.tmp';
fopen($file, "w+");
if (file_exists($file)) {
return $name . '.tmp';
} else {
return '';
}
}
}
but when I try to test the file creation :
$filename = $myClass->createFile(vfsStream::url('/var/www/app/web/exported/folder'));
I get an error :
failed to open stream: "org\bovigo\vfs\vfsStreamWrapper::stream_open" call failed fopen(vfs://var/www/app/web/exported/folder)
I have see this question talking about mocking the fileSystem but it has no information about the file creation. Does the vfsstream support the file creation with the fopen function? How can I test the file creation?