Integrates Pest with PHP-VCR using plugins.
You can install the package via composer:
composer require phpjuice/pest-plugin-vcr --dev
Add new folder inside tests to store cassettes:
mkdir tests/cassettes
Add the following line to your Pest.php
file, this will tell
VCR where to look for cassettes
:
use VCR\VCR;
VCR::configure()->setCassettePath(__DIR__.'/cassettes');
This plugin will provide you with two handy functions vcrTurnOn
& vcrTurnOff
to turn on and off the http recording :
it('records requests to pestphp.com', function () {
vcrTurnOn('pestphp.com');
$result = file_get_contents('https://pestphp.com/');
expect($result)
->toBe('Hello from pestphp.');
vcrTurnOff();
});
The previous testsuite, will first send a request to pestphp.com
and
Record your test suite's HTTP interactions into a cassette and replay them
during future test runs for fast, deterministic, accurate tests.
Important before running your tests make sure to have the following folder
tests/cassettes
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, send us an email to [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the PHP Package Boilerplate by Beyond Code.