matusstafura / pest-plugin-fileloader
A PHP Pest plugin to load file
Installs: 55
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/matusstafura/pest-plugin-fileloader
Requires
- php: ^8.1 || ^8.2 || ^8.3 || ^8.4
- ext-simplexml: *
- pestphp/pest: ^2.0 || ^3.0 || ^4.0
Requires (Dev)
- pestphp/pest-dev-tools: ^2.0.0 || ^3.0 || ^4.0
README
This Pest plugin simplifies loading file for testing.
If you want to test a response, save it as json, load a file and test:
use function MatusStafura\PestPluginFileLoader\fileLoader; test('response', function () { $json = fileLoader()->json('tests/response_dump.json'); expect($json)->toBeArray() ->and($json['id'])->toBe(1) ->and($json['title'])->toBe('Shirt Black'); });
Available methods:
json(string $filepath): array // $json = fileLoader()->json('response.json'); plaintext(string $filepath): string // fileLoader()->plaintext('response.txt'); xmlToArray(string $filepath): array // fileLoader()->json('response.xml');
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.