This gives you the possibilty to write unit tests that does not rely on a specific file, resource or stream, but rather on data provided by the test itself.
Creating a memory stream is easy; $fp = fopen('php://memory', 'r+');
. Now you have a resource that can be used and manipulated just like any other stream or file.