Skip to content

Instantly share code, notes, and snippets.

@till
Created May 22, 2014 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save till/182a4b5c98f7863a84e7 to your computer and use it in GitHub Desktop.
Save till/182a4b5c98f7863a84e7 to your computer and use it in GitHub Desktop.

Assuming you have the following tree and you want file operations on it, this is the minimum PHP you have to write to test it.

$ tree foo
foo
`-- bar

1 directory, 0 files

Add this to your composer.json:

{
    "require-dev": {
      "mikey179/vfsStream": "*"
    }
}

Here's a shiny example test case:

<?php
use org\bovigo\vfs\vfsStream;

class DirTest extends \PHPUnit_Framework_TestCase
{
    public function testSimple()
    {
        vfsStream::setup('my-root', 'null', ['foo' => ['bar' => []]]);
        $this->assertTrue(file_exists(vfsStream::url('my-root/foo')));
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment