5 ms·
How does this compare to vfsStream[1]? I've used that in the past for mocking in unit tests. Does this offer anything more than vfsStream? [1]: https://githu
by nubs 12y ago
How does this compare to vfsStream[1]? I've used that in the past for mocking in unit tests. Does this offer anything more than vfsStream?
[1]: https://github.com/mikey179/vfsStream https://github.com/mikey179/vfsStream
- adlawson 12y agoOn the surface of it, there is no real difference. You can use them both with your usual `fopen` and `file_get_contents` builtins. I believe that the implementation is truer to the behaviour of how these builtin functions behave with a unix FS. Amongst some other subtleties, here's some examples: - vfsStream simply ignores handle modifiers (except for +)[1] - some effort has gone into showing where errors were triggered in userland code[2] - node types are represented as `fstat` would see them[3] rather than using simple types[4] vfsStream works perfectly fine, but if you want to use it more with testing file system operations; the closer you are to a true environment the better. Obviously this project isn't quite there yet, but it should be once a few issues have been ironed out. [1]: https://github.com/mikey179/vfsStream/blob/master/src/main/php/org/bovigo/vfs/vfsStreamWrapper.php#L253-L254 https://github.com/mikey179/vfsStream/blob/master/src/main/p... [2]: https://github.com/adlawson/vfs.php/blob/master/src/Logger/PhpErrorLogger.php#L53 https://github.com/adlawson/vfs.php/blob/master/src/Logger/P... [3]: https://github.com/adlawson/vfs.php/blob/master/src/Node/StatInterface.php#L17-L29 https://github.com/adlawson/vfs.php/blob/master/src/Node/Sta... [4]: https://github.com/mikey179/vfsStream/blob/master/src/main/php/org/bovigo/vfs/vfsStreamContent.php#L21-L27 https://github.com/mikey179/vfsStream/blob/master/src/main/p...