matusstafura / pest-plugin-fileloader
一个用于加载文件的PHP Pest插件
v0.2.0
2024-09-26 13:57 UTC
Requires
- php: ^8.1
- ext-simplexml: *
- pestphp/pest: ^1.2 || ^2.0
Requires (Dev)
- pestphp/pest-dev-tools: ^2.0.0
README
此Pest插件简化了测试中加载文件的过程。
如果您想测试一个响应,将其保存为json,然后加载一个文件进行测试
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'); });
可用方法
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
变更日志
有关最近更改的更多信息,请参阅变更日志。
致谢
许可
MIT许可(MIT)。有关更多信息,请参阅许可文件。