Skip to content

phpjuice/pest-plugin-vcr

Repository files navigation

Pest plugin for PHP-VCR

GitHub Actions Latest Stable Version Total Downloads License

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.

GitHub Actions Latest Stable Version Total Downloads License