News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

VG Tech Blog:
Mocking the File System Using PHPUnit and vfsStream
December 09, 2011 @ 09:40:13

On the VG Tech blog today there's another post related to unit testing (here's one from before) but this time they're talking about mocking the filesystem with vfsStream, a powerful tool that lets you interact with PHP streams as a virtual file system.

This article is about how to mock the file system when writing unit tests, and it will be rather code-heavy. [...] PHPUnit is the de-facto standard for unit testing in PHP projects, and this is what we will be using together with vfsStream in this article.

The include the code for a simple storage driver (VGF_Storage_Driver_Filesystem) to use with vfsStream with "store", "delete" and "get" methods. Also included are examples of using vfsStream to check things like directory existence, if a file exists, or if a file can be read. A few simple assertions are set up in their sample test to check the methods in their "VGF_Storage_Driver_Filesystem" class.

0 comments voice your opinion now!
unittest phpunit vfsstream tutorial filesystem mock


blog comments powered by Disqus

Similar Posts

Gonzalo Ayuso: Sending automated emails with PHP, Swiftmailer and Twig

Simon Jodet: Partial mocks with Mockery

Sebastian Bergmann's Blog: Test Dependencies in PHPUnit 3.4

PHPBuilder.com: Parsing XML with the DOM Extension for PHP 5

HowTo Forge: Installing The PHP-MSSQL Module On CentOS 5.0


Community Events





Don't see your event here?
Let us know!


configure testing developer framework opinion symfony2 interview code podcast unittest list release install introduction laravel series language community threedevsandamaybe refactor

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework