I found vfsStream reading http://www.sitepoint.com/8-must-have-php-quality-assurance-tools/ but I’m finding it hard to use the way I like in my tests.
I’ve got a function which takes a path as an argument and if the file doesn’t exist the file is created and the number 1 is set as the content. If the file exists it reads in the content and adds 1 to it so if the content is 1 I write 2 back.
In my tests (using PHPUnit) I want the filesystem to be empty before every tests so that the file is created the first time I run the function. However right now using vfsSystem::setup() and vfsSystem:url() the file does not seem to be deleted beteween tests or test runs. When I in my tests check that the content is 1 after the first run it’s actually 20 and rises everytime I run the tests.