Skip to content

Commit ed90e6b

Browse files
authored
fix vcr cassettes path (#4)
1 parent 197ad2d commit ed90e6b

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# Pest plugin for PHP-VCR
22

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

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

1110
## Installation
1211

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

18+
## Setup
19+
1920
Add new folder inside tests to store cassettes:
2021

2122
```bash
2223
mkdir tests/cassettes
2324
```
2425

26+
Add the following line to your `Pest.php` file, inorder to instruct
27+
php vcr of our cassettes folder:
28+
29+
```php
30+
use VCR\VCR;
31+
32+
33+
VCR::configure()->setCassettePath(__DIR__.'/cassettes');
34+
```
35+
2536
## Usage
2637

2738
This plugin will provide you with two handy functions `vcrTurnOn` & `vcrTurnOff` to turn on and off the http recording :
@@ -40,8 +51,8 @@ it('records requests to pestphp.com', function () {
4051
});
4152
```
4253

43-
The previous testsuite, will first send a request to `pestphp.com` and
44-
Record your test suite's HTTP interactions into a cassette and replay them
54+
The previous testsuite, will first send a request to `pestphp.com` and
55+
Record your test suite's HTTP interactions into a cassette and replay them
4556
during future test runs for fast, deterministic, accurate tests.
4657

4758
> **Important** before running your tests make sure to have the following folder `tests/cassettes`
@@ -77,6 +88,6 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
7788
This package was generated using the [PHP Package Boilerplate](https://laravelpackageboilerplate.com) by [Beyond Code](http://beyondco.de/).
7889

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

src/PestPluginVcr.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ function vcrTurnOn(string $cassetteName)
1717
VCR::configure()->setStorage('json');
1818
}
1919

20-
$root = __DIR__.DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR;
21-
VCR::configure()->setCassettePath($root."tests/cassettes");
22-
2320
VCR::turnOn();
2421
VCR::insertCassette($cassetteName);
2522
}

tests/Pest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use VCR\VCR;
4+
35
/*
46
|--------------------------------------------------------------------------
57
| Test Case
@@ -12,6 +14,7 @@
1214
*/
1315

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

1619
/*
1720
|--------------------------------------------------------------------------

0 commit comments

Comments
 (0)