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');
composer test
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.