dantudor / mockfs
This package is abandoned and no longer maintained.
No replacement package was suggested.
0.1
2013-05-22 09:56 UTC
Requires
- php: >=5.3
This package is not auto-updated.
Last update: 2018-10-01 00:16:13 UTC
README
Mock FileSystem for use with your PHPUnit tests.
Installation
To install via composer add dantudor/mockfs
as a dev dependency in your composer.json
file:
{
"require-dev": {
"dantudor/mockfs": "dev/master"
}
}
Features
As this is still in development only the following commands have been tested and confirmed:
- is_dir (string $filename)
- mkdir (string $pathname)
- rmdir (string $dirname)
- file_exists (string $filename)
- is_readable (string $filename)
- file_get_contents (string $filename)
- rename (string $pathFrom, string $pathTo)
Priming
Add a Directory
# addDirectory($name, $path = '/', $recursive = true)
$mockFs = new MockFs\MockFs();
$mockFs->getFileSystem()
->addDirectory('Directory')
->addDirectory('Another Directory, '/Directory')
->addDirectory('Me too', '/New Folder')
;
Add a File
# addFile($name, $contents = null, $path = '/', $recursive = true)
$mockFs = new MockFs\MockFs();
$mockFs->getFileSystem()
->addFile('file.txt', 'File Contents')
->addFile('file.txt', 'File Contents', '/New Folder')
;
Setting Permissions, Owner Id and Group Id
$mockFs = new MockFs\MockFs();
$mockFs->getFileSystem()
->addDirectory('Directory')
;
$directory = $mockFs->getFileSystem()->getChild('Directory');
$directory
->setPermissions(0600)
->setOwnerId(501)
->setGroupId(100)
;
All file system objects are created recursively by default.