Bryan Ashley, Full Stack Software Engineer at Weebly, have written an interesting case study on mocking the file system using vfsStream. vfsStream is a PHP stream wrapper for a virtual file system that may be helpful in unit tests to mock the real file system. It can be used with any unit test framework, like PHPUnit or SimpleTest.
Testing classes having dependencies on the file system can be tricky, the reason why vfsStream can be very helpful in such cases :
it allows you to define a file system structure, and provides you a path that your tests will be able to read/write/manipulate files from. This makes testing code that uses the php native functions for file manipulation super easy!