christeredvartsen / testfs
Virtual filesystem that can be used for testing
Installs: 2 178
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 2
Requires
- php: >=8.1
Requires (Dev)
- phpunit/phpunit: ^10.0
- psalm/plugin-phpunit: ^0.18.4
- symfony/var-dumper: ^6.2
- vimeo/psalm: ^5.5
README
Virtual filesystem for PHP for use with testing, implemented using a stream wrapper.
Requirements
This library requires PHP >= 8.1.
Installation
Install using Composer:
composer require christeredvartsen/testfs
Usage
To enable the stream wrapper you must first register it:
TestFs\StreamWrapper::register();
When it is registered it will pick up usage of the tfs://
protocol used with filesystem functions, for instance fopen()
, file_get_contents()
, touch()
and so forth.
You can also fetch the "root" of the virtual filesystem after registering the wrapper to inspect the assets (files and/or directories within the virtual filesystem):
$root = TestFs\StreamWrapper::getRoot();
Development
git clone git@github.com:christeredvartsen/testfs.git
composer install
composer run ci
License
Licensed under the MIT License.