Creating a new file for every test with vfsStream

I found vfsStream reading 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.

Well if you’re using vfsSystem:: i can imagine the problem you’re having is that the class is vfsStream instead?

Sorry that was just a spelling error in my message. I was using vfsStream not vfsSystem, however it was also a spelling error which caused the problems in my code. Everything is working great now.