PHPackages                             covergenius/phpunit-testlistener-vcr - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. covergenius/phpunit-testlistener-vcr

ActiveLibrary[Testing &amp; Quality](/categories/testing)

covergenius/phpunit-testlistener-vcr
====================================

Integrates PHPUnit with PHP-VCR.

v4.2.2(1y ago)342.1k—0.9%24MITPHPPHP ^8.1CI passing

Since May 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/CoverGenius/phpunit-testlistener-vcr)[ Packagist](https://packagist.org/packages/covergenius/phpunit-testlistener-vcr)[ RSS](/packages/covergenius-phpunit-testlistener-vcr/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (2)Versions (31)Used By (4)

PHPUnit TestListener for PHP-VCR
================================

[](#phpunit-testlistener-for-php-vcr)

[![CI Tests](https://github.com/covergenius/phpunit-testlistener-vcr/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/covergenius/phpunit-testlistener-vcr/actions)[![License](https://camo.githubusercontent.com/a06a83bf30d4282ebb89bc3674dc39b6c5e986783d370017deef46194dbfa6b2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f636f76657267656e6975732f706870756e69742d746573746c697374656e65722d7663722e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Development Version](https://camo.githubusercontent.com/ed16c5301e640a7c963209761dac91b81ba4c1dd71df99251a3a0e6e22dba8da/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f636f76657267656e6975732f706870756e69742d746573746c697374656e65722d7663722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/covergenius/phpunit-testlistener-vcr)[![Monthly Installs](https://camo.githubusercontent.com/b02ad3a6e9b6974ceef77a6ffa0a5c8e45b6b37f8a629f9d80d0bde9384fa734/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f636f76657267656e6975732f706870756e69742d746573746c697374656e65722d7663722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/covergenius/phpunit-testlistener-vcr)

Integrates PHPUnit with [PHP-VCR](http://github.com/covergenius/php-vcr) using annotations.

[![PHP-VCR](https://user-images.githubusercontent.com/133832/27151811-0d95c6c4-514c-11e7-834e-eff1eec2ea16.png)](https://user-images.githubusercontent.com/133832/27151811-0d95c6c4-514c-11e7-834e-eff1eec2ea16.png)

Use `@vcr cassette_name` on your tests to turn VCR automatically on and off.

Usage example
-------------

[](#usage-example)

```
use PHPUnit\Framework\TestCase;
use VCR\PHPUnit\TestListener\Attributes\Vcr;

class VCRTest extends TestCase
{
    /**
     * @vcr unittest_annotation_test
     */
    public function testInterceptsWithAnnotations()
    {
        // Content of tests/fixtures/unittest_annotation_test: "This is a annotation test dummy".
        $result = file_get_contents('http://google.com');
        $this->assertEquals('This is a annotation test dummy.', $result, 'Call was not intercepted (using annotations).');
    }

    #[Vcr('unittest_annotation_test')]
    public function testInterceptsWithAttributes(): void
    {
        // Content of tests/fixtures/unittest_annotation_test: "This is a annotation test dummy".
        $result = file_get_contents('http://google.com');
        $this->assertEquals('This is a annotation test dummy.', $result, 'Call was not intercepted (using attributes).');
    }
}
```

Installation
------------

[](#installation)

1. Install using composer:

```
composer require --dev covergenius/phpunit-testlistener-vcr
```

### For phpunit version 10+

[](#for-phpunit-version-10)

2. Add listener to your `phpunit.xml`:

```

```

### For phpunit version 9 and below

[](#for-phpunit-version-9-and-below)

```

```

Dependencies
------------

[](#dependencies)

PHPUnit-Testlistener-VCR depends on the following;

- [php-vcr/php-vcr](https://github.com/covergenius/php-vcr)

### Version 4

[](#version-4)

- PHP 8.1+
- PHPUnit &gt;=10

### Version 3

[](#version-3)

- PHP 7.1+
- PHPUnit &lt;10

Run tests
---------

[](#run-tests)

In order to run all tests you need to get development dependencies using composer:

```
composer install
./vendor/bin/phpunit
```

Changelog
---------

[](#changelog)

**The changelog is manage at [PHPUnit testlistener for PHP-VCR releases page](https://github.com/covergenius/phpunit-testlistener-vcr/releases).**

Copyright
---------

[](#copyright)

Copyright (c) 2013-2018 Adrian Philipp. Released under the terms of the MIT license. See LICENSE for details. [Contributors](https://github.com/covergenius/phpunit-testlistener-vcr/graphs/contributors)

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance50

Moderate activity, may be stable

Popularity34

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~190 days

Recently: every ~72 days

Total

24

Last Release

366d ago

Major Versions

1.1.7 → 2.0.02016-12-19

2.0.0 → 3.0.02017-08-08

v3.x-dev → v4.0.02023-07-14

PHP version history (4 changes)1.0.0PHP &gt;=5.3.15

3.2.0PHP ^7.1

v3.3.0PHP ^7.4||^8.0

v4.0.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2955754?v=4)[Max](/maintainers/specialtactics)[@specialtactics](https://github.com/specialtactics)

---

Top Contributors

[![adri](https://avatars.githubusercontent.com/u/133832?v=4)](https://github.com/adri "adri (29 commits)")[![renatomefi](https://avatars.githubusercontent.com/u/823634?v=4)](https://github.com/renatomefi "renatomefi (16 commits)")[![specialtactics](https://avatars.githubusercontent.com/u/2955754?v=4)](https://github.com/specialtactics "specialtactics (4 commits)")[![sf-cg](https://avatars.githubusercontent.com/u/99694531?v=4)](https://github.com/sf-cg "sf-cg (3 commits)")[![cg-x](https://avatars.githubusercontent.com/u/53591541?v=4)](https://github.com/cg-x "cg-x (3 commits)")[![GaryJones](https://avatars.githubusercontent.com/u/88371?v=4)](https://github.com/GaryJones "GaryJones (2 commits)")[![chrisguitarguy](https://avatars.githubusercontent.com/u/1010392?v=4)](https://github.com/chrisguitarguy "chrisguitarguy (2 commits)")[![dborsatto](https://avatars.githubusercontent.com/u/94651?v=4)](https://github.com/dborsatto "dborsatto (2 commits)")[![MrRio](https://avatars.githubusercontent.com/u/47539?v=4)](https://github.com/MrRio "MrRio (2 commits)")[![alnorth](https://avatars.githubusercontent.com/u/672745?v=4)](https://github.com/alnorth "alnorth (2 commits)")[![ivancli](https://avatars.githubusercontent.com/u/14046763?v=4)](https://github.com/ivancli "ivancli (1 commits)")[![janhartigan](https://avatars.githubusercontent.com/u/580052?v=4)](https://github.com/janhartigan "janhartigan (1 commits)")[![Sevavietl](https://avatars.githubusercontent.com/u/1844827?v=4)](https://github.com/Sevavietl "Sevavietl (1 commits)")[![jorgemudry](https://avatars.githubusercontent.com/u/1508989?v=4)](https://github.com/jorgemudry "jorgemudry (1 commits)")[![justincy](https://avatars.githubusercontent.com/u/1037458?v=4)](https://github.com/justincy "justincy (1 commits)")

---

Tags

hacktoberfest

### Embed Badge

![Health badge](/badges/covergenius-phpunit-testlistener-vcr/health.svg)

```
[![Health](https://phpackages.com/badges/covergenius-phpunit-testlistener-vcr/health.svg)](https://phpackages.com/packages/covergenius-phpunit-testlistener-vcr)
```

###  Alternatives

[timacdonald/log-fake

A drop in fake logger for testing with the Laravel framework.

4235.9M56](/packages/timacdonald-log-fake)[jasonmccreary/laravel-test-assertions

A set of helpful assertions when testing Laravel applications.

3513.9M32](/packages/jasonmccreary-laravel-test-assertions)[ergebnis/phpunit-slow-test-detector

Provides facilities for detecting slow tests in phpunit/phpunit.

1468.1M72](/packages/ergebnis-phpunit-slow-test-detector)[typo3/testing-framework

The TYPO3 testing framework provides base classes for unit, functional and acceptance testing.

675.0M775](/packages/typo3-testing-framework)[robiningelbrecht/phpunit-pretty-print

Prettify PHPUnit output

76460.0k15](/packages/robiningelbrecht-phpunit-pretty-print)[webmozarts/strict-phpunit

Enables type-safe comparisons of objects in PHPUnit

31252.7k5](/packages/webmozarts-strict-phpunit)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
