phpjuice / pest-plugin-vcr
Integrates Pest with PHP-VCR
Installs: 3 966
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: ^7.4|^8.0
- php-vcr/php-vcr: dev-master as 1.5
Requires (Dev)
- ext-curl: *
- filp/whoops: ^2.9
- pestphp/pest: ^1.17
- phpunit/phpunit: ^9.0
README
Integrates Pest with PHP-VCR using plugins.
Installation
You can install the package via composer:
composer require phpjuice/pest-plugin-vcr --dev
Setup
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');
Usage
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
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, send us an email to phpjuice@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
PHP Package Boilerplate
This package was generated using the PHP Package Boilerplate by Beyond Code.