Skip to content

Commit

Permalink
fix vcr cassettes path (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhdcodes authored Aug 29, 2021
1 parent 197ad2d commit ed90e6b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Pest plugin for PHP-VCR

![GitHub Actions](https://github.com/phpjuice/pest-plugin-vcr/actions/workflows/ci.yml/badge.svg)
[![Latest Stable Version](http://poser.pugx.org/phpjuice/pest-plugin-vcr/v)](https://packagist.org/packages/phpjuice/pest-plugin-vcr)
[![Total Downloads](http://poser.pugx.org/phpjuice/pest-plugin-vcr/downloads)](https://packagist.org/packages/phpjuice/pest-plugin-vcr)
[![Latest Stable Version](http://poser.pugx.org/phpjuice/pest-plugin-vcr/v)](https://packagist.org/packages/phpjuice/pest-plugin-vcr)
[![Total Downloads](http://poser.pugx.org/phpjuice/pest-plugin-vcr/downloads)](https://packagist.org/packages/phpjuice/pest-plugin-vcr)
[![License](http://poser.pugx.org/phpjuice/pest-plugin-vcr/license)](https://packagist.org/packages/phpjuice/pest-plugin-vcr)


Integrates Pest with PHP-VCR using plugins.
Integrates Pest with [PHP-VCR](http://php-vcr.github.io) using plugins.

## Installation

Expand All @@ -16,12 +15,24 @@ You can install the package via composer:
composer require phpjuice/pest-plugin-vcr --dev
```

## Setup

Add new folder inside tests to store cassettes:

```bash
mkdir tests/cassettes
```

Add the following line to your `Pest.php` file, inorder to instruct
php vcr of our cassettes folder:

```php
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 :
Expand All @@ -40,8 +51,8 @@ it('records requests to pestphp.com', function () {
});
```

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
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`
Expand Down Expand Up @@ -77,6 +88,6 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
This package was generated using the [PHP Package Boilerplate](https://laravelpackageboilerplate.com) by [Beyond Code](http://beyondco.de/).

![GitHub Actions](https://github.com/phpjuice/pest-plugin-vcr/actions/workflows/ci.yml/badge.svg)
[![Latest Stable Version](http://poser.pugx.org/phpjuice/pest-plugin-vcr/v)](https://packagist.org/packages/phpjuice/pest-plugin-vcr)
[![Total Downloads](http://poser.pugx.org/phpjuice/pest-plugin-vcr/downloads)](https://packagist.org/packages/phpjuice/pest-plugin-vcr)
[![Latest Stable Version](http://poser.pugx.org/phpjuice/pest-plugin-vcr/v)](https://packagist.org/packages/phpjuice/pest-plugin-vcr)
[![Total Downloads](http://poser.pugx.org/phpjuice/pest-plugin-vcr/downloads)](https://packagist.org/packages/phpjuice/pest-plugin-vcr)
[![License](http://poser.pugx.org/phpjuice/pest-plugin-vcr/license)](https://packagist.org/packages/phpjuice/pest-plugin-vcr)
3 changes: 0 additions & 3 deletions src/PestPluginVcr.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ function vcrTurnOn(string $cassetteName)
VCR::configure()->setStorage('json');
}

$root = __DIR__.DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR;
VCR::configure()->setCassettePath($root."tests/cassettes");

VCR::turnOn();
VCR::insertCassette($cassetteName);
}
Expand Down
3 changes: 3 additions & 0 deletions tests/Pest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use VCR\VCR;

/*
|--------------------------------------------------------------------------
| Test Case
Expand All @@ -12,6 +14,7 @@
*/

// uses(Tests\TestCase::class)->in('Feature');
VCR::configure()->setCassettePath(__DIR__.'/cassettes');

/*
|--------------------------------------------------------------------------
Expand Down

0 comments on commit ed90e6b

Please sign in to comment.